Sanity App SDK
    Preparing search index...

    Interface CreateCommentOptionsBeta

    interface CreateCommentOptions {
        commentId?: string;
        contentSnapshot?: unknown;
        context?: Record<string, unknown>;
        dataset?: string;
        documentId: string;
        documentRevisionId?: string;
        documentType: string;
        fieldPath: string | Path;
        liveEdit?: boolean;
        message: CommentMessage;
        perspective?: ReleasePerspective | ClientPerspective;
        projectId?: string;
        resource?: DocumentResource;
        selection?: CommentTextSelection;
        source?: DocumentResource;
        status?: CommentStatus;
        threadId?: string;
    }

    Hierarchy (View Summary)

    Index

    Properties

    commentId?: string

    Reuse the id of a failed comment to retry it. Defaults to a new id.

    contentSnapshot?: unknown

    A copy of the content being discussed. References in it are weakened.

    context?: Record<string, unknown>

    Ambient information stored alongside the comment, merged over the defaults.

    The Studio writes tool, payload, intent, and notification here for its notification backend. The SDK has no source for any of them, so mentions in comments created this way do not send email unless you supply notification yourself. Deliberately loose: the organization-level store treats this as free-form, so no shape is worth promising.

    dataset?: string
    documentId: string
    documentRevisionId?: string

    The _rev of the document when the comment was written.

    Not filled in automatically: the SDK's local document revision is replaced by a transaction id while an edit is in flight, so it can name a revision that never reached the server. Nothing in the Studio reads this today.

    documentType: string
    fieldPath: string | Path

    Which field the thread hangs off, for example title or body[_key=="intro"].content.

    Required, and it has to resolve to a real path. There is no such thing as a comment on a document as a whole: the Studio only ever creates field comments, and its comment inspector throws on an empty path rather than ignoring it, so a pathless comment takes the inspector down for everyone looking at that document.

    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?: string
    resource?: DocumentResource

    Explicit resource object to use for this operation.

    Anchors the comment to a run of text inside a Portable Text field. Building one needs a live editor, so this comes from @portabletext/plugin-sdk-value rather than being constructed by hand.

    Use resource instead.

    status?: CommentStatus

    'open'

    threadId?: string

    Defaults to a new id, which starts a new thread.