Sanity Mutation icon

Sanity Mutation

Create, Read, Update, and Delete documents in Sanity.io

Create or Replace

AI-generated

Summary

Create or replace a document in the Sanity.io dataset with the specified JSON data and optional document ID, overwriting any existing document with that ID.

Inputs

  • Document ID — The ID of the document to create or replace. If left blank, a random ID will be generated.
  • Document Data (required) — The full JSON data for the document to be created or replaced.
  • Options — Optional parameters including whether to return the full document(s) in the response and the Sanity API version to use.

Output shape

a JSON array of document objects representing the created or replaced documents

The output contains the mutation results. The returned documents depend on the 'Return Documents' option, which defaults to true. If false, documents may not be returned. Errors are handled per item with error messages included if 'Continue On Fail' is enabled.

Links

Discussion