You're reading "Content Management API"

Model filter

In DatoCMS you can create filters to help you (and other editors) quickly search for records

The Model filter object

A Model filter object is returned as part of the response body of each successful Index, Show, Create, Update or Delete API call. The following table contains the list of all its fields along with their type, description and example values.

Object fields:
filterobject

The actual filter

This attribute is required
namestring

The name of the filter

This attribute is required
sharedboolean

Whether it's a shared filter or not

This attribute is required

List all filters

To list all filters, send a GET request to the /item-type-filters endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/item-type-filters HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": [ { "type": "item_type_filter", "id": "34", "attributes": { "name": "Draft posts", "filter": { "status": { "eq": "draft" } }, "shared": true }, "relationships": { "item_type": { "data": { "type": "item_type", "id": "44" } } } } ] }

Retrieve a filter

To retrieve a filter, send a GET request to the /item-type-filters/:item_type_filter_id endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
GET https://site-api.datocms.com/item-type-filters/:item_type_filter_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "item_type_filter", "id": "34", "attributes": { "name": "Draft posts", "filter": { "status": { "eq": "draft" } }, "shared": true }, "relationships": { "item_type": { "data": { "type": "item_type", "id": "44" } } } } }

Create a new filter

To create a new filter, send a POST request to the /item-type-filters endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
POST https://site-api.datocms.com/item-type-filters HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "item_type_filter", "attributes": { "name": "Draft posts", "filter": { "status": { "eq": "draft" } }, "shared": true }, "relationships": { "item_type": { "data": { "type": "item_type", "id": "44" } } } } }
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "item_type_filter", "id": "34", "attributes": { "name": "Draft posts", "filter": { "status": { "eq": "draft" } }, "shared": true }, "relationships": { "item_type": { "data": { "type": "item_type", "id": "44" } } } } }

Update a filter

To update a filter, send a PUT request to the /item-type-filters/:item_type_filter_id endpoint, passing the resource arguments in the request body. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
PUT https://site-api.datocms.com/item-type-filters/:item_type_filter_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "item_type_filter", "id": "34", "attributes": { "name": "Draft posts", "filter": { "status": { "eq": "draft" } } } } }
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "item_type_filter", "id": "34", "attributes": { "name": "Draft posts", "filter": { "status": { "eq": "draft" } }, "shared": true }, "relationships": { "item_type": { "data": { "type": "item_type", "id": "44" } } } } }

Delete a filter

To delete a filter, send a DELETE request to the /item-type-filters/:item_type_filter_id endpoint. The following table contains the list of all the possible arguments, along with their type, description and examples values. All the arguments marked as required must be present in the request.

Example request
DELETE https://site-api.datocms.com/item-type-filters/:item_type_filter_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Example response
HTTP/1.1 200 OK
Content-Typeapplication/json; charset=utf-8
Cache-Controlcache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit30
X-RateLimit-Remaining28
{ "data": { "type": "item_type_filter", "id": "34", "attributes": { "name": "Draft posts", "filter": { "status": { "eq": "draft" } }, "shared": true }, "relationships": { "item_type": { "data": { "type": "item_type", "id": "44" } } } } }