Validate a new record
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 a payload for a new record without creating it. The payload has the same shape as the one for Create a new record. It goes through the same field checks: fields you omit get their default value, 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.
relationships.item_type must be a regular model. If it is a block model, the endpoint returns 404 NOT_FOUND. A block cannot be validated on its own: put it inside the block field of its parent record, and validate the parent record's payload instead.
id and meta are accepted, but ignoredThis endpoint checks field values only. id and meta are accepted so you can validate the same payload you will send to create the record, but they are not checked. An id with an invalid format, or one already used by another record, does not make the validation fail: the create request rejects it.
Body parameters
RFC 4122 UUID of record expressed in URL-safe base64 format
"hWl-mnkWRYmMCSTq4z_piQ"
The entity (account/collaborator/access token/sso user) who created the record
Examples
import { buildClient } from "@datocms/cma-client-node";
async function run() { const client = buildClient({ apiToken: process.env.DATOCMS_API_TOKEN });
await client.items.validateNew({ 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: {}, }, item_type: { type: "item_type", id: "DxMaW10UQiCmZcuuA-IkkA" }, });}
run();