REST API: GET view rule

Selections use rules to decide which profiles are included in the selection and which profiles are not. Profile that match at least on of the selection rules are included in the selection. To retrieve the properties and the conditions of a single rule, you can send a HTTP GET request to the following URL:$id/rule/$id?access_token=xxxx

The first $id code should be replaced with the numeric identifier of the selection from which you want to retrieve a rule. The second $id parameter should be the ID of the rule.

Returned fields

This method returns rule data. The following properties are returned:

  • ID: ID of the rule
  • name: Name of the rule
  • view: ID of the selection to which the rule belongs
  • disabled: Boolean value whether the rule is disabled / not used to match profiles
  • inverted: Boolean value whether this is an inverted rule, meaning that profiles are included in the rule if they do not match the rule
  • conditions: Array of conditions in the rule


A rule on its own contains conditions. For a profile to match a rule, it has to match all the conditions. The conditions property that is returned by this method holds an array of condition objects, with the following properties per condition:

  • ID: numeric ID of the condition
  • type: condition type
  • rule: numeric ID of the rule to which the condition belongs

Based on the condition type, specific properties are set. Specific condition types are discussed in separate articles, which are linked in the "More information" section.

JSON example

The JSON for a rule looks something like this:


PHP example

The following script can be used to fetch the properties of a rule.

// dependencies

// change this into your access token
$api = new CopernicaRestAPI("your-access-token", 3);

// do the call, and print result

The example above requires the CopernicaRestApi class.

More information

Since there are many condition types which behave very differently each condition type is explained in a separate article below.