Sorry, no results found for "".
We strongly recommend reading the Introduction to Records guide first. The payload for updating a record follows the same structure as creating one, so that guide is also an essential prerequisite.
The fundamental rules for structuring field values (i.e., strings, numbers, objects, references) are the same for both creating and updating records. For a complete reference on how to format the value for every field type, please see the Field Types Overview in the main records guide.
When updating an existing record, you only need to provide the fields you want to change. Any fields you omit from your payload will remain untouched.
The following sections highlight the rules and strategies that are specific to the update process.
As with creation, you cannot edit blocks directly; you must update the parent record that contains them. The payload you send uses a mix of block IDs and block objects to define the desired final state.
The rules for adding, updating, keeping, deleting, and reordering blocks are covered in detail in the main records guide.
➡️ See the complete guide to Creating and Updating Blocks
➡️ Before proceeding, ensure you have read the general guide on Localization
When you send an update request, the API follows these strict rules.
When you update a translated field, you must provide the entire object for that field, including all the languages you want to keep unchanged. You can't just send the one language you're changing.
{ "title": { "en": "Hello World", "it": "Ciao a tutti! (Updated)" }}
This is the only time you can't just send the one field you're changing. To add or remove a language from an entire record, you must include all translated fields in your request. This is to enforce the Locale Sync Rule and ensure all fields remain consistent.
title
and content
, your request must include both fields with the new fr
locale.If your API key only has permission for certain languages (e.g., only English), you must only include those languages in your update. The system is smart and will automatically protect and preserve the content for the languages you can't access (like Italian or French).
This table shows what happens in different situations. The key takeaway is that your update payload defines the new final state for the languages you are allowed to manage.
Your Role manages | Record currently Has | Your payload sends | Result |
---|---|---|---|
English | English | English | ✅ English is updated. |
English, Italian | English | English, Italian | ✅ English is updated. ➕ Italian is added. |
English, Italian | English, Italian | English | ✅ English is updated. ➖ Italian is removed. |
English, Italian | English, Italian | English, Italian | ✅ English is updated. ✅ Italian is updated. |
Eng, Ita, Fre | English, Italian | English, French | ✅ English is updated. ➖ Italian is removed. ➕ French is added. |
English | English, Italian | English | ✅ English is updated. 🛡️ Italian is preserved. |
English, Italian | English, French | English, Italian | ✅ English is updated. 🛡️ French is preserved. ➕ Italian is added. |
English, Italian | English, French | Italian | ➖ English is removed. 🛡️ French is preserved. ➕ Italian is added. |
The rules about localization work in combination with the rules for updating blocks: you use full block objects to create/update and block IDs to leave unchanged, but you do so within the object for a specific locale.
This payload updates the title of an existing block in the en
locale, while leaving the second English block and all Italian blocks untouched. The it
locale needs to be included in the payload, or the Italian locale will be deleted!
{ "content_blocks": { "en": [ { "id": "dhVR2HqgRVCTGFi0bWqLqA", "type": "item", "attributes": { "title": "Updated English Title" } }, "kL9mN3pQrStUvWxYzAbCdE" ], "it": [ "dhVR2HqgRVCTGFi_0bWqLqA", "kL9mN3pQrStUvWxYzAbCdE" ] }}
This payload adds a new block to the it
locale only. The en
locale needs to be included in the payload, or the Italian locale will be deleted!
{ "content_blocks": { "en": [ "dhVR2HqgRVCTGFi_0bWqLqA", "kL9mN3pQrStUvWxYzAbCdE" ], "it": [ "fG8hI1jKlMnOpQrStUvWxY", { "type": "item", "attributes": { "title": "Nuovo Blocco" }, "relationships": { "item_type": { "data": { "id": "BxZ9Y2aKQVeTnM4hP8wLpD", "type": "item_type" } } } }, "dhVR2HqgRVCTGFi0bWqLqA" ] }}
To add a new locale to an existing record, you must provide values for all localized fields for that new locale, and include existing locales that you want to preserve.
{ "title": { "en": "English Title", "fr": "Titre Français", }, "content_blocks": { "en": [ "dhVR2HqgRVCTGFi_0bWqLqA", "kL9mN3pQrStUvWxYzAbCdE" ], "fr": [ { "type": "item", "attributes": { "title": "Nouveau Bloc Français" }, "relationships": { "item_type": { "data": { "id": "BxZ9Y2aKQVeTnM4hP8wLpD", "type": "item_type" } } } } ] }}
To prevent clients from accidentally overwriting each other's changes, the update endpoint supports optimistic locking. You can include the record's current version number in the meta
object of your payload.
If the version on the server is newer than the one you provide, the API will reject the update with a 422 STALE_ITEM_VERSION
error, indicating that the record has been modified since you last fetched it.
Must be exactly "item"
.
Date of creation
Date of first publication
The ID of the current record version (for optimistic locking, see the example)
"4234"
The new stage to move the record to
The entity (account/collaborator/access token/sso user) who created the record
Returns a resource object of type item.
PUT https://site-api.datocms.com/items/:item_id HTTP/1.1Authorization: Bearer YOUR-API-TOKENAccept: application/jsonX-Api-Version: 3Content-Type: application/vnd.api+json
{ "data": { "type": "item", "id": "hWl-mnkWRYmMCSTq4z_piQ" }}
curl -g 'https://site-api.datocms.com/items/:item_id' \ -X PUT \ -H "Authorization: Bearer YOUR-API-TOKEN" \ -H "Accept: application/json" \ -H "X-Api-Version: 3" \ -H "Content-Type: application/vnd.api+json" \ --data-binary '{"data":{"type":"item","id":"hWl-mnkWRYmMCSTq4z_piQ"}}'
await fetch("https://site-api.datocms.com/items/:item_id", { method: "PUT", headers: { Authorization: "Bearer YOUR-API-TOKEN", Accept: "application/json", "X-Api-Version": "3", "Content-Type": "application/vnd.api+json", }, body: JSON.stringify({ data: { type: "item", id: "hWl-mnkWRYmMCSTq4z_piQ" }, }),});
HTTP/1.1 200 OKContent-Type: application/jsonCache-Control: cache-control: max-age=0, private, must-revalidateX-RateLimit-Limit: 30X-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 } }}