Sanity Library Reference Docs
    Preparing search index...

    Interface CreateDocumentAction<TDocumentType, TDataset, TProjectId>Beta

    Represents an action to create a new document. Specifies the document type and optionally a document ID (which will be treated as the published ID).

    interface CreateDocumentAction<
        TDocumentType extends string = string,
        TDataset extends string = string,
        TProjectId extends string = string,
    > {
        dataset?: TDataset;
        documentId?: string;
        documentType: TDocumentType;
        initialValue?: Partial<
            Omit<
                SanityDocument<TDocumentType, `${TProjectId}.${TDataset}`>,
                "_type" | "_id" | "_rev" | "_createdAt" | "_updatedAt",
            >,
        >;
        liveEdit?: boolean;
        perspective?: ReleasePerspective | ClientPerspective;
        projectId?: TProjectId;
        source?: DocumentSource;
        sourceName?: string;
        type: "document.create";
    }

    Type Parameters

    • TDocumentType extends string = string
    • TDataset extends string = string
    • TProjectId extends string = string

    Hierarchy (View Summary)

    Index

    Properties

    dataset?: TDataset
    documentId?: string
    documentType: TDocumentType
    initialValue?: Partial<
        Omit<
            SanityDocument<TDocumentType, `${TProjectId}.${TDataset}`>,
            "_type" | "_id" | "_rev" | "_createdAt" | "_updatedAt",
        >,
    >

    Optional initial field values for the document. These values will be set when the document is created. System fields (_id, _type, _rev, _createdAt, _updatedAt) are omitted as they are set automatically.

    liveEdit?: boolean

    Indicates whether this document uses liveEdit mode. When true, the document does not use the draft/published model and edits are applied directly to the document.

    perspective?: ReleasePerspective | ClientPerspective
    projectId?: TProjectId

    Explicit source object to use for this operation.

    sourceName?: string

    The name of the source to use for this operation.

    type: "document.create"