
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeUnfortunately, _createdAt cannot be modified after a document is first created, even through migrations. According to Sanity's documentation on setting created and modified dates:
You can set the
_createdAtattribute the first time you create a document, but it cannot be modified in subsequent mutations (without deleting and recreating the document).
The best approach is to create your own datetime fields in your schema for editorial purposes. These fields are fully editable and can be set during migration or updated anytime:
defineField({
name: 'originalCreatedAt',
type: 'datetime',
title: 'Original Creation Date',
description: 'The original creation date from the imported content',
})You can then populate these fields with a migration script using the migration tooling or the Sanity Client.
If you absolutely need the system _createdAt field to reflect the original dates, you'd have to:
_createdAt set to the original dates in your create mutationImportant: When you first create a document, you CAN set _createdAt to any value you want. It's only locked after that initial creation.
If you still have access to your original data source, you could:
create mutations:const doc = {
_id: 'imported-post-123',
_type: 'post',
_createdAt: originalPost.created, // Set it during initial creation
title: originalPost.title,
// ... other fields
}
await client.create(doc)The editorial date field approach (option 1) is generally the best practice, as it gives you full control over dates that matter to your content team, while the system _createdAt/_updatedAt fields track actual mutation history in Sanity.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store