Sorry, no results found for "".

Show examples in:
Javascript HTTP

Content Management API > Record

Retrieve a record
📚 New to DatoCMS records?

Begin by reading the Introduction to records guide to familiarize yourself with field types, API response modes, and the concepts of block manipulation!

To retrieve a single record, send a GET request to the /items/:id endpoint.

Response modes: Regular vs. Nested

The GET /items/:id endpoint, just like the List all records endpoint, supports two different response modes that control how block fields are returned in the JSON payload. You can switch between them using the nested query parameter.

  • Regular mode (default): This is the most efficient mode for listing records. Any block fields (like Modular Content) will contain an array of block IDs, not the full block content. This keeps the response size small and fast.

  • Nested mode (nested=true): This mode returns the complete content for any block fields. Instead of just IDs, the API will return full block objects, including all their attributes. This is useful when you need to display the blocks' content immediately without making additional API calls, or to read existing content and then make an update.

GET https://site-api.datocms.com/items/:item_id HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Terminal window
curl -g 'https://site-api.datocms.com/items/:item_id' \
\
-H "Authorization: Bearer YOUR-API-TOKEN" \
-H "Accept: application/json" \
-H "X-Api-Version: 3"
await fetch("https://site-api.datocms.com/items/:item_id", {
headers: {
Authorization: "Bearer YOUR-API-TOKEN",
Accept: "application/json",
"X-Api-Version": "3",
},
});
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": {
"type": "item",
"id": "hWl-mnkWRYmMCSTq4z_piQ",
"relationships": {
"item_type": {
"data": {
"type": "item_type",
"id": "DxMaW10UQiCmZcuuA-IkkA"
}
}
},
"attributes": {
"title": "My first blog post!",
"content": "Lorem ipsum dolor sit amet...",
"category": "24",
"image": {
"alt": "Alt text",
"title": "Image title",
"custom_data": {},
"focal_point": null,
"upload_id": "20042921"
}
},
"meta": {
"created_at": "2020-04-21T07:57:11.124Z",
"updated_at": "2020-04-21T07:57:11.124Z",
"published_at": "2020-04-21T07:57:11.124Z",
"first_published_at": "2020-04-21T07:57:11.124Z",
"publication_scheduled_at": "2020-04-21T07:57:11.124Z",
"unpublishing_scheduled_at": "2020-04-21T07:57:11.124Z",
"status": "published",
"is_current_version_valid": true,
"is_published_version_valid": true,
"current_version": "4234",
"stage": null,
"has_children": true
}
}
}

Sometimes, you may wish to fetch a record that has embedded blocks inside Modular Content, Single Block or Structured Text fields.

By default, those nested blocks are returned as block IDs (ie. "dhVR2HqgRVCTGFi_0bWqLqA"), but if you add the nested=true query parameter, we'll embed the blocks content inline for you.

GET https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Terminal window
curl -g 'https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true' \
\
-H "Authorization: Bearer YOUR-API-TOKEN" \
-H "Accept: application/json" \
-H "X-Api-Version: 3"
await fetch(
"https://site-api.datocms.com/items/FEzWmQhjQgeHsCrUtvlEMw?nested=true",
{
headers: {
Authorization: "Bearer YOUR-API-TOKEN",
Accept: "application/json",
"X-Api-Version": "3",
},
},
);
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": {
"id": "FEzWmQhjQgeHsCrUtvlEMw",
"type": "item",
"attributes": {
"structured_text_field": {
"schema": "dast",
"document": {
"children": [
{
"item": {
"type": "item",
"attributes": {
"button_label": "Example button",
"button_url": "https://www.example.com"
},
"relationships": {
"item_type": {
"data": {
"id": "SkVjHJSGR5CyK16E8TfJxg",
"type": "item_type"
}
}
},
"id": "ahxSnFQEQ02K3TjttWAg-Q"
},
"type": "block"
},
{
"item": {
"type": "item",
"attributes": {
"nested_structured_text_field": {
"schema": "dast",
"document": {
"children": [
{
"children": [
{
"type": "span",
"value": "This is a "
},
{
"marks": ["emphasis"],
"type": "span",
"value": "nested"
},
{
"type": "span",
"value": " structured text block inside the parent structured text field."
}
],
"type": "paragraph"
},
{
"item": {
"type": "item",
"attributes": {
"button_label": "And this is a button inside the nested structured text block",
"button_url": "https://www.example2.com"
},
"relationships": {
"item_type": {
"data": {
"id": "SkVjHJSGR5CyK16E8TfJxg",
"type": "item_type"
}
}
},
"id": "CGqwjPDsTHKGFy1IbC0RAQ"
},
"type": "block"
}
],
"type": "root"
}
}
},
"relationships": {
"item_type": {
"data": {
"id": "Ty4S40cbQH6_VMNnGdd9KA",
"type": "item_type"
}
}
},
"id": "AppHB06oRBm-er3oooL_LA"
},
"type": "block"
}
],
"type": "root"
}
}
},
"relationships": {
"item_type": {
"data": {
"id": "UVa_hHEBSeefLEUnwoQFig",
"type": "item_type"
}
},
"creator": {
"data": {
"id": "104280",
"type": "account"
}
}
},
"meta": {
"created_at": "2024-03-13T17:01:19.243+00:00",
"updated_at": "2024-03-13T17:14:17.444+00:00",
"published_at": "2024-03-13T17:14:17.597+00:00",
"publication_scheduled_at": null,
"unpublishing_scheduled_at": null,
"first_published_at": "2024-03-13T17:01:19.326+00:00",
"is_valid": true,
"is_current_version_valid": true,
"is_published_version_valid": true,
"status": "published",
"current_version": "DLtyHZ2MTDqYMg7g5mgYEw",
"stage": null
}
}
}

Query parameters

nested boolean

For Modular Content, Structured Text and Single Block fields. If set, returns full payload for nested blocks instead of IDs

version string

Whether you want the currently published versions (published, default) of your records, or the latest available (current)

Example: "published"

Returns

Returns a resource object of type item.