Skip to content

Timestamp overrides

When creating or updating documents, Appwrite automatically sets $createdAt and $updatedAt timestamps. However, there are scenarios where you might need to set these timestamps manually, such as when migrating data from another system or backfilling historical records.

Server SDKs required

To manually set $createdAt and $updatedAt, you must use a server SDK with an API key. These attributes can be passed inside the data parameter on any of the create, update, or upsert routes (single or bulk).

Setting custom timestamps

You can override a document's timestamps by providing ISO 8601 strings (for example, 2025-08-10T12:34:56.000Z) in the data payload. If these attributes are not provided, Appwrite will set them automatically.

Custom timestamps work with all document operations: create, update, upsert, and their bulk variants.

Single document operations

When working with individual documents, you can set custom timestamps during create, update, and upsert operations.

Create with custom timestamps

Update with custom timestamps

When updating documents, you can also set a custom $updatedAt timestamp:

Bulk operations

Custom timestamps also work with bulk operations, allowing you to set different timestamps for each document in the batch:

Bulk create

Bulk upsert

Common use cases

Custom timestamps are particularly useful in several scenarios:

Data migration

When migrating existing data from another system, you can preserve the original creation and modification times:

Backdating records

For historical data entry or when creating records that represent past events:

Synchronization

When synchronizing data between systems while maintaining timestamp consistency:

Timestamp format and usage
  • Values must be valid ISO 8601 date-time strings (UTC recommended). Using toISOString() (JavaScript) or datetime.isoformat() (Python) is a good default.
  • You can set either or both attributes as needed. If omitted, Appwrite sets them automatically.