See how we built our intranet. Live + Q&A, June 30

When using the Sanity client API, do we need to manually set _updatedAt?

1 replyLast updated: Nov 29, 2025

When using the Sanity client API, do we need to manually set _updatedAt value or is this set in the API for us?
AI Update

No, you do not need to manually set the _updatedAt value when using the Sanity client API. This field is automatically set by the system.

How System Fields Work

According to the Sanity document type documentation, every document in Sanity automatically includes several system fields:

These fields are managed automatically by Sanity's Content Lake. When you create or update a document through mutations (like create, patch, createOrReplace, etc.), Sanity automatically:

Important Caveat

While these timestamps are automatically set by the system, there's an important note from the documentation:

"_createdAt and _updatedAt are automatically set by the system to the current time when the document is created or updated, respectively. It is possible to provide a custom value when the document is initially created via a create, createIfNotExists, or createOrReplace mutation. Since the timestamps can be set by a client, they should never be assumed to be accurate."

This means:

Best Practice

Simply perform your mutations without worrying about _updatedAt or _createdAt - Sanity will handle these system fields automatically for you. The system automatically updates _updatedAt every time you modify a document through any mutation operation.

Show original thread
1 reply

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions