Type Alias CreateAction

CreateAction: {
    actionType: "sanity.action.document.create";
    attributes: IdentifiedSanityDocumentStub;
    ifExists: "fail" | "ignore";
    publishedId: string;
}

Creates a new draft document. The published version must not already exist. If a draft exists, the action will fail by default.

Type declaration

  • actionType: "sanity.action.document.create"
  • attributes: IdentifiedSanityDocumentStub

    Document to create. Must have _type property

  • ifExists: "fail" | "ignore"

    What to do if draft exists: 'fail' or 'ignore'

  • publishedId: string

    ID of the published document to create a draft for

await client.action({
actionType: 'sanity.action.document.create',
publishedId: 'bike-123',
attributes: {name: 'New Bike', _type: 'bike'},
ifExists: 'fail' // or 'ignore' to keep existing draft
})