Sanity Library Reference Docs
    Preparing search index...
    interface components {
        headers: never;
        parameters: never;
        pathItems: never;
        requestBodies: never;
        responses: never;
        schemas: {
            ApiErrorBody: {
                code:
                    | "knowledgeBaseNotFound"
                    | "jobNotFound"
                    | "sourceNotFound"
                    | "documentNotFound"
                    | "syncNotFound"
                    | "uploadNotFound"
                    | "chunkNotFound"
                    | "entryNotFound"
                    | "entryDocumentInvalid"
                    | "revisionNotFound"
                    | "revisionNotBrowsable"
                    | "revisionNotRestorable"
                    | "buildDecisionsNotFound"
                    | "issueNotFound"
                    | "instructionNotFound"
                    | "routeNotFound"
                    | "buildInFlight"
                    | "knowledgeBaseIsDraft"
                    | "webSourceRootConflict"
                    | "webSourceRootLimitExceeded"
                    | "preferenceLimitExceeded"
                    | "syncInProgress"
                    | "syncNotHeld"
                    | "sourceDeletionsUnconfirmed"
                    | "documentNotConverted"
                    | "documentNotStored"
                    | "documentInvalidState"
                    | "uploadTooLarge"
                    | "payloadTooLarge"
                    | "validationError"
                    | "unsupportedMediaType"
                    | "sourceTypeMismatch"
                    | "issueNotResolvable"
                    | "issueNotAutoApplicable"
                    | "issueDocumentInvalid"
                    | "issueTransitionConflict"
                    | "draftTitleRequired"
                    | "datasetSourceEmpty"
                    | "datasetAlreadyBound"
                    | "datasetSourceNotBound"
                    | "datasetReadAccessDenied"
                    | "invalidGroqFilter"
                    | "mcpEndpointNotFound"
                    | "mcpEndpointNameConflict"
                    | "mcpEndpointEditConflict"
                    | "mcpSourceKnowledgeBaseNotFound"
                    | "mcpEndpointNotServable"
                    | "conversationNotFound"
                    | "missingCredential"
                    | "invalidCredential"
                    | "missingOrganization"
                    | "organizationAccessDenied"
                    | "knowledgeBaseAccessDenied"
                    | "contextGrantRequired"
                    | "knowledgeBaseCreateAccessDenied"
                    | "mcpEndpointManageAccessDenied"
                    | "insightsWriteAccessDenied"
                    | "sharedOrgPreferencesWriteAccessDenied"
                    | "projectAdminRequired"
                    | "accessCheckFailed"
                    | "planLimitReached"
                    | "featureNotInPlan"
                    | "buildCapReached"
                    | "tooManyConnections"
                    | "jobsUnavailable"
                    | "contextStoreUnavailable"
                    | "crawlingUnavailable"
                    | "crawlPreviewUnavailable"
                    | "instructionDraftFailed"
                    | "instructionScopeVanished"
                    | "purposeDraftFailed"
                    | "noPurposeEvidence"
                    | "idempotencyKeyReused"
                    | "idempotencyRequestInFlight"
                    | "idempotencyParamsMismatch"
                    | "internal";
                error: string;
                fields?: { [key: string]: unknown };
                message: string;
                statusCode: number;
            };
            ConversationDoc: {
                _createdAt: string;
                _id: string;
                _rev: string;
                _type: "sanity.context.conversation";
                _updatedAt: string;
                classificationError: string
                | null;
                classifiedAt: string | null;
                coreMetrics:
                    | {
                        contentGaps?: string[];
                        sentiment?: "positive"
                        | "neutral"
                        | "negative";
                        successScore?: number;
                    }
                    | null;
                messages: {
                    content: string
                    | null;
                    error: string | null;
                    role: "user" | "assistant" | "system" | "tool";
                    timestamp: string | null;
                    toolName: string | null;
                    toolType: "result" | "call" | null;
                }[];
                messagesUpdatedAt: string;
                metadata: { [key: string]: string | string[] }
                | null;
                modelId: string | null;
                modelProvider: string | null;
                organizationId: string;
                schemaVersion: 1;
                sharing:
                    | { contact?: string; conversations?: boolean; metrics?: boolean }
                    | null;
                startedAt: string;
                threadId: string;
                tokenUsage:
                    | {
                        inputTokens?: number;
                        outputTokens?: number;
                        totalTokens?: number;
                    }
                    | null;
                updatedAt?: string;
            };
            EntryDoc: {
                _createdAt: string;
                _id: string;
                _rev: string;
                _type: "sanity.context.entry";
                _updatedAt: string;
                body?: string;
                citations: {
                    _key: string;
                    _type: "sanity.context.citation";
                    chunkId: string;
                    claims: string[];
                    documentId: string;
                    lineEnd: number;
                    lineStart: number;
                    prefix: string;
                    quote: string;
                    suffix: string;
                    title: string;
                    url?: string;
                }[];
                documentIds: string[];
                generatedAt: string;
                knowledgeBaseId: string;
                path: string;
                revisionId: string;
                schemaVersion: number;
                sectionTitles?: string[];
                status: "virtual"
                | "outlined"
                | "filled"
                | "stale"
                | "generation_failed";
                title: string;
                tldr?: { excludes: string; neighbors?: string[]; scope: string };
                topicHeadings?: string[];
                updatedAt?: string;
            };
            InstructionDoc: | {
                _createdAt: string;
                _id: string;
                _rev: string;
                _type: "sanity.context.instruction";
                _updatedAt: string;
                archivedAt: string
                | null;
                archivedReason: string | null;
                knowledgeBaseId: string;
                origin: "conflict";
                schemaVersion: 2;
                scopeDocuments:
                    | { _key: string; contentHash: string; documentId: string }[]
                    | null;
                sourceIssueId: string;
                statement: string;
                status: "active" | "archived";
                updatedAt?: string;
            }
            | {
                _createdAt: string;
                _id: string;
                _rev: string;
                _type: "sanity.context.instruction";
                _updatedAt: string;
                archivedAt: string
                | null;
                archivedReason: string | null;
                knowledgeBaseId: string;
                origin: "human";
                schemaVersion: 2;
                scopeDocuments:
                    | { _key: string; contentHash: string; documentId: string }[]
                    | null;
                sourceIssueId: null;
                statement: string;
                status: "active" | "archived";
                updatedAt?: string;
            };
            IssueDoc: | {
                _createdAt: string;
                _id: string;
                _rev: string;
                _type: "sanity.context.issue";
                _updatedAt: string;
                content: | {
                    claimKey: string;
                    context?: string;
                    issue: string;
                    kind: "conflict";
                    scopePath: string;
                    severity: "critical"
                    | "suggestion";
                    sides: {
                        authority?: "primary" | "secondary" | "community";
                        citations?: {
                            _key: string;
                            _type: "sanity.context.citation";
                            chunkId: string;
                            documentId: string;
                            lineEnd: number;
                            lineStart: number;
                            prefix: string;
                            quote: string;
                            suffix: string;
                            title: string;
                            url?: (...) | (...);
                        }[];
                        claim: string;
                        documentIds?: string[];
                        entryPaths?: string[];
                        value?: string;
                        where?: string;
                    }[];
                    suggested?: number;
                    suggestedFix: string;
                }
                | {
                    citedDocumentIds?: string[];
                    claimKey?: string;
                    involvedScopes?: string[];
                    issue: string;
                    kind: "update_required";
                    scopePath: string;
                    severity: "critical"
                    | "suggestion";
                    suggestedFix: string;
                };
                fingerprint: string;
                knowledgeBaseId: string;
                resolution: null;
                resolvedAt: null;
                resolvedBy: null;
                revisionId: string
                | null;
                schemaVersion: 2;
                status: "open";
                updatedAt?: string;
            }
            | {
                _createdAt: string;
                _id: string;
                _rev: string;
                _type: "sanity.context.issue";
                _updatedAt: string;
                content: | {
                    claimKey: string;
                    context?: string;
                    issue: string;
                    kind: "conflict";
                    scopePath: string;
                    severity: "critical"
                    | "suggestion";
                    sides: {
                        authority?: "primary" | "secondary" | "community";
                        citations?: {
                            _key: string;
                            _type: "sanity.context.citation";
                            chunkId: string;
                            documentId: string;
                            lineEnd: number;
                            lineStart: number;
                            prefix: string;
                            quote: string;
                            suffix: string;
                            title: string;
                            url?: (...) | (...);
                        }[];
                        claim: string;
                        documentIds?: string[];
                        entryPaths?: string[];
                        value?: string;
                        where?: string;
                    }[];
                    suggested?: number;
                    suggestedFix: string;
                }
                | {
                    citedDocumentIds?: string[];
                    claimKey?: string;
                    involvedScopes?: string[];
                    issue: string;
                    kind: "update_required";
                    scopePath: string;
                    severity: "critical"
                    | "suggestion";
                    suggestedFix: string;
                };
                fingerprint: string;
                knowledgeBaseId: string;
                resolution: number
                | null;
                resolvedAt: string;
                resolvedBy: { id: string; kind: "user" | "robot" } | null;
                revisionId: string | null;
                schemaVersion: 2;
                status: "accepted";
                updatedAt?: string;
            }
            | {
                _createdAt: string;
                _id: string;
                _rev: string;
                _type: "sanity.context.issue";
                _updatedAt: string;
                content: | {
                    claimKey: string;
                    context?: string;
                    issue: string;
                    kind: "conflict";
                    scopePath: string;
                    severity: "critical"
                    | "suggestion";
                    sides: {
                        authority?: "primary" | "secondary" | "community";
                        citations?: {
                            _key: string;
                            _type: "sanity.context.citation";
                            chunkId: string;
                            documentId: string;
                            lineEnd: number;
                            lineStart: number;
                            prefix: string;
                            quote: string;
                            suffix: string;
                            title: string;
                            url?: (...) | (...);
                        }[];
                        claim: string;
                        documentIds?: string[];
                        entryPaths?: string[];
                        value?: string;
                        where?: string;
                    }[];
                    suggested?: number;
                    suggestedFix: string;
                }
                | {
                    citedDocumentIds?: string[];
                    claimKey?: string;
                    involvedScopes?: string[];
                    issue: string;
                    kind: "update_required";
                    scopePath: string;
                    severity: "critical"
                    | "suggestion";
                    suggestedFix: string;
                };
                fingerprint: string;
                knowledgeBaseId: string;
                resolution: null;
                resolvedAt: string;
                resolvedBy: { id: string; kind: "user" | "robot" }
                | null;
                revisionId: string | null;
                schemaVersion: 2;
                status: "rejected";
                updatedAt?: string;
            };
            McpDoc: {
                _createdAt: string;
                _id: string;
                _rev: string;
                _type: "sanity.context.mcp";
                _updatedAt: string;
                groqFilter: string
                | null;
                instructions: string | null;
                lastUsedAt?: string | null;
                name: string;
                organizationId: string;
                publicId: string;
                schemaVersion: 1;
                sources: (
                    | { id: string; type: "knowledge-base" }
                    | {
                        id: string;
                        perspective: "published" | "drafts" | "raw" | null;
                        semanticSearch: boolean | null;
                        type: "dataset";
                        workspace: string | null;
                    }
                )[];
                title: string;
                updatedAt?: string;
            };
        };
    }
    Index

    Properties

    headers: never
    parameters: never
    pathItems: never
    requestBodies: never
    responses: never
    schemas: {
        ApiErrorBody: {
            code:
                | "knowledgeBaseNotFound"
                | "jobNotFound"
                | "sourceNotFound"
                | "documentNotFound"
                | "syncNotFound"
                | "uploadNotFound"
                | "chunkNotFound"
                | "entryNotFound"
                | "entryDocumentInvalid"
                | "revisionNotFound"
                | "revisionNotBrowsable"
                | "revisionNotRestorable"
                | "buildDecisionsNotFound"
                | "issueNotFound"
                | "instructionNotFound"
                | "routeNotFound"
                | "buildInFlight"
                | "knowledgeBaseIsDraft"
                | "webSourceRootConflict"
                | "webSourceRootLimitExceeded"
                | "preferenceLimitExceeded"
                | "syncInProgress"
                | "syncNotHeld"
                | "sourceDeletionsUnconfirmed"
                | "documentNotConverted"
                | "documentNotStored"
                | "documentInvalidState"
                | "uploadTooLarge"
                | "payloadTooLarge"
                | "validationError"
                | "unsupportedMediaType"
                | "sourceTypeMismatch"
                | "issueNotResolvable"
                | "issueNotAutoApplicable"
                | "issueDocumentInvalid"
                | "issueTransitionConflict"
                | "draftTitleRequired"
                | "datasetSourceEmpty"
                | "datasetAlreadyBound"
                | "datasetSourceNotBound"
                | "datasetReadAccessDenied"
                | "invalidGroqFilter"
                | "mcpEndpointNotFound"
                | "mcpEndpointNameConflict"
                | "mcpEndpointEditConflict"
                | "mcpSourceKnowledgeBaseNotFound"
                | "mcpEndpointNotServable"
                | "conversationNotFound"
                | "missingCredential"
                | "invalidCredential"
                | "missingOrganization"
                | "organizationAccessDenied"
                | "knowledgeBaseAccessDenied"
                | "contextGrantRequired"
                | "knowledgeBaseCreateAccessDenied"
                | "mcpEndpointManageAccessDenied"
                | "insightsWriteAccessDenied"
                | "sharedOrgPreferencesWriteAccessDenied"
                | "projectAdminRequired"
                | "accessCheckFailed"
                | "planLimitReached"
                | "featureNotInPlan"
                | "buildCapReached"
                | "tooManyConnections"
                | "jobsUnavailable"
                | "contextStoreUnavailable"
                | "crawlingUnavailable"
                | "crawlPreviewUnavailable"
                | "instructionDraftFailed"
                | "instructionScopeVanished"
                | "purposeDraftFailed"
                | "noPurposeEvidence"
                | "idempotencyKeyReused"
                | "idempotencyRequestInFlight"
                | "idempotencyParamsMismatch"
                | "internal";
            error: string;
            fields?: { [key: string]: unknown };
            message: string;
            statusCode: number;
        };
        ConversationDoc: {
            _createdAt: string;
            _id: string;
            _rev: string;
            _type: "sanity.context.conversation";
            _updatedAt: string;
            classificationError: string
            | null;
            classifiedAt: string | null;
            coreMetrics:
                | {
                    contentGaps?: string[];
                    sentiment?: "positive"
                    | "neutral"
                    | "negative";
                    successScore?: number;
                }
                | null;
            messages: {
                content: string
                | null;
                error: string | null;
                role: "user" | "assistant" | "system" | "tool";
                timestamp: string | null;
                toolName: string | null;
                toolType: "result" | "call" | null;
            }[];
            messagesUpdatedAt: string;
            metadata: { [key: string]: string | string[] }
            | null;
            modelId: string | null;
            modelProvider: string | null;
            organizationId: string;
            schemaVersion: 1;
            sharing:
                | { contact?: string; conversations?: boolean; metrics?: boolean }
                | null;
            startedAt: string;
            threadId: string;
            tokenUsage:
                | {
                    inputTokens?: number;
                    outputTokens?: number;
                    totalTokens?: number;
                }
                | null;
            updatedAt?: string;
        };
        EntryDoc: {
            _createdAt: string;
            _id: string;
            _rev: string;
            _type: "sanity.context.entry";
            _updatedAt: string;
            body?: string;
            citations: {
                _key: string;
                _type: "sanity.context.citation";
                chunkId: string;
                claims: string[];
                documentId: string;
                lineEnd: number;
                lineStart: number;
                prefix: string;
                quote: string;
                suffix: string;
                title: string;
                url?: string;
            }[];
            documentIds: string[];
            generatedAt: string;
            knowledgeBaseId: string;
            path: string;
            revisionId: string;
            schemaVersion: number;
            sectionTitles?: string[];
            status: "virtual"
            | "outlined"
            | "filled"
            | "stale"
            | "generation_failed";
            title: string;
            tldr?: { excludes: string; neighbors?: string[]; scope: string };
            topicHeadings?: string[];
            updatedAt?: string;
        };
        InstructionDoc: | {
            _createdAt: string;
            _id: string;
            _rev: string;
            _type: "sanity.context.instruction";
            _updatedAt: string;
            archivedAt: string
            | null;
            archivedReason: string | null;
            knowledgeBaseId: string;
            origin: "conflict";
            schemaVersion: 2;
            scopeDocuments:
                | { _key: string; contentHash: string; documentId: string }[]
                | null;
            sourceIssueId: string;
            statement: string;
            status: "active" | "archived";
            updatedAt?: string;
        }
        | {
            _createdAt: string;
            _id: string;
            _rev: string;
            _type: "sanity.context.instruction";
            _updatedAt: string;
            archivedAt: string
            | null;
            archivedReason: string | null;
            knowledgeBaseId: string;
            origin: "human";
            schemaVersion: 2;
            scopeDocuments:
                | { _key: string; contentHash: string; documentId: string }[]
                | null;
            sourceIssueId: null;
            statement: string;
            status: "active" | "archived";
            updatedAt?: string;
        };
        IssueDoc: | {
            _createdAt: string;
            _id: string;
            _rev: string;
            _type: "sanity.context.issue";
            _updatedAt: string;
            content: | {
                claimKey: string;
                context?: string;
                issue: string;
                kind: "conflict";
                scopePath: string;
                severity: "critical"
                | "suggestion";
                sides: {
                    authority?: "primary" | "secondary" | "community";
                    citations?: {
                        _key: string;
                        _type: "sanity.context.citation";
                        chunkId: string;
                        documentId: string;
                        lineEnd: number;
                        lineStart: number;
                        prefix: string;
                        quote: string;
                        suffix: string;
                        title: string;
                        url?: (...) | (...);
                    }[];
                    claim: string;
                    documentIds?: string[];
                    entryPaths?: string[];
                    value?: string;
                    where?: string;
                }[];
                suggested?: number;
                suggestedFix: string;
            }
            | {
                citedDocumentIds?: string[];
                claimKey?: string;
                involvedScopes?: string[];
                issue: string;
                kind: "update_required";
                scopePath: string;
                severity: "critical"
                | "suggestion";
                suggestedFix: string;
            };
            fingerprint: string;
            knowledgeBaseId: string;
            resolution: null;
            resolvedAt: null;
            resolvedBy: null;
            revisionId: string
            | null;
            schemaVersion: 2;
            status: "open";
            updatedAt?: string;
        }
        | {
            _createdAt: string;
            _id: string;
            _rev: string;
            _type: "sanity.context.issue";
            _updatedAt: string;
            content: | {
                claimKey: string;
                context?: string;
                issue: string;
                kind: "conflict";
                scopePath: string;
                severity: "critical"
                | "suggestion";
                sides: {
                    authority?: "primary" | "secondary" | "community";
                    citations?: {
                        _key: string;
                        _type: "sanity.context.citation";
                        chunkId: string;
                        documentId: string;
                        lineEnd: number;
                        lineStart: number;
                        prefix: string;
                        quote: string;
                        suffix: string;
                        title: string;
                        url?: (...) | (...);
                    }[];
                    claim: string;
                    documentIds?: string[];
                    entryPaths?: string[];
                    value?: string;
                    where?: string;
                }[];
                suggested?: number;
                suggestedFix: string;
            }
            | {
                citedDocumentIds?: string[];
                claimKey?: string;
                involvedScopes?: string[];
                issue: string;
                kind: "update_required";
                scopePath: string;
                severity: "critical"
                | "suggestion";
                suggestedFix: string;
            };
            fingerprint: string;
            knowledgeBaseId: string;
            resolution: number
            | null;
            resolvedAt: string;
            resolvedBy: { id: string; kind: "user" | "robot" } | null;
            revisionId: string | null;
            schemaVersion: 2;
            status: "accepted";
            updatedAt?: string;
        }
        | {
            _createdAt: string;
            _id: string;
            _rev: string;
            _type: "sanity.context.issue";
            _updatedAt: string;
            content: | {
                claimKey: string;
                context?: string;
                issue: string;
                kind: "conflict";
                scopePath: string;
                severity: "critical"
                | "suggestion";
                sides: {
                    authority?: "primary" | "secondary" | "community";
                    citations?: {
                        _key: string;
                        _type: "sanity.context.citation";
                        chunkId: string;
                        documentId: string;
                        lineEnd: number;
                        lineStart: number;
                        prefix: string;
                        quote: string;
                        suffix: string;
                        title: string;
                        url?: (...) | (...);
                    }[];
                    claim: string;
                    documentIds?: string[];
                    entryPaths?: string[];
                    value?: string;
                    where?: string;
                }[];
                suggested?: number;
                suggestedFix: string;
            }
            | {
                citedDocumentIds?: string[];
                claimKey?: string;
                involvedScopes?: string[];
                issue: string;
                kind: "update_required";
                scopePath: string;
                severity: "critical"
                | "suggestion";
                suggestedFix: string;
            };
            fingerprint: string;
            knowledgeBaseId: string;
            resolution: null;
            resolvedAt: string;
            resolvedBy: { id: string; kind: "user" | "robot" }
            | null;
            revisionId: string | null;
            schemaVersion: 2;
            status: "rejected";
            updatedAt?: string;
        };
        McpDoc: {
            _createdAt: string;
            _id: string;
            _rev: string;
            _type: "sanity.context.mcp";
            _updatedAt: string;
            groqFilter: string
            | null;
            instructions: string | null;
            lastUsedAt?: string | null;
            name: string;
            organizationId: string;
            publicId: string;
            schemaVersion: 1;
            sources: (
                | { id: string; type: "knowledge-base" }
                | {
                    id: string;
                    perspective: "published" | "drafts" | "raw" | null;
                    semanticSearch: boolean | null;
                    type: "dataset";
                    workspace: string | null;
                }
            )[];
            title: string;
            updatedAt?: string;
        };
    }

    Type declaration

    • ApiErrorBody: {
          code:
              | "knowledgeBaseNotFound"
              | "jobNotFound"
              | "sourceNotFound"
              | "documentNotFound"
              | "syncNotFound"
              | "uploadNotFound"
              | "chunkNotFound"
              | "entryNotFound"
              | "entryDocumentInvalid"
              | "revisionNotFound"
              | "revisionNotBrowsable"
              | "revisionNotRestorable"
              | "buildDecisionsNotFound"
              | "issueNotFound"
              | "instructionNotFound"
              | "routeNotFound"
              | "buildInFlight"
              | "knowledgeBaseIsDraft"
              | "webSourceRootConflict"
              | "webSourceRootLimitExceeded"
              | "preferenceLimitExceeded"
              | "syncInProgress"
              | "syncNotHeld"
              | "sourceDeletionsUnconfirmed"
              | "documentNotConverted"
              | "documentNotStored"
              | "documentInvalidState"
              | "uploadTooLarge"
              | "payloadTooLarge"
              | "validationError"
              | "unsupportedMediaType"
              | "sourceTypeMismatch"
              | "issueNotResolvable"
              | "issueNotAutoApplicable"
              | "issueDocumentInvalid"
              | "issueTransitionConflict"
              | "draftTitleRequired"
              | "datasetSourceEmpty"
              | "datasetAlreadyBound"
              | "datasetSourceNotBound"
              | "datasetReadAccessDenied"
              | "invalidGroqFilter"
              | "mcpEndpointNotFound"
              | "mcpEndpointNameConflict"
              | "mcpEndpointEditConflict"
              | "mcpSourceKnowledgeBaseNotFound"
              | "mcpEndpointNotServable"
              | "conversationNotFound"
              | "missingCredential"
              | "invalidCredential"
              | "missingOrganization"
              | "organizationAccessDenied"
              | "knowledgeBaseAccessDenied"
              | "contextGrantRequired"
              | "knowledgeBaseCreateAccessDenied"
              | "mcpEndpointManageAccessDenied"
              | "insightsWriteAccessDenied"
              | "sharedOrgPreferencesWriteAccessDenied"
              | "projectAdminRequired"
              | "accessCheckFailed"
              | "planLimitReached"
              | "featureNotInPlan"
              | "buildCapReached"
              | "tooManyConnections"
              | "jobsUnavailable"
              | "contextStoreUnavailable"
              | "crawlingUnavailable"
              | "crawlPreviewUnavailable"
              | "instructionDraftFailed"
              | "instructionScopeVanished"
              | "purposeDraftFailed"
              | "noPurposeEvidence"
              | "idempotencyKeyReused"
              | "idempotencyRequestInFlight"
              | "idempotencyParamsMismatch"
              | "internal";
          error: string;
          fields?: { [key: string]: unknown };
          message: string;
          statusCode: number;
      }

      The body of every error response. Branch on code, a stable identifier; message is human-readable and can change.

    • ConversationDoc: {
          _createdAt: string;
          _id: string;
          _rev: string;
          _type: "sanity.context.conversation";
          _updatedAt: string;
          classificationError: string | null;
          classifiedAt: string | null;
          coreMetrics:
              | {
                  contentGaps?: string[];
                  sentiment?: "positive"
                  | "neutral"
                  | "negative";
                  successScore?: number;
              }
              | null;
          messages: {
              content: string
              | null;
              error: string | null;
              role: "user" | "assistant" | "system" | "tool";
              timestamp: string | null;
              toolName: string | null;
              toolType: "result" | "call" | null;
          }[];
          messagesUpdatedAt: string;
          metadata: { [key: string]: string | string[] }
          | null;
          modelId: string | null;
          modelProvider: string | null;
          organizationId: string;
          schemaVersion: 1;
          sharing:
              | { contact?: string; conversations?: boolean; metrics?: boolean }
              | null;
          startedAt: string;
          threadId: string;
          tokenUsage:
              | { inputTokens?: number; outputTokens?: number; totalTokens?: number }
              | null;
          updatedAt?: string;
      }

      A sanity.context.conversation document: one agent conversation and its classification, stored in your organization's document store. No endpoint returns this document. Use this schema to type GROQ query results. To record conversations, use the conversations endpoints.

      • _createdAt: string

        Format: date-time

        When the document was created, as an ISO 8601 timestamp.

      • _id: string

        The document ID.

      • _rev: string

        The document revision. It changes on every write.

      • _type: "sanity.context.conversation"

        The document type. Always sanity.context.conversation.

      • _updatedAt: string

        Format: date-time

        When the document was last changed, as an ISO 8601 timestamp.

      • classificationError: string | null

        Why your classifier couldn't classify the conversation. null when no failure is recorded. Recording a result clears it.

      • classifiedAt: string | null

        Format: date-time

        When the latest classification result was recorded, as an ISO 8601 timestamp. The API sets it. null until you record a result.

      • coreMetrics:
            | {
                contentGaps?: string[];
                sentiment?: "positive"
                | "neutral"
                | "negative";
                successScore?: number;
            }
            | null

        The latest classification result. null until you record one.

      • messages: {
            content: string | null;
            error: string | null;
            role: "user" | "assistant" | "system" | "tool";
            timestamp: string | null;
            toolName: string | null;
            toolType: "result" | "call" | null;
        }[]

        The conversation transcript, in order. Each save replaces it.

      • messagesUpdatedAt: string

        Format: date-time

        When the conversation was last saved, as an ISO 8601 timestamp.

      • metadata: { [key: string]: string | string[] } | null

        Tags that describe the conversation, such as mcpEndpoints, app, and environment. Filter on them in GROQ queries. null until a save includes metadata.

      • modelId: string | null

        The ID of the model the agent used. null until a save includes modelId.

      • modelProvider: string | null

        The provider of the model the agent used. null until a save includes modelProvider.

      • organizationId: string

        The ID of the organization that owns the conversation. Filter on it in every query, because the document store also holds documents from other features.

      • schemaVersion: 1

        The version of the document shape. Currently 1.

      • sharing: { contact?: string; conversations?: boolean; metrics?: boolean } | null

        Your choice to share conversation telemetry with Sanity. null until a save includes sharing.

        null
        
      • startedAt: string

        Format: date-time

        When the API received the first save for this thread, as an ISO 8601 timestamp.

      • threadId: string

        Your identifier for the conversation thread, unique within the organization. It is the threadId in the conversations endpoint path and determines the document _id.

      • tokenUsage: { inputTokens?: number; outputTokens?: number; totalTokens?: number } | null

        The running total of token usage for the conversation. null until a save includes tokenUsage.

      • OptionalupdatedAt?: string

        Format: date-time

        When the conversation was last saved, edited or classified through the API, as an ISO 8601 timestamp. Unlike _updatedAt, no other write to the document changes it.

    • EntryDoc: {
          _createdAt: string;
          _id: string;
          _rev: string;
          _type: "sanity.context.entry";
          _updatedAt: string;
          body?: string;
          citations: {
              _key: string;
              _type: "sanity.context.citation";
              chunkId: string;
              claims: string[];
              documentId: string;
              lineEnd: number;
              lineStart: number;
              prefix: string;
              quote: string;
              suffix: string;
              title: string;
              url?: string;
          }[];
          documentIds: string[];
          generatedAt: string;
          knowledgeBaseId: string;
          path: string;
          revisionId: string;
          schemaVersion: number;
          sectionTitles?: string[];
          status: "virtual"
          | "outlined"
          | "filled"
          | "stale"
          | "generation_failed";
          title: string;
          tldr?: { excludes: string; neighbors?: string[]; scope: string };
          topicHeadings?: string[];
          updatedAt?: string;
      }

      A sanity.context.entry document: one entry in a knowledge base outline, stored in your organization's document store. No endpoint returns this document. Use this schema to type GROQ query results.

      • _createdAt: string

        Format: date-time

        When the document was created, as an ISO 8601 timestamp.

      • _id: string

        The document ID.

      • _rev: string

        The document revision. It changes on every write.

      • _type: "sanity.context.entry"

        The document type. Always sanity.context.entry.

      • _updatedAt: string

        Format: date-time

        When the document was last changed, as an ISO 8601 timestamp.

      • Optionalbody?: string

        The entry content in Markdown, with inline [^key] footnote markers. The text after ^ in each marker is the _key of one item in citations. Absent when the entry has no content of its own, such as a virtual entry.

      • citations: {
            _key: string;
            _type: "sanity.context.citation";
            chunkId: string;
            claims: string[];
            documentId: string;
            lineEnd: number;
            lineStart: number;
            prefix: string;
            quote: string;
            suffix: string;
            title: string;
            url?: string;
        }[]

        The passages that back this entry, one item per quoted passage, in the order the body first uses them. A document cited twice with different quotes has two items. Empty when the entry has no body or the body cites nothing.

      • documentIds: string[]

        The IDs of every document the entry was built from, cited or not, sorted. Every citation documentId is in this list.

      • generatedAt: string

        When the build that last wrote this entry's content ran, as an ISO 8601 timestamp.

      • knowledgeBaseId: string

        The ID (kb…) of the knowledge base this document belongs to.

      • path: string

        The entry's slash-delimited path, such as docs/api/webhooks. Order entries by path to get the knowledge base outline.

      • revisionId: string

        The ID of the build that last wrote this entry's content. An unchanged entry keeps its earlier value across builds.

      • schemaVersion: number

        The version of the document shape. Currently 3.

      • OptionalsectionTitles?: string[]

        The titles of the sections above the entry, top level first, one for each path segment before the last. For groq/functions/math it holds the titles of groq and groq/functions. Absent when the entry was written before section titles were recorded.

      • status: "virtual" | "outlined" | "filled" | "stale" | "generation_failed"

        The entry state. Builds currently write only two values: virtual for an entry that groups child entries and has no body, and filled for an entry with a written body. The other values are reserved.

      • title: string

        The entry title.

      • Optionaltldr?: { excludes: string; neighbors?: string[]; scope: string }

        A summary of the entry. scope is what the entry covers, and excludes is what it does not cover. neighbors lists the paths of related entries.

      • OptionaltopicHeadings?: string[]

        The H2 and H3 heading titles in body. Absent when the entry has no body.

      • OptionalupdatedAt?: string

        Format: date-time

        When the entry's content last changed, by a build, a restore or a source being removed. A build that writes the same content leaves it alone, as an ISO 8601 timestamp. Unlike _updatedAt, no other write to the document changes it.

    • InstructionDoc:
          | {
              _createdAt: string;
              _id: string;
              _rev: string;
              _type: "sanity.context.instruction";
              _updatedAt: string;
              archivedAt: string
              | null;
              archivedReason: string | null;
              knowledgeBaseId: string;
              origin: "conflict";
              schemaVersion: 2;
              scopeDocuments:
                  | { _key: string; contentHash: string; documentId: string }[]
                  | null;
              sourceIssueId: string;
              statement: string;
              status: "active" | "archived";
              updatedAt?: string;
          }
          | {
              _createdAt: string;
              _id: string;
              _rev: string;
              _type: "sanity.context.instruction";
              _updatedAt: string;
              archivedAt: string
              | null;
              archivedReason: string | null;
              knowledgeBaseId: string;
              origin: "human";
              schemaVersion: 2;
              scopeDocuments:
                  | { _key: string; contentHash: string; documentId: string }[]
                  | null;
              sourceIssueId: null;
              statement: string;
              status: "active" | "archived";
              updatedAt?: string;
          }

      A sanity.context.instruction document: a standing instruction that steers every build, stored in your organization's document store. No endpoint returns this document. Use this schema to type GROQ query results. To change instructions, use the instructions endpoints.

    • IssueDoc:
          | {
              _createdAt: string;
              _id: string;
              _rev: string;
              _type: "sanity.context.issue";
              _updatedAt: string;
              content: | {
                  claimKey: string;
                  context?: string;
                  issue: string;
                  kind: "conflict";
                  scopePath: string;
                  severity: "critical"
                  | "suggestion";
                  sides: {
                      authority?: "primary" | "secondary" | "community";
                      citations?: {
                          _key: string;
                          _type: "sanity.context.citation";
                          chunkId: string;
                          documentId: string;
                          lineEnd: number;
                          lineStart: number;
                          prefix: string;
                          quote: string;
                          suffix: string;
                          title: string;
                          url?: (...) | (...);
                      }[];
                      claim: string;
                      documentIds?: string[];
                      entryPaths?: string[];
                      value?: string;
                      where?: string;
                  }[];
                  suggested?: number;
                  suggestedFix: string;
              }
              | {
                  citedDocumentIds?: string[];
                  claimKey?: string;
                  involvedScopes?: string[];
                  issue: string;
                  kind: "update_required";
                  scopePath: string;
                  severity: "critical"
                  | "suggestion";
                  suggestedFix: string;
              };
              fingerprint: string;
              knowledgeBaseId: string;
              resolution: null;
              resolvedAt: null;
              resolvedBy: null;
              revisionId: string
              | null;
              schemaVersion: 2;
              status: "open";
              updatedAt?: string;
          }
          | {
              _createdAt: string;
              _id: string;
              _rev: string;
              _type: "sanity.context.issue";
              _updatedAt: string;
              content: | {
                  claimKey: string;
                  context?: string;
                  issue: string;
                  kind: "conflict";
                  scopePath: string;
                  severity: "critical"
                  | "suggestion";
                  sides: {
                      authority?: "primary" | "secondary" | "community";
                      citations?: {
                          _key: string;
                          _type: "sanity.context.citation";
                          chunkId: string;
                          documentId: string;
                          lineEnd: number;
                          lineStart: number;
                          prefix: string;
                          quote: string;
                          suffix: string;
                          title: string;
                          url?: (...) | (...);
                      }[];
                      claim: string;
                      documentIds?: string[];
                      entryPaths?: string[];
                      value?: string;
                      where?: string;
                  }[];
                  suggested?: number;
                  suggestedFix: string;
              }
              | {
                  citedDocumentIds?: string[];
                  claimKey?: string;
                  involvedScopes?: string[];
                  issue: string;
                  kind: "update_required";
                  scopePath: string;
                  severity: "critical"
                  | "suggestion";
                  suggestedFix: string;
              };
              fingerprint: string;
              knowledgeBaseId: string;
              resolution: number
              | null;
              resolvedAt: string;
              resolvedBy: { id: string; kind: "user" | "robot" } | null;
              revisionId: string | null;
              schemaVersion: 2;
              status: "accepted";
              updatedAt?: string;
          }
          | {
              _createdAt: string;
              _id: string;
              _rev: string;
              _type: "sanity.context.issue";
              _updatedAt: string;
              content: | {
                  claimKey: string;
                  context?: string;
                  issue: string;
                  kind: "conflict";
                  scopePath: string;
                  severity: "critical"
                  | "suggestion";
                  sides: {
                      authority?: "primary" | "secondary" | "community";
                      citations?: {
                          _key: string;
                          _type: "sanity.context.citation";
                          chunkId: string;
                          documentId: string;
                          lineEnd: number;
                          lineStart: number;
                          prefix: string;
                          quote: string;
                          suffix: string;
                          title: string;
                          url?: (...) | (...);
                      }[];
                      claim: string;
                      documentIds?: string[];
                      entryPaths?: string[];
                      value?: string;
                      where?: string;
                  }[];
                  suggested?: number;
                  suggestedFix: string;
              }
              | {
                  citedDocumentIds?: string[];
                  claimKey?: string;
                  involvedScopes?: string[];
                  issue: string;
                  kind: "update_required";
                  scopePath: string;
                  severity: "critical"
                  | "suggestion";
                  suggestedFix: string;
              };
              fingerprint: string;
              knowledgeBaseId: string;
              resolution: null;
              resolvedAt: string;
              resolvedBy: { id: string; kind: "user" | "robot" }
              | null;
              revisionId: string | null;
              schemaVersion: 2;
              status: "rejected";
              updatedAt?: string;
          }

      A sanity.context.issue document: a build finding waiting for triage, stored in your organization's document store. No endpoint returns this document. Use this schema to type GROQ query results and Sanity Function filters. To change an issue's status, use the issues endpoints. Only a conflict issue can have a non-null resolution.

    • McpDoc: {
          _createdAt: string;
          _id: string;
          _rev: string;
          _type: "sanity.context.mcp";
          _updatedAt: string;
          groqFilter: string | null;
          instructions: string | null;
          lastUsedAt?: string | null;
          name: string;
          organizationId: string;
          publicId: string;
          schemaVersion: 1;
          sources: (
              | { id: string; type: "knowledge-base" }
              | {
                  id: string;
                  perspective: "published" | "drafts" | "raw" | null;
                  semanticSearch: boolean | null;
                  type: "dataset";
                  workspace: string | null;
              }
          )[];
          title: string;
          updatedAt?: string;
      }

      A sanity.context.mcp document: the configuration of one MCP endpoint, stored in your organization's document store. No endpoint returns this document. Use this schema to type GROQ query results and Sanity Function filters. Manage MCP endpoints in the Context dashboard.

      • _createdAt: string

        Format: date-time

        When the document was created, as an ISO 8601 timestamp.

      • _id: string

        The document ID.

      • _rev: string

        The document revision. It changes on every write.

      • _type: "sanity.context.mcp"

        The document type. Always sanity.context.mcp.

      • _updatedAt: string

        Format: date-time

        When the document was last changed, as an ISO 8601 timestamp.

      • groqFilter: string | null

        A GROQ filter that limits what the MCP endpoint's dataset source serves. It has no effect on knowledge-base sources. null when unset. The API clears it when the endpoint has no dataset source.

      • instructions: string | null

        Prompt text the MCP endpoint serves to connecting agents. null when unset.

      • OptionallastUsedAt?: string | null

        Format: date-time

        When an agent last used the MCP endpoint, as an ISO 8601 timestamp. Recorded at most once per UTC day. null when it has not been used since usage tracking started.

      • name: string

        The MCP endpoint's name in its URL, in lowercase kebab case such as my-endpoint. It is unique within the organization and can't change after creation.

      • organizationId: string

        The ID of the organization that owns the MCP endpoint. Filter on it in every query, because the document store also holds documents from other features.

      • publicId: string

        The MCP endpoint's public ID (mcp…). It is set once at creation, never changes, and determines the document _id.

      • schemaVersion: 1

        The version of the document shape. Currently 1.

      • sources: (
            | { id: string; type: "knowledge-base" }
            | {
                id: string;
                perspective: "published" | "drafts" | "raw" | null;
                semanticSearch: boolean | null;
                type: "dataset";
                workspace: string | null;
            }
        )[]

        The content sources the MCP endpoint serves, all at once. Each source appears once, there is at most one dataset source, and the order has no meaning. With no sources, agents can't connect until one is added.

      • title: string

        The MCP endpoint's display name. You can change it at any time.

      • OptionalupdatedAt?: string

        Format: date-time

        When the MCP endpoint was last created or edited through the API, as an ISO 8601 timestamp. Agent use never changes it, unlike _updatedAt.