Create a Filter Set¶
Create a filter set to start using filter rules to control content manually.
Endpoint¶
POST https://api.crowdynews.com/collection/sets
Request Parameters¶
HEADER FIELD | VALUE DESCRIPTION |
---|---|
Content-Type | The content type of the request body, must be set to application/json . |
QUERY PARAMETER | VALUE DESCRIPTION |
---|---|
access_token | A valid OAuth access token with the correct permission(s). |
REQUEST BODY DATA | VALUE TYPE | VALUE DESCRIPTION |
---|---|---|
name | String | Identifies the set in a human readable way and must be unique inside a contract. This name can be changed after creation. |
contractId | String | The resource ID that specifies to which contract this set belongs. The consumer that wants to create the set must have access to the provided contract, otherwise this action is forbidden. |
rules | Array | The filter rules that determine if a content item will be rejected or accepted. Each element is a rule object. |
preCondition | Object | A rule object that must evaluate to true before the filter rules will be processed. The entire set will be skipped when the this property evaluates to false . |
or | Boolean | Optional. Specifies if all rules must be evaluated before determining if a content item should be rejected or if we can stop processing the rules as soon the first rule evaluates to true , rejecting the content item. The first happens when the or property is set to true . The latter happens when the or property is set to false . This property defaults to false when omitted. |
active | Boolean | Optional. Specifies if this chain will be processed by the platform. This property defaults to true when omitted. |
REQUEST BODY DATA (RULE OBJECT) | VALUE TYPE | VALUE DESCRIPTION |
---|---|---|
operator | String | The kind of logic used by the rule. Supported operators are:
|
field | String | The content item property used by the rule to apply operator logic against. |
value | String or Number or Array | Optional. The value a rule uses to evaluate a content item. This may be an array of values when in or patternin are used as operators, alternatively a list can be used in combination with these operators, in which case a listId property must be specified instead of the value property. |
listId | String | Optional. The resource ID that specifies which list of values must be used by the rule. A list can only be used in combination with the in and patternin operators. The list must belong to the same contract that is referenced in the contractId property of the set and the consumer that wants to create this set must have access to said contract, otherwise this action is forbidden. |
not | Boolean | Flips the value the rule evaluates to. For example, when a rule evaluates to true and the not property is set to true , the rule will evaluate to false . |
Response Format¶
On success, the HTTP status code in the response header is
201 Created
and the response body will contain a set
object in JSON format. On error, the header status code is
an error code
and the response body contains an error object.
Example Request¶
Request:
POST https://api.crowdynews.com/collection/sets?access_token={your access token}
{
"contractId": "565c4df4056e859526e62257",
"name": "Twitter Blacklist",
"preCondition": {
"operator": "equals",
"field": "service",
"value": "twitter",
"not": false
},
"rules": [
{
"operator": "equals",
"field": "user",
"value": "Justin Bieber",
"not": false
}
]
}
Response:
HTTP/1.1 201
{
"_id": "565d4de4056f859526d53389",
"created": "2016-05-03T10:26:22.009Z",
"lastModified": "2016-05-03T10:26:22.009Z",
"lastModifiedBy": "John Doe",
"createdBy": "John Doe",
"contractId": "565c4df4056e859526e62257",
"name": "Twitter Blacklist",
"preCondition": {
"operator": "equals",
"field": "service",
"value": "twitter",
"not": false
},
"active": true,
"rules": [
{
"operator": "equals",
"field": "user",
"value": "Justin Bieber",
"not": false
}
],
"or": false
}