Show examples in:
JavascriptHTTP
Endpoint info
Available examples
Content Management API > Record

Validate an existing record

Warning: Experimental API

Please note that this API method is marked as unstable and should be avoided in production environments. Changes may occur at any time without warning, potentially impacting your scripts. We recommend contacting our Support Team to explore alternative approaches that are safer and more reliable!

Checks an update payload for an existing record without saving it. The payload has the same shape as the one for Update a record, except that attributes is required. It goes through the same field checks: the attributes you send are merged with the record's current version, then every field and every nested block is validated against its model.

The response is 204 No Content when the payload is valid, or a 422 with INVALID_FIELD errors when it is not. Nothing is saved.

⚠️ Block records are not accepted

The ID in the URL must belong to a record of a regular model. If it belongs to a block, the endpoint returns 404 NOT_FOUND. A block cannot be validated on its own: validate the payload of the record that contains it instead.

⚠️ meta is accepted, but ignored

This endpoint checks field values only. meta is accepted so you can validate the same payload you will send to update the record, but none of its keys is checked. In particular, a stale meta.current_version does not make the validation fail: the optimistic locking check runs only when you update the record, which then returns 422 STALE_ITEM_VERSION.

Body parameters

idstringRequired

RFC 4122 UUID of record expressed in URL-safe base64 format

Example:"hWl-mnkWRYmMCSTq4z_piQ"
item_typeOptional

The record's model

Type:<a href="/docs/content-management-api/resources/item_type">ResourceLinkage&#x3C;"item_type"></a>
creatorOptional

The entity (account/collaborator/access token/sso user) who created the record

Type:<a href="/docs/content-management-api/resources/account">ResourceLinkage&#x3C;"account"></a>, <a href="/docs/content-management-api/resources/access_token">ResourceLinkage&#x3C;"access_token"></a>, <a href="/docs/content-management-api/resources/user">ResourceLinkage&#x3C;"user"></a>, <a href="/docs/content-management-api/resources/sso_user">ResourceLinkage&#x3C;"sso_user"></a>, <a href="/docs/content-management-api/resources/organization">ResourceLinkage&#x3C;"organization"></a>

Examples

import { buildClient } from "@datocms/cma-client-node";
async function run() {
const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
const itemId = "hWl-mnkWRYmMCSTq4z_piQ";
await client.items.validateExisting(itemId, {
title: "My first blog post!",
content: "Lorem ipsum dolor sit amet...",
category: "24",
image: {
upload_id: "WxrWMPl3TjeSJYcl6lNCbg",
alt: "Alt text",
title: "Image title",
custom_data: {},
},
});
}
run();