Sanity Library Reference Docs
    Preparing search index...

    Interface CommentBeta

    A single comment.

    Deliberately not the stored document: this stays put while the comment API's own shape moves, and it flattens away the parts of the stored shape that exist for storage rather than for reading — the global document reference, the array keys on reactions, the nested target.

    Threads are flat: every comment in a thread shares a threadId, the thread's first comment has no parentCommentId, and replies carry that first comment's id. Use CommentThread to work with them grouped.

    interface Comment {
        authorId?: string;
        contentSnapshot?: CommentMessage;
        context?: Record<string, unknown>;
        createdAt: string;
        documentId: string;
        documentType: string;
        fieldPath: string;
        id: string;
        lastEditedAt?: string;
        message: CommentMessage;
        parentCommentId?: string;
        reactions: CommentReaction[];
        selection?: CommentTextSelection;
        sourceDocumentId: string;
        state?: CommentLocalState;
        status: CommentStatus;
        threadId: string;
    }
    Index

    Properties

    authorId?: string

    Who wrote it.

    Absent when the server records attribution elsewhere, as it does for an agent-authored comment. Render a fallback rather than assuming a user id.

    contentSnapshot?: CommentMessage

    A copy of the content the comment was written about, resolved by the API when the comment was created. Inline comments only, and only the part of each block the selection covers.

    context?: Record<string, unknown>

    Free-form data the writing app stored with the comment, as passed to createComment or replyToComment. Absent when none was given.

    createdAt: string
    documentId: string

    The document the thread hangs on, always the published id.

    documentType: string
    fieldPath: string

    The field the thread hangs off, for example title.

    id: string
    lastEditedAt?: string

    Set once the message has been rewritten.

    parentCommentId?: string

    Absent on the comment that starts a thread.

    reactions: CommentReaction[]

    Set when the comment is anchored to a run of text in a Portable Text field.

    sourceDocumentId: string

    The exact document id the comment was written against: a published id, a draft id, or a version id.

    documentId groups every form of a document into one thread list; this tells them apart, which matters when reading across more than one.

    Local only. Present while a create is failing or being retried.

    threadId: string