You're reading "Content Management API"

Model

The way you define the kind of content you can edit inside your administrative area passes through the concept of Models, which are much like database tables. For backward-compatibility reasons, the API refers to models as "item types".

The Model object

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

Object fields:
all_locales_requiredboolean
api_keystring
collection_appeareancestring
draft_mode_activeboolean
has_singleton_itemboolean
modular_blockboolean
namestring
ordering_directionstring
singletonboolean
sortableboolean
treeboolean

List all models

To list all models, send a GET request to the /item-types 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-types 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", "id": "44", "attributes": { "name": "Blog post", "api_key": "post", "collection_appeareance": "compact", "singleton": false, "all_locales_required": false, "sortable": true, "modular_block": false, "draft_mode_active": false, "tree": false, "ordering_direction": null, "has_singleton_item": true }, "relationships": { "menu_item": { "data": null }, "singleton_item": { "data": null }, "fields": { "data": [ { "type": "field", "id": "124" } ] }, "title_field": { "data": null }, "ordering_field": { "data": null } } } ] }

Retrieve a model

To retrieve a model, send a GET request to the /item-types/:item_type_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-types/:item_type_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", "id": "44", "attributes": { "name": "Blog post", "api_key": "post", "collection_appeareance": "compact", "singleton": false, "all_locales_required": false, "sortable": true, "modular_block": false, "draft_mode_active": false, "tree": false, "ordering_direction": null, "has_singleton_item": true }, "relationships": { "menu_item": { "data": null }, "singleton_item": { "data": null }, "fields": { "data": [ { "type": "field", "id": "124" } ] }, "title_field": { "data": null }, "ordering_field": { "data": null } } } }

Create a new model

To create a new model, send a POST request to the /item-types 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-types HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "item_type", "attributes": { "name": "Blog post", "api_key": "post", "singleton": false, "all_locales_required": false, "sortable": true, "modular_block": false, "draft_mode_active": false, "tree": false, "ordering_direction": null, "collection_appeareance": "compact" }, "relationships": { "ordering_field": { "data": null }, "title_field": { "data": null } } } }
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", "id": "44", "attributes": { "name": "Blog post", "api_key": "post", "collection_appeareance": "compact", "singleton": false, "all_locales_required": false, "sortable": true, "modular_block": false, "draft_mode_active": false, "tree": false, "ordering_direction": null, "has_singleton_item": true }, "relationships": { "menu_item": { "data": null }, "singleton_item": { "data": null }, "fields": { "data": [ { "type": "field", "id": "124" } ] }, "title_field": { "data": null }, "ordering_field": { "data": null } } }, "included": [ { "type": "menu_item", "id": "34", "attributes": { "label": "Posts", "external_url": null, "position": 1 }, "relationships": { "item_type": { "data": { "type": "item_type", "id": "44" } }, "parent": { "data": null }, "children": { "data": [ { "type": "menu_item", "id": "34" } ] } } } ] }

Update a model

To update a model, send a PUT request to the /item-types/:item_type_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-types/:item_type_id HTTP/1.1
X-Api-Version2
AuthorizationBearer YOUR-API-KEY
Acceptapplication/json
Content-Typeapplication/json
{ "data": { "type": "item_type", "id": "44", "attributes": { "name": "Blog post", "api_key": "post", "collection_appeareance": "compact", "singleton": false, "all_locales_required": false, "sortable": true, "modular_block": false, "draft_mode_active": false, "tree": false, "ordering_direction": null, "has_singleton_item": true }, "relationships": { "ordering_field": { "data": null }, "title_field": { "data": null } } } }
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", "id": "44", "attributes": { "name": "Blog post", "api_key": "post", "collection_appeareance": "compact", "singleton": false, "all_locales_required": false, "sortable": true, "modular_block": false, "draft_mode_active": false, "tree": false, "ordering_direction": null, "has_singleton_item": true }, "relationships": { "menu_item": { "data": null }, "singleton_item": { "data": null }, "fields": { "data": [ { "type": "field", "id": "124" } ] }, "title_field": { "data": null }, "ordering_field": { "data": null } } } }

Delete a model

To delete a model, send a DELETE request to the /item-types/:item_type_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-types/:item_type_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", "id": "44", "attributes": { "name": "Blog post", "api_key": "post", "collection_appeareance": "compact", "singleton": false, "all_locales_required": false, "sortable": true, "modular_block": false, "draft_mode_active": false, "tree": false, "ordering_direction": null, "has_singleton_item": true }, "relationships": { "menu_item": { "data": null }, "singleton_item": { "data": null }, "fields": { "data": [ { "type": "field", "id": "124" } ] }, "title_field": { "data": null }, "ordering_field": { "data": null } } } }

Duplicate model

To duplicate model, send a POST request to the /item-types/:item_type_id/duplicate 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-types/:item_type_id/duplicate 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", "id": "44", "attributes": { "name": "Blog post", "api_key": "post", "collection_appeareance": "compact", "singleton": false, "all_locales_required": false, "sortable": true, "modular_block": false, "draft_mode_active": false, "tree": false, "ordering_direction": null, "has_singleton_item": true }, "relationships": { "menu_item": { "data": null }, "singleton_item": { "data": null }, "fields": { "data": [ { "type": "field", "id": "124" } ] }, "title_field": { "data": null }, "ordering_field": { "data": null } } } }