POST https://YOUR-NETWORK-DOMAIN/rest-api/rule/create.do
Creates a new targeting rule in the system. The request body must be a JSON object containing the rule's name, type (CAMPAIGN or INVENTORY), active status, default-for flags, and an optional ruleMatches array. Each rule match specifies categories (AdvertisingCategory IDs for CAMPAIGN type, PublisherCategory IDs for INVENTORY type), label IDs, a logical operator (AND/OR), and an include/exclude flag. Returns a JSON object with 'success: true' and the newly created 'ruleId', or validation errors if the input is invalid. Requires authentication and CREATE permission on the RULES static ACL identity.
Body
A JSON body. An example, built from the field definitions:
using var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://YOUR-NETWORK-DOMAIN/rest-api/rule/create.do");
request.Headers.Add("X-Api-Key", "YOUR_API_KEY");
request.Content = new StringContent("{\"id\":\"200\",\"name\":\"Block Adult Content\",\"active\":\"true\",\"type\":\"CAMPAIGN\"}", Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine(await response.Content.ReadAsStringAsync());