UNPKG

@sanity/client

Version:

Client for retrieving, creating and patching data from Sanity.io

13,334 lines • 728 kB
{
  "openapi": "3.0.3",
  "info": {
    "title": "Sanity Context API",
    "description": "Build knowledge bases from your content (file uploads, website crawls, and Sanity datasets), then read, triage, and steer what they produce.",
    "version": "2026-05-26"
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "A Sanity API token or a user token."
      }
    },
    "schemas": {
      "EntryDoc": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "minLength": 1,
            "description": "The document ID."
          },
          "_rev": {
            "type": "string",
            "minLength": 1,
            "description": "The document revision. It changes on every write."
          },
          "_createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
            "description": "When the document was created, as an ISO 8601 timestamp."
          },
          "_updatedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
            "description": "When the document was last changed, as an ISO 8601 timestamp."
          },
          "knowledgeBaseId": {
            "type": "string",
            "minLength": 1,
            "description": "The ID (`kb…`) of the knowledge base this document belongs to."
          },
          "_type": {
            "type": "string",
            "enum": ["sanity.context.entry"],
            "description": "The document type. Always `sanity.context.entry`."
          },
          "schemaVersion": {
            "type": "number",
            "description": "The version of the document shape. Currently `3`."
          },
          "revisionId": {
            "type": "string",
            "description": "The ID of the build that last wrote this entry's content. An unchanged entry keeps its earlier value across builds."
          },
          "path": {
            "type": "string",
            "description": "The entry's slash-delimited path, such as `docs/api/webhooks`. Order entries by `path` to get the knowledge base outline."
          },
          "title": {
            "type": "string",
            "description": "The entry title."
          },
          "sectionTitles": {
            "description": "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.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tldr": {
            "description": "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.",
            "type": "object",
            "properties": {
              "scope": {
                "type": "string"
              },
              "excludes": {
                "type": "string"
              },
              "neighbors": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": ["scope", "excludes"]
          },
          "body": {
            "description": "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.",
            "type": "string"
          },
          "topicHeadings": {
            "description": "The H2 and H3 heading titles in `body`. Absent when the entry has no `body`.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "citations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "_key": {
                  "type": "string",
                  "pattern": "^[a-z2-7]{10}$",
                  "description": "Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a `[^key]` marker."
                },
                "_type": {
                  "type": "string",
                  "enum": ["sanity.context.citation"]
                },
                "documentId": {
                  "type": "string",
                  "description": "ID of the document the quote comes from. Read it with `GET .../documents/{documentId}/content`."
                },
                "chunkId": {
                  "type": "string",
                  "minLength": 1,
                  "description": "ID of the chunk of the document that holds the quote's first line. A chunk is the text under one heading, and keeps its ID across versions of the document while its headings stay the same."
                },
                "title": {
                  "type": "string",
                  "description": "The document's name when the entry was written."
                },
                "url": {
                  "description": "Where the document lives on the web. Absent for uploaded files and datasets.",
                  "type": "string"
                },
                "quote": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 300,
                  "description": "The passage from the document that backs the claims, copied word for word."
                },
                "prefix": {
                  "type": "string",
                  "maxLength": 32,
                  "description": "Up to 32 characters of document text just before the quote, to tell repeats apart."
                },
                "suffix": {
                  "type": "string",
                  "maxLength": 32,
                  "description": "Up to 32 characters of document text just after the quote, to tell repeats apart."
                },
                "lineStart": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991,
                  "description": "First line of the quote in the document, counting from 1. Line numbers match `GET .../documents/{documentId}/content`. A hint: the quote is the stable locator."
                },
                "lineEnd": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991,
                  "description": "Last line of the quote, inclusive."
                },
                "claims": {
                  "minItems": 1,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "minLength": 1
                  },
                  "description": "The statements in the entry body that this passage backs."
                }
              },
              "required": [
                "_key",
                "_type",
                "documentId",
                "chunkId",
                "title",
                "quote",
                "prefix",
                "suffix",
                "lineStart",
                "lineEnd",
                "claims"
              ]
            },
            "description": "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": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The IDs of every document the entry was built from, cited or not, sorted. Every citation `documentId` is in this list."
          },
          "status": {
            "type": "string",
            "enum": ["virtual", "outlined", "filled", "stale", "generation_failed"],
            "description": "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."
          },
          "generatedAt": {
            "type": "string",
            "description": "When the build that last wrote this entry's content ran, as an ISO 8601 timestamp."
          },
          "updatedAt": {
            "description": "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.",
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
          }
        },
        "required": [
          "_id",
          "_rev",
          "_createdAt",
          "_updatedAt",
          "knowledgeBaseId",
          "_type",
          "schemaVersion",
          "revisionId",
          "path",
          "title",
          "citations",
          "documentIds",
          "status",
          "generatedAt"
        ],
        "description": "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."
      },
      "InstructionDoc": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "_id": {
                "type": "string",
                "minLength": 1,
                "description": "The document ID."
              },
              "_rev": {
                "type": "string",
                "minLength": 1,
                "description": "The document revision. It changes on every write."
              },
              "_createdAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was created, as an ISO 8601 timestamp."
              },
              "_updatedAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was last changed, as an ISO 8601 timestamp."
              },
              "knowledgeBaseId": {
                "type": "string",
                "minLength": 1,
                "description": "The ID (`kb…`) of the knowledge base this document belongs to."
              },
              "_type": {
                "type": "string",
                "enum": ["sanity.context.instruction"],
                "description": "The document type. Always `sanity.context.instruction`."
              },
              "schemaVersion": {
                "type": "number",
                "enum": [2],
                "description": "The version of the document shape. Currently `2`. An instruction without the current version doesn't appear in lists and doesn't affect builds."
              },
              "statement": {
                "type": "string",
                "minLength": 1,
                "description": "The instruction, in plain language. Builds follow it over the raw sources."
              },
              "scopeDocuments": {
                "nullable": true,
                "description": "The documents the instruction is tied to. The instruction affects the entries built from these documents. The API always sets at least one document. When `null`, the instruction isn't tied to any document and doesn't affect builds.",
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "_key": {
                      "type": "string",
                      "minLength": 1,
                      "description": "A unique key for this item in the array. It matches `documentId`."
                    },
                    "documentId": {
                      "type": "string",
                      "minLength": 1,
                      "description": "The ID of the document the instruction is tied to."
                    },
                    "contentHash": {
                      "type": "string",
                      "minLength": 1,
                      "description": "The document's content hash when the instruction was last checked against it. When the document's content changes, the instruction is checked again."
                    }
                  },
                  "required": ["_key", "documentId", "contentHash"]
                }
              },
              "status": {
                "type": "string",
                "enum": ["active", "archived"],
                "description": "The instruction state. `active` instructions apply to every build. `archived` instructions don't apply: a document changed and no longer supports the instruction. Editing an archived instruction makes it `active` again."
              },
              "archivedAt": {
                "nullable": true,
                "description": "When the instruction was archived, as an ISO 8601 timestamp. `null` while `active`.",
                "type": "string"
              },
              "archivedReason": {
                "nullable": true,
                "description": "Why the instruction was archived. `null` while `active`.",
                "type": "string"
              },
              "updatedAt": {
                "description": "When the instruction was last created or changed through the API, or archived or re-evaluated by a refresh, as an ISO 8601 timestamp. Unlike `_updatedAt`, no other write to the document changes it.",
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
              },
              "origin": {
                "type": "string",
                "enum": ["conflict"],
                "description": "Where the instruction came from. `conflict` means it was created when you resolved a conflict issue."
              },
              "sourceIssueId": {
                "type": "string",
                "minLength": 1,
                "description": "The `_id` of the conflict issue this instruction resolved. Reopening that issue deletes this instruction."
              }
            },
            "required": [
              "_id",
              "_rev",
              "_createdAt",
              "_updatedAt",
              "knowledgeBaseId",
              "_type",
              "schemaVersion",
              "statement",
              "scopeDocuments",
              "status",
              "archivedAt",
              "archivedReason",
              "origin",
              "sourceIssueId"
            ]
          },
          {
            "type": "object",
            "properties": {
              "_id": {
                "type": "string",
                "minLength": 1,
                "description": "The document ID."
              },
              "_rev": {
                "type": "string",
                "minLength": 1,
                "description": "The document revision. It changes on every write."
              },
              "_createdAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was created, as an ISO 8601 timestamp."
              },
              "_updatedAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was last changed, as an ISO 8601 timestamp."
              },
              "knowledgeBaseId": {
                "type": "string",
                "minLength": 1,
                "description": "The ID (`kb…`) of the knowledge base this document belongs to."
              },
              "_type": {
                "type": "string",
                "enum": ["sanity.context.instruction"],
                "description": "The document type. Always `sanity.context.instruction`."
              },
              "schemaVersion": {
                "type": "number",
                "enum": [2],
                "description": "The version of the document shape. Currently `2`. An instruction without the current version doesn't appear in lists and doesn't affect builds."
              },
              "statement": {
                "type": "string",
                "minLength": 1,
                "description": "The instruction, in plain language. Builds follow it over the raw sources."
              },
              "scopeDocuments": {
                "nullable": true,
                "description": "The documents the instruction is tied to. The instruction affects the entries built from these documents. The API always sets at least one document. When `null`, the instruction isn't tied to any document and doesn't affect builds.",
                "minItems": 1,
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "_key": {
                      "type": "string",
                      "minLength": 1,
                      "description": "A unique key for this item in the array. It matches `documentId`."
                    },
                    "documentId": {
                      "type": "string",
                      "minLength": 1,
                      "description": "The ID of the document the instruction is tied to."
                    },
                    "contentHash": {
                      "type": "string",
                      "minLength": 1,
                      "description": "The document's content hash when the instruction was last checked against it. When the document's content changes, the instruction is checked again."
                    }
                  },
                  "required": ["_key", "documentId", "contentHash"]
                }
              },
              "status": {
                "type": "string",
                "enum": ["active", "archived"],
                "description": "The instruction state. `active` instructions apply to every build. `archived` instructions don't apply: a document changed and no longer supports the instruction. Editing an archived instruction makes it `active` again."
              },
              "archivedAt": {
                "nullable": true,
                "description": "When the instruction was archived, as an ISO 8601 timestamp. `null` while `active`.",
                "type": "string"
              },
              "archivedReason": {
                "nullable": true,
                "description": "Why the instruction was archived. `null` while `active`.",
                "type": "string"
              },
              "updatedAt": {
                "description": "When the instruction was last created or changed through the API, or archived or re-evaluated by a refresh, as an ISO 8601 timestamp. Unlike `_updatedAt`, no other write to the document changes it.",
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
              },
              "origin": {
                "type": "string",
                "enum": ["human"],
                "description": "Where the instruction came from. `human` means it was created directly through the API or the dashboard."
              },
              "sourceIssueId": {
                "type": "string",
                "nullable": true,
                "enum": [null],
                "description": "Always `null` for a `human` instruction."
              }
            },
            "required": [
              "_id",
              "_rev",
              "_createdAt",
              "_updatedAt",
              "knowledgeBaseId",
              "_type",
              "schemaVersion",
              "statement",
              "scopeDocuments",
              "status",
              "archivedAt",
              "archivedReason",
              "origin",
              "sourceIssueId"
            ]
          }
        ],
        "description": "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": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "_id": {
                "type": "string",
                "minLength": 1,
                "description": "The document ID."
              },
              "_rev": {
                "type": "string",
                "minLength": 1,
                "description": "The document revision. It changes on every write."
              },
              "_createdAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was created, as an ISO 8601 timestamp."
              },
              "_updatedAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was last changed, as an ISO 8601 timestamp."
              },
              "knowledgeBaseId": {
                "type": "string",
                "minLength": 1,
                "description": "The ID (`kb…`) of the knowledge base this document belongs to."
              },
              "_type": {
                "type": "string",
                "enum": ["sanity.context.issue"],
                "description": "The document type. Always `sanity.context.issue`."
              },
              "schemaVersion": {
                "type": "number",
                "enum": [2],
                "description": "The version of the document shape. Currently `2`."
              },
              "content": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "severity": {
                        "type": "string",
                        "enum": ["critical", "suggestion"],
                        "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                      },
                      "scopePath": {
                        "type": "string",
                        "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                      },
                      "issue": {
                        "type": "string",
                        "description": "What the problem is, in one or two sentences."
                      },
                      "suggestedFix": {
                        "type": "string",
                        "description": "What to do to fix the issue."
                      },
                      "kind": {
                        "type": "string",
                        "enum": ["conflict"],
                        "description": "The issue type. `conflict` means two or more positions disagree on the same fact, and you choose which one is correct."
                      },
                      "claimKey": {
                        "type": "string",
                        "description": "A key naming the disputed fact, such as `free_tier.request_limit`. It never includes the disputed value, so every side shares it."
                      },
                      "context": {
                        "description": "One sentence that explains the question, when it needs one.",
                        "type": "string"
                      },
                      "sides": {
                        "minItems": 2,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "claim": {
                              "type": "string",
                              "description": "The position as a self-contained sentence. This is the option you choose from."
                            },
                            "value": {
                              "description": "The disputed value on its own, such as `10,000/month`, without the sentence.",
                              "type": "string"
                            },
                            "entryPaths": {
                              "description": "Paths of the entries that state this position.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "documentIds": {
                              "description": "IDs of the documents that directly back this position.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "where": {
                              "description": "The documents that state this value, by the names you know them by.",
                              "type": "string"
                            },
                            "citations": {
                              "description": "Quotes from the documents that state this value, copied word for word and checked against each document. A document whose wording could not be checked has none.",
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "_key": {
                                    "type": "string",
                                    "pattern": "^[a-z2-7]{10}$",
                                    "description": "Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a `[^key]` marker."
                                  },
                                  "_type": {
                                    "type": "string",
                                    "enum": ["sanity.context.citation"]
                                  },
                                  "documentId": {
                                    "type": "string",
                                    "description": "ID of the document the quote comes from. Read it with `GET .../documents/{documentId}/content`."
                                  },
                                  "chunkId": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "ID of the chunk of the document that holds the quote's first line. A chunk is the text under one heading, and keeps its ID across versions of the document while its headings stay the same."
                                  },
                                  "title": {
                                    "type": "string",
                                    "description": "The document's name when the entry was written."
                                  },
                                  "url": {
                                    "description": "Where the document lives on the web. Absent for uploaded files and datasets.",
                                    "type": "string"
                                  },
                                  "quote": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 300,
                                    "description": "The passage from the document that backs the claims, copied word for word."
                                  },
                                  "prefix": {
                                    "type": "string",
                                    "maxLength": 32,
                                    "description": "Up to 32 characters of document text just before the quote, to tell repeats apart."
                                  },
                                  "suffix": {
                                    "type": "string",
                                    "maxLength": 32,
                                    "description": "Up to 32 characters of document text just after the quote, to tell repeats apart."
                                  },
                                  "lineStart": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 9007199254740991,
                                    "description": "First line of the quote in the document, counting from 1. Line numbers match `GET .../documents/{documentId}/content`. A hint: the quote is the stable locator."
                                  },
                                  "lineEnd": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 9007199254740991,
                                    "description": "Last line of the quote, inclusive."
                                  }
                                },
                                "required": [
                                  "_key",
                                  "_type",
                                  "documentId",
                                  "chunkId",
                                  "title",
                                  "quote",
                                  "prefix",
                                  "suffix",
                                  "lineStart",
                                  "lineEnd"
                                ]
                              }
                            },
                            "authority": {
                              "description": "How much weight the sources behind this position carry. `primary`: your own content, such as uploaded files and pages on your own site. `secondary`: other sources. `community`: forums and Q&A sites.",
                              "type": "string",
                              "enum": ["primary", "secondary", "community"]
                            }
                          },
                          "required": ["claim"],
                          "description": "One position in a conflict, and the entries and documents it comes from."
                        },
                        "description": "The conflicting positions, at least two. To resolve the conflict, pass the index of one side as `resolution`."
                      },
                      "suggested": {
                        "description": "Index in `sides` of the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "severity",
                      "scopePath",
                      "issue",
                      "suggestedFix",
                      "kind",
                      "claimKey",
                      "sides"
                    ],
                    "description": "A conflict: two or more positions disagree on the same fact, and you choose which one is correct."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "severity": {
                        "type": "string",
                        "enum": ["critical", "suggestion"],
                        "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                      },
                      "scopePath": {
                        "type": "string",
                        "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                      },
                      "issue": {
                        "type": "string",
                        "description": "What the problem is, in one or two sentences."
                      },
                      "suggestedFix": {
                        "type": "string",
                        "description": "What to do to fix the issue."
                      },
                      "kind": {
                        "type": "string",
                        "enum": ["update_required"],
                        "description": "The issue type. `update_required` means an entry is out of date with its sources or contradicts an instruction, and needs a rewrite."
                      },
                      "citedDocumentIds": {
                        "description": "IDs of the documents that led to the issue.",
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "claimKey": {
                        "description": "A key naming the specific finding, when the check that found it sets one.",
                        "type": "string"
                      },
                      "involvedScopes": {
                        "description": "Paths of the entries the issue involves, when it spans more than one entry.",
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "required": ["severity", "scopePath", "issue", "suggestedFix", "kind"],
                    "description": "An entry that needs a rewrite: it is out of date with its sources or contradicts an instruction."
                  }
                ],
                "description": "What an issue found. The shape depends on `kind`."
              },
              "fingerprint": {
                "type": "string",
                "minLength": 1,
                "description": "An identity for the finding that doesn't depend on its wording. It determines the issue's `_id`, so a reworded finding updates the same issue."
              },
              "revisionId": {
                "nullable": true,
                "description": "The ID of the build that filed this issue. `null` when the issue was filed outside a build, such as when removing a document leaves an entry without documents.",
                "type": "string",
                "minLength": 1
              },
              "updatedAt": {
                "description": "When the issue was last filed, refiled or triaged, as an ISO 8601 timestamp. Unlike `_updatedAt`, no other write to the document changes it.",
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
              },
              "status": {
                "type": "string",
                "enum": ["open"],
                "description": "The issue status. `open` means it is waiting for triage."
              },
              "resolution": {
                "type": "string",
                "nullable": true,
                "enum": [null],
                "description": "Always `null` while the issue is `open`."
              },
              "resolvedAt": {
                "type": "string",
                "nullable": true,
                "enum": [null],
                "description": "Always `null` while the issue is `open`."
              },
              "resolvedBy": {
                "type": "string",
                "nullable": true,
                "enum": [null],
                "description": "Always `null` while the issue is `open`."
              }
            },
            "required": [
              "_id",
              "_rev",
              "_createdAt",
              "_updatedAt",
              "knowledgeBaseId",
              "_type",
              "schemaVersion",
              "content",
              "fingerprint",
              "revisionId",
              "status",
              "resolution",
              "resolvedAt",
              "resolvedBy"
            ]
          },
          {
            "type": "object",
            "properties": {
              "_id": {
                "type": "string",
                "minLength": 1,
                "description": "The document ID."
              },
              "_rev": {
                "type": "string",
                "minLength": 1,
                "description": "The document revision. It changes on every write."
              },
              "_createdAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was created, as an ISO 8601 timestamp."
              },
              "_updatedAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was last changed, as an ISO 8601 timestamp."
              },
              "knowledgeBaseId": {
                "type": "string",
                "minLength": 1,
                "description": "The ID (`kb…`) of the knowledge base this document belongs to."
              },
              "_type": {
                "type": "string",
                "enum": ["sanity.context.issue"],
                "description": "The document type. Always `sanity.context.issue`."
              },
              "schemaVersion": {
                "type": "number",
                "enum": [2],
                "description": "The version of the document shape. Currently `2`."
              },
              "content": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "severity": {
                        "type": "string",
                        "enum": ["critical", "suggestion"],
                        "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                      },
                      "scopePath": {
                        "type": "string",
                        "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                      },
                      "issue": {
                        "type": "string",
                        "description": "What the problem is, in one or two sentences."
                      },
                      "suggestedFix": {
                        "type": "string",
                        "description": "What to do to fix the issue."
                      },
                      "kind": {
                        "type": "string",
                        "enum": ["conflict"],
                        "description": "The issue type. `conflict` means two or more positions disagree on the same fact, and you choose which one is correct."
                      },
                      "claimKey": {
                        "type": "string",
                        "description": "A key naming the disputed fact, such as `free_tier.request_limit`. It never includes the disputed value, so every side shares it."
                      },
                      "context": {
                        "description": "One sentence that explains the question, when it needs one.",
                        "type": "string"
                      },
                      "sides": {
                        "minItems": 2,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "claim": {
                              "type": "string",
                              "description": "The position as a self-contained sentence. This is the option you choose from."
                            },
                            "value": {
                              "description": "The disputed value on its own, such as `10,000/month`, without the sentence.",
                              "type": "string"
                            },
                            "entryPaths": {
                              "description": "Paths of the entries that state this position.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "documentIds": {
                              "description": "IDs of the documents that directly back this position.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "where": {
                              "description": "The documents that state this value, by the names you know them by.",
                              "type": "string"
                            },
                            "citations": {
                              "description": "Quotes from the documents that state this value, copied word for word and checked against each document. A document whose wording could not be checked has none.",
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "_key": {
                                    "type": "string",
                                    "pattern": "^[a-z2-7]{10}$",
                                    "description": "Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a `[^key]` marker."
                                  },
                                  "_type": {
                                    "type": "string",
                                    "enum": ["sanity.context.citation"]
                                  },
                                  "documentId": {
                                    "type": "string",
                                    "description": "ID of the document the quote comes from. Read it with `GET .../documents/{documentId}/content`."
                                  },
                                  "chunkId": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "ID of the chunk of the document that holds the quote's first line. A chunk is the text under one heading, and keeps its ID across versions of the document while its headings stay the same."
                                  },
                                  "title": {
                                    "type": "string",
                                    "description": "The document's name when the entry was written."
                                  },
                                  "url": {
                                    "description": "Where the document lives on the web. Absent for uploaded files and datasets.",
                                    "type": "string"
                                  },
                                  "quote": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 300,
                                    "description": "The passage from the document that backs the claims, copied word for word."
                                  },
                                  "prefix": {
                                    "type": "string",
                                    "maxLength": 32,
                                    "description": "Up to 32 characters of document text just before the quote, to tell repeats apart."
                                  },
                                  "suffix": {
                                    "type": "string",
                                    "maxLength": 32,
                                    "description": "Up to 32 characters of document text just after the quote, to tell repeats apart."
                                  },
                                  "lineStart": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 9007199254740991,
                                    "description": "First line of the quote in the document, counting from 1. Line numbers match `GET .../documents/{documentId}/content`. A hint: the quote is the stable locator."
                                  },
                                  "lineEnd": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 9007199254740991,
                                    "description": "Last line of the quote, inclusive."
                                  }
                                },
                                "required": [
                                  "_key",
                                  "_type",
                                  "documentId",
                                  "chunkId",
                                  "title",
                                  "quote",
                                  "prefix",
                                  "suffix",
                                  "lineStart",
                                  "lineEnd"
                                ]
                              }
                            },
                            "authority": {
                              "description": "How much weight the sources behind this position carry. `primary`: your own content, such as uploaded files and pages on your own site. `secondary`: other sources. `community`: forums and Q&A sites.",
                              "type": "string",
                              "enum": ["primary", "secondary", "community"]
                            }
                          },
                          "required": ["claim"],
                          "description": "One position in a conflict, and the entries and documents it comes from."
                        },
                        "description": "The conflicting positions, at least two. To resolve the conflict, pass the index of one side as `resolution`."
                      },
                      "suggested": {
                        "description": "Index in `sides` of the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "severity",
                      "scopePath",
                      "issue",
                      "suggestedFix",
                      "kind",
                      "claimKey",
                      "sides"
                    ],
                    "description": "A conflict: two or more positions disagree on the same fact, and you choose which one is correct."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "severity": {
                        "type": "string",
                        "enum": ["critical", "suggestion"],
                        "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                      },
                      "scopePath": {
                        "type": "string",
                        "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                      },
                      "issue": {
                        "type": "string",
                        "description": "What the problem is, in one or two sentences."
                      },
                      "suggestedFix": {
                        "type": "string",
                        "description": "What to do to fix the issue."
                      },
                      "kind": {
                        "type": "string",
                        "enum": ["update_required"],
                        "description": "The issue type. `update_required` means an entry is out of date with its sources or contradicts an instruction, and needs a rewrite."
                      },
                      "citedDocumentIds": {
                        "description": "IDs of the documents that led to the issue.",
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "claimKey": {
                        "description": "A key naming the specific finding, when the check that found it sets one.",
                        "type": "string"
                      },
                      "involvedScopes": {
                        "description": "Paths of the entries the issue involves, when it spans more than one entry.",
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "required": ["severity", "scopePath", "issue", "suggestedFix", "kind"],
                    "description": "An entry that needs a rewrite: it is out of date with its sources or contradicts an instruction."
                  }
                ],
                "description": "What an issue found. The shape depends on `kind`."
              },
              "fingerprint": {
                "type": "string",
                "minLength": 1,
                "description": "An identity for the finding that doesn't depend on its wording. It determines the issue's `_id`, so a reworded finding updates the same issue."
              },
              "revisionId": {
                "nullable": true,
                "description": "The ID of the build that filed this issue. `null` when the issue was filed outside a build, such as when removing a document leaves an entry without documents.",
                "type": "string",
                "minLength": 1
              },
              "updatedAt": {
                "description": "When the issue was last filed, refiled or triaged, as an ISO 8601 timestamp. Unlike `_updatedAt`, no other write to the document changes it.",
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
              },
              "status": {
                "type": "string",
                "enum": ["accepted"],
                "description": "The issue status. `accepted` means the issue was resolved or its fix applied."
              },
              "resolvedAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the issue left `open`, as an ISO 8601 timestamp."
              },
              "resolvedBy": {
                "nullable": true,
                "description": "Who triaged the issue. `null` while the issue is open, or when the caller could not be identified.",
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The ID of the Sanity user or robot token that triaged the issue."
                  },
                  "kind": {
                    "type": "string",
                    "enum": ["user", "robot"],
                    "description": "What triaged the issue. `user` is a person, and `robot` is a robot token."
                  }
                },
                "required": ["id", "kind"]
              },
              "resolution": {
                "nullable": true,
                "description": "The index of the chosen side in `content.sides`. For a conflict on one entry, index `0` is the entry's own position. `null` when the fix was applied without choosing a side.",
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "_id",
              "_rev",
              "_createdAt",
              "_updatedAt",
              "knowledgeBaseId",
              "_type",
              "schemaVersion",
              "content",
              "fingerprint",
              "revisionId",
              "status",
              "resolvedAt",
              "resolvedBy",
              "resolution"
            ]
          },
          {
            "type": "object",
            "properties": {
              "_id": {
                "type": "string",
                "minLength": 1,
                "description": "The document ID."
              },
              "_rev": {
                "type": "string",
                "minLength": 1,
                "description": "The document revision. It changes on every write."
              },
              "_createdAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was created, as an ISO 8601 timestamp."
              },
              "_updatedAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the document was last changed, as an ISO 8601 timestamp."
              },
              "knowledgeBaseId": {
                "type": "string",
                "minLength": 1,
                "description": "The ID (`kb…`) of the knowledge base this document belongs to."
              },
              "_type": {
                "type": "string",
                "enum": ["sanity.context.issue"],
                "description": "The document type. Always `sanity.context.issue`."
              },
              "schemaVersion": {
                "type": "number",
                "enum": [2],
                "description": "The version of the document shape. Currently `2`."
              },
              "content": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "severity": {
                        "type": "string",
                        "enum": ["critical", "suggestion"],
                        "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                      },
                      "scopePath": {
                        "type": "string",
                        "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                      },
                      "issue": {
                        "type": "string",
                        "description": "What the problem is, in one or two sentences."
                      },
                      "suggestedFix": {
                        "type": "string",
                        "description": "What to do to fix the issue."
                      },
                      "kind": {
                        "type": "string",
                        "enum": ["conflict"],
                        "description": "The issue type. `conflict` means two or more positions disagree on the same fact, and you choose which one is correct."
                      },
                      "claimKey": {
                        "type": "string",
                        "description": "A key naming the disputed fact, such as `free_tier.request_limit`. It never includes the disputed value, so every side shares it."
                      },
                      "context": {
                        "description": "One sentence that explains the question, when it needs one.",
                        "type": "string"
                      },
                      "sides": {
                        "minItems": 2,
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "claim": {
                              "type": "string",
                              "description": "The position as a self-contained sentence. This is the option you choose from."
                            },
                            "value": {
                              "description": "The disputed value on its own, such as `10,000/month`, without the sentence.",
                              "type": "string"
                            },
                            "entryPaths": {
                              "description": "Paths of the entries that state this position.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "documentIds": {
                              "description": "IDs of the documents that directly back this position.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "where": {
                              "description": "The documents that state this value, by the names you know them by.",
                              "type": "string"
                            },
                            "citations": {
                              "description": "Quotes from the documents that state this value, copied word for word and checked against each document. A document whose wording could not be checked has none.",
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "_key": {
                                    "type": "string",
                                    "pattern": "^[a-z2-7]{10}$",
                                    "description": "Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a `[^key]` marker."
                                  },
                                  "_type": {
                                    "type": "string",
                                    "enum": ["sanity.context.citation"]
                                  },
                                  "documentId": {
                                    "type": "string",
                                    "description": "ID of the document the quote comes from. Read it with `GET .../documents/{documentId}/content`."
                                  },
                                  "chunkId": {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "ID of the chunk of the document that holds the quote's first line. A chunk is the text under one heading, and keeps its ID across versions of the document while its headings stay the same."
                                  },
                                  "title": {
                                    "type": "string",
                                    "description": "The document's name when the entry was written."
                                  },
                                  "url": {
                                    "description": "Where the document lives on the web. Absent for uploaded files and datasets.",
                                    "type": "string"
                                  },
                                  "quote": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 300,
                                    "description": "The passage from the document that backs the claims, copied word for word."
                                  },
                                  "prefix": {
                                    "type": "string",
                                    "maxLength": 32,
                                    "description": "Up to 32 characters of document text just before the quote, to tell repeats apart."
                                  },
                                  "suffix": {
                                    "type": "string",
                                    "maxLength": 32,
                                    "description": "Up to 32 characters of document text just after the quote, to tell repeats apart."
                                  },
                                  "lineStart": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 9007199254740991,
                                    "description": "First line of the quote in the document, counting from 1. Line numbers match `GET .../documents/{documentId}/content`. A hint: the quote is the stable locator."
                                  },
                                  "lineEnd": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 9007199254740991,
                                    "description": "Last line of the quote, inclusive."
                                  }
                                },
                                "required": [
                                  "_key",
                                  "_type",
                                  "documentId",
                                  "chunkId",
                                  "title",
                                  "quote",
                                  "prefix",
                                  "suffix",
                                  "lineStart",
                                  "lineEnd"
                                ]
                              }
                            },
                            "authority": {
                              "description": "How much weight the sources behind this position carry. `primary`: your own content, such as uploaded files and pages on your own site. `secondary`: other sources. `community`: forums and Q&A sites.",
                              "type": "string",
                              "enum": ["primary", "secondary", "community"]
                            }
                          },
                          "required": ["claim"],
                          "description": "One position in a conflict, and the entries and documents it comes from."
                        },
                        "description": "The conflicting positions, at least two. To resolve the conflict, pass the index of one side as `resolution`."
                      },
                      "suggested": {
                        "description": "Index in `sides` of the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.",
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      }
                    },
                    "required": [
                      "severity",
                      "scopePath",
                      "issue",
                      "suggestedFix",
                      "kind",
                      "claimKey",
                      "sides"
                    ],
                    "description": "A conflict: two or more positions disagree on the same fact, and you choose which one is correct."
                  },
                  {
                    "type": "object",
                    "properties": {
                      "severity": {
                        "type": "string",
                        "enum": ["critical", "suggestion"],
                        "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                      },
                      "scopePath": {
                        "type": "string",
                        "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                      },
                      "issue": {
                        "type": "string",
                        "description": "What the problem is, in one or two sentences."
                      },
                      "suggestedFix": {
                        "type": "string",
                        "description": "What to do to fix the issue."
                      },
                      "kind": {
                        "type": "string",
                        "enum": ["update_required"],
                        "description": "The issue type. `update_required` means an entry is out of date with its sources or contradicts an instruction, and needs a rewrite."
                      },
                      "citedDocumentIds": {
                        "description": "IDs of the documents that led to the issue.",
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "claimKey": {
                        "description": "A key naming the specific finding, when the check that found it sets one.",
                        "type": "string"
                      },
                      "involvedScopes": {
                        "description": "Paths of the entries the issue involves, when it spans more than one entry.",
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    },
                    "required": ["severity", "scopePath", "issue", "suggestedFix", "kind"],
                    "description": "An entry that needs a rewrite: it is out of date with its sources or contradicts an instruction."
                  }
                ],
                "description": "What an issue found. The shape depends on `kind`."
              },
              "fingerprint": {
                "type": "string",
                "minLength": 1,
                "description": "An identity for the finding that doesn't depend on its wording. It determines the issue's `_id`, so a reworded finding updates the same issue."
              },
              "revisionId": {
                "nullable": true,
                "description": "The ID of the build that filed this issue. `null` when the issue was filed outside a build, such as when removing a document leaves an entry without documents.",
                "type": "string",
                "minLength": 1
              },
              "updatedAt": {
                "description": "When the issue was last filed, refiled or triaged, as an ISO 8601 timestamp. Unlike `_updatedAt`, no other write to the document changes it.",
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
              },
              "status": {
                "type": "string",
                "enum": ["rejected"],
                "description": "The issue status. `rejected` means the issue was dismissed. Dismissal is final."
              },
              "resolvedAt": {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                "description": "When the issue left `open`, as an ISO 8601 timestamp."
              },
              "resolvedBy": {
                "nullable": true,
                "description": "Who triaged the issue. `null` while the issue is open, or when the caller could not be identified.",
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The ID of the Sanity user or robot token that triaged the issue."
                  },
                  "kind": {
                    "type": "string",
                    "enum": ["user", "robot"],
                    "description": "What triaged the issue. `user` is a person, and `robot` is a robot token."
                  }
                },
                "required": ["id", "kind"]
              },
              "resolution": {
                "type": "string",
                "nullable": true,
                "enum": [null],
                "description": "Always `null`, because a dismissal chooses no side."
              }
            },
            "required": [
              "_id",
              "_rev",
              "_createdAt",
              "_updatedAt",
              "knowledgeBaseId",
              "_type",
              "schemaVersion",
              "content",
              "fingerprint",
              "revisionId",
              "status",
              "resolvedAt",
              "resolvedBy",
              "resolution"
            ]
          }
        ],
        "description": "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`."
      },
      "ConversationDoc": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "minLength": 1,
            "description": "The document ID."
          },
          "_rev": {
            "type": "string",
            "minLength": 1,
            "description": "The document revision. It changes on every write."
          },
          "_createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
            "description": "When the document was created, as an ISO 8601 timestamp."
          },
          "_updatedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
            "description": "When the document was last changed, as an ISO 8601 timestamp."
          },
          "_type": {
            "type": "string",
            "enum": ["sanity.context.conversation"],
            "description": "The document type. Always `sanity.context.conversation`."
          },
          "schemaVersion": {
            "type": "number",
            "enum": [1],
            "description": "The version of the document shape. Currently `1`."
          },
          "organizationId": {
            "type": "string",
            "minLength": 1,
            "description": "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."
          },
          "threadId": {
            "type": "string",
            "minLength": 1,
            "description": "Your identifier for the conversation thread, unique within the organization. It is the `threadId` in the conversations endpoint path and determines the document `_id`."
          },
          "metadata": {
            "nullable": true,
            "description": "Tags that describe the conversation, such as `mcpEndpoints`, `app`, and `environment`. Filter on them in GROQ queries. `null` until a save includes `metadata`.",
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 256
                },
                {
                  "maxItems": 20,
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 256
                  }
                }
              ]
            }
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
            "description": "When the API received the first save for this thread, as an ISO 8601 timestamp."
          },
          "messagesUpdatedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
            "description": "When the conversation was last saved, as an ISO 8601 timestamp."
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "enum": ["user", "assistant", "system", "tool"],
                  "description": "Who sent the message. `user` is the person talking to the agent, `assistant` is the agent, `system` is a system prompt, and `tool` is a tool call or tool result."
                },
                "content": {
                  "default": null,
                  "description": "The message text. `null` when the message has no text, such as a tool call.",
                  "nullable": true,
                  "type": "string",
                  "maxLength": 20000
                },
                "toolName": {
                  "default": null,
                  "description": "The name of the tool for a `tool` message. `null` on other messages.",
                  "nullable": true,
                  "type": "string"
                },
                "toolType": {
                  "default": null,
                  "description": "The kind of `tool` message. `call` is the agent calling the tool, and `result` is what the tool returned. `null` on other messages.",
                  "nullable": true,
                  "type": "string",
                  "enum": ["call", "result", null]
                },
                "error": {
                  "default": null,
                  "description": "Why this step failed, including any stack trace. Set it on the tool result for a failed tool call, or on the assistant message for a turn that failed instead of answering. `null` when the step succeeded.",
                  "nullable": true,
                  "type": "string",
                  "maxLength": 20000
                },
                "timestamp": {
                  "default": null,
                  "description": "When the API first received this message, as an ISO 8601 timestamp. The API sets it. Resending an unchanged message at the same position keeps its timestamp. `null` for messages recorded before timestamps existed.",
                  "nullable": true,
                  "type": "string",
                  "format": "date-time",
                  "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                }
              },
              "required": ["role", "content", "toolName", "toolType", "error", "timestamp"],
              "description": "One message in a conversation transcript, with the time the API received it."
            },
            "description": "The conversation transcript, in order. Each save replaces it."
          },
          "modelProvider": {
            "nullable": true,
            "description": "The provider of the model the agent used. `null` until a save includes `modelProvider`.",
            "type": "string"
          },
          "modelId": {
            "nullable": true,
            "description": "The ID of the model the agent used. `null` until a save includes `modelId`.",
            "type": "string"
          },
          "tokenUsage": {
            "nullable": true,
            "description": "The running total of token usage for the conversation. `null` until a save includes `tokenUsage`.",
            "type": "object",
            "properties": {
              "inputTokens": {
                "description": "The number of input tokens.",
                "type": "number"
              },
              "outputTokens": {
                "description": "The number of output tokens.",
                "type": "number"
              },
              "totalTokens": {
                "description": "The total number of tokens.",
                "type": "number"
              }
            }
          },
          "coreMetrics": {
            "nullable": true,
            "description": "The latest classification result. `null` until you record one.",
            "type": "object",
            "properties": {
              "successScore": {
                "description": "How well the agent resolved the user's needs, from 1 to 10.",
                "type": "number"
              },
              "sentiment": {
                "description": "The overall sentiment of the conversation.",
                "type": "string",
                "enum": ["positive", "neutral", "negative"]
              },
              "contentGaps": {
                "description": "Topics the agent couldn't answer because it lacked content.",
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "classifiedAt": {
            "nullable": true,
            "description": "When the latest classification result was recorded, as an ISO 8601 timestamp. The API sets it. `null` until you record a result.",
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
          },
          "classificationError": {
            "nullable": true,
            "description": "Why your classifier couldn't classify the conversation. `null` when no failure is recorded. Recording a result clears it.",
            "type": "string"
          },
          "sharing": {
            "default": null,
            "description": "Your choice to share conversation telemetry with Sanity. `null` until a save includes `sharing`.",
            "nullable": true,
            "type": "object",
            "properties": {
              "metrics": {
                "description": "Whether to share classification metrics with Sanity: scores, sentiment, content gap counts, message counts and sizes, tool names, and model and token usage. Message content is not included.",
                "type": "boolean"
              },
              "conversations": {
                "description": "Whether to share full conversation transcripts with Sanity. When `true`, the API also sets `metrics` to `true`.",
                "type": "boolean"
              },
              "contact": {
                "description": "How the Sanity team can reach you about your agent, such as an email address or a Discord handle.",
                "type": "string",
                "maxLength": 200
              }
            }
          },
          "updatedAt": {
            "description": "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.",
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
          }
        },
        "required": [
          "_id",
          "_rev",
          "_createdAt",
          "_updatedAt",
          "_type",
          "schemaVersion",
          "organizationId",
          "threadId",
          "metadata",
          "startedAt",
          "messagesUpdatedAt",
          "messages",
          "modelProvider",
          "modelId",
          "tokenUsage",
          "coreMetrics",
          "classifiedAt",
          "classificationError",
          "sharing"
        ],
        "description": "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."
      },
      "McpDoc": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "minLength": 1,
            "description": "The document ID."
          },
          "_rev": {
            "type": "string",
            "minLength": 1,
            "description": "The document revision. It changes on every write."
          },
          "_createdAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
            "description": "When the document was created, as an ISO 8601 timestamp."
          },
          "_updatedAt": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
            "description": "When the document was last changed, as an ISO 8601 timestamp."
          },
          "_type": {
            "type": "string",
            "enum": ["sanity.context.mcp"],
            "description": "The document type. Always `sanity.context.mcp`."
          },
          "schemaVersion": {
            "type": "number",
            "enum": [1],
            "description": "The version of the document shape. Currently `1`."
          },
          "organizationId": {
            "type": "string",
            "minLength": 1,
            "description": "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": {
            "type": "string",
            "minLength": 1,
            "description": "The MCP endpoint's public ID (`mcp…`). It is set once at creation, never changes, and determines the document `_id`."
          },
          "title": {
            "type": "string",
            "minLength": 1,
            "description": "The MCP endpoint's display name. You can change it at any time."
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "description": "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."
          },
          "sources": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": ["knowledge-base"],
                      "description": "The source type. `knowledge-base` serves a whole knowledge base."
                    },
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "description": "The knowledge base ID (`kb…`)."
                    }
                  },
                  "required": ["type", "id"]
                },
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": ["dataset"],
                      "description": "The source type. `dataset` serves documents from a Sanity dataset, limited by the MCP endpoint's `groqFilter` when set."
                    },
                    "id": {
                      "type": "string",
                      "pattern": "^[a-z0-9]+\\.[a-z0-9][a-z0-9_-]*$",
                      "description": "The dataset, as `<projectId>.<datasetName>`."
                    },
                    "workspace": {
                      "default": null,
                      "description": "The studio workspace whose schema agents use, by name. `null` uses the studio's first workspace.",
                      "nullable": true,
                      "type": "string",
                      "minLength": 1
                    },
                    "perspective": {
                      "default": null,
                      "description": "The perspective agents query the dataset with: `published`, `drafts`, or `raw`. `null` uses `published`.",
                      "nullable": true,
                      "type": "string",
                      "enum": ["published", "drafts", "raw", null]
                    },
                    "semanticSearch": {
                      "default": null,
                      "description": "Whether agents can use semantic search on the dataset. `false` turns it off. `true` or `null` use it while the dataset has embeddings enabled and the organization has embeddings usage left.",
                      "nullable": true,
                      "type": "boolean"
                    }
                  },
                  "required": ["type", "id", "workspace", "perspective", "semanticSearch"]
                }
              ],
              "description": "A content source that an MCP endpoint serves: a knowledge base or a Sanity dataset."
            },
            "description": "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."
          },
          "instructions": {
            "nullable": true,
            "description": "Prompt text the MCP endpoint serves to connecting agents. `null` when unset.",
            "type": "string"
          },
          "groqFilter": {
            "nullable": true,
            "description": "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.",
            "type": "string"
          },
          "updatedAt": {
            "description": "When the MCP endpoint was last created or edited through the API, as an ISO 8601 timestamp. Agent use never changes it, unlike `_updatedAt`.",
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
          },
          "lastUsedAt": {
            "description": "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.",
            "nullable": true,
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
          }
        },
        "required": [
          "_id",
          "_rev",
          "_createdAt",
          "_updatedAt",
          "_type",
          "schemaVersion",
          "organizationId",
          "publicId",
          "title",
          "name",
          "sources",
          "instructions",
          "groqFilter"
        ],
        "description": "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."
      },
      "ApiErrorBody": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "enum": [
              "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"
            ]
          },
          "message": {
            "type": "string"
          },
          "fields": {
            "type": "object",
            "additionalProperties": {}
          }
        },
        "required": ["statusCode", "error", "code", "message"],
        "description": "The body of every error response. Branch on `code`, a stable identifier; `message` is human-readable and can change."
      }
    }
  },
  "paths": {
    "/{apiVersion}/context/knowledge-bases": {
      "get": {
        "operationId": "listKnowledgeBases",
        "summary": "List knowledge bases",
        "tags": ["knowledge-bases"],
        "description": "Returns the knowledge bases you can access in the organization set by `organizationId`. Drafts are left out unless you set `includeDrafts` to `true`. Results are cursor-paginated, newest first.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "The `nextCursor` value from the previous page. Omit it to get the first page."
          },
          {
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "The maximum number of items to return."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "query",
            "name": "organizationId",
            "required": true,
            "description": "The organization to list knowledge bases for."
          },
          {
            "schema": {
              "type": "string",
              "enum": ["true", "false"]
            },
            "in": "query",
            "name": "includeDrafts",
            "required": false,
            "description": "Set to `true` to also list the organization's drafts, which have `state` set to `draft`. Drafts count toward the plan's knowledge base limit, and `createdBy` says who started each one."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of knowledge bases.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                            "description": "An internal UUID for the knowledge base, still accepted wherever a `knowledgeBaseId` is expected. Use `publicId` instead."
                          },
                          "publicId": {
                            "type": "string",
                            "description": "The knowledge base's ID, such as `kb3do82whm`. Store this one, and pass it as `knowledgeBaseId` in paths and filters. Treat it as an opaque string."
                          },
                          "organizationId": {
                            "type": "string",
                            "description": "The ID of the organization that owns the knowledge base."
                          },
                          "title": {
                            "type": "string",
                            "description": "The knowledge base's title."
                          },
                          "description": {
                            "type": "string",
                            "description": "A short description of what the knowledge base covers."
                          },
                          "state": {
                            "type": "string",
                            "enum": ["draft", "created", "ready"],
                            "description": "The knowledge base's state. `draft`: still being set up, so it can't be built yet. `created`: not built yet. `ready`: built. Open issues and failed builds don't change the state. To check for open issues, use `openIssueCount`. To check for a running build, use `isBuilding`."
                          },
                          "activeJobId": {
                            "nullable": true,
                            "description": "The job ID of the most recent build, or `null` if no build has started. Check its progress with `GET .../jobs/{jobId}`.",
                            "type": "string"
                          },
                          "isBuilding": {
                            "type": "boolean",
                            "description": "Whether a build is running now."
                          },
                          "buildStageState": {
                            "nullable": true,
                            "description": "Progress of the most recent build, by stage. `null` until a build reports progress. It can briefly belong to an earlier build, so use it only when its `jobId` matches `activeJobId`.",
                            "type": "object",
                            "properties": {
                              "jobId": {
                                "type": "string",
                                "description": "The ID of the build job this progress belongs to."
                              },
                              "stages": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "id": {
                                      "type": "string",
                                      "minLength": 1,
                                      "description": "The stage's ID, such as `tldr` or `write`. Which stages a build runs changes between builds and knowledge bases, so treat it as an open string and handle IDs you don't recognize."
                                    },
                                    "weight": {
                                      "type": "number",
                                      "minimum": 0,
                                      "maximum": 1,
                                      "description": "The stage's share of the whole build, from 0 to 1. The weights of a build's stages sum to 1."
                                    },
                                    "status": {
                                      "type": "string",
                                      "enum": ["pending", "running", "done", "failed"],
                                      "description": "The stage's status. `pending`: not started. `running`: in progress. `done`: finished. `failed`: the build ended before the stage finished."
                                    },
                                    "units": {
                                      "description": "The stage's progress counts. Absent when the stage hasn't reported counts.",
                                      "type": "object",
                                      "properties": {
                                        "unit": {
                                          "type": "string",
                                          "enum": ["sources", "groups", "entries", "rounds"],
                                          "description": "What `done` and `total` count: `sources`, `groups` of related content, `entries`, or `rounds` of final fixes. A `rounds` stage has no `total`."
                                        },
                                        "done": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 9007199254740991,
                                          "description": "How many units the stage has finished."
                                        },
                                        "total": {
                                          "description": "How many units the stage will process. Absent when `unit` is `rounds`.",
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 9007199254740991
                                        }
                                      },
                                      "required": ["unit", "done"]
                                    }
                                  },
                                  "required": ["id", "weight", "status"]
                                },
                                "description": "Every stage this build runs, in the order it runs them, with each stage's progress."
                              }
                            },
                            "required": ["jobId", "stages"]
                          },
                          "lastCheckedAt": {
                            "nullable": true,
                            "description": "When a refresh last checked the knowledge base for changes, whether or not anything changed. `null` until the first refresh.",
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "lastChangedAt": {
                            "nullable": true,
                            "description": "When the content last changed: the time of the most recent successful build. `null` if the knowledge base has never built.",
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "hasPendingChanges": {
                            "type": "boolean",
                            "description": "Whether sources were added, changed, or removed since the last successful build. A change a check already reviewed without filing an issue, or that a dismissed issue covered, no longer counts. Always `false` before the first build."
                          },
                          "pendingChanges": {
                            "nullable": true,
                            "description": "Counts of sources added, changed, and removed since the last successful build, excluding changes a check already reviewed without filing an issue or that a dismissed issue covered. Only `GET .../knowledge-bases/{knowledgeBaseId}` computes it. `null` in list responses and before the first build.",
                            "type": "object",
                            "properties": {
                              "added": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "Sources added since the last successful build, including sources no successful build has included yet."
                              },
                              "changed": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "Sources whose content changed since the last successful build."
                              },
                              "removed": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "Sources that recent refreshes no longer find."
                              }
                            },
                            "required": ["added", "changed", "removed"]
                          },
                          "pipelineOutdated": {
                            "type": "boolean",
                            "description": "Whether Sanity Context has improved how it builds knowledge bases since the last successful build. Rebuild to apply the improvements. Always `false` before the first build."
                          },
                          "rebuildRecommended": {
                            "nullable": true,
                            "description": "A recommendation to rebuild, because new or changed content doesn't fit the current outline, or pages are out of date with changed sources and only a build updates them. `null` when there's no recommendation. A refresh where the content fits again, a successful build, or adding or removing sources clears it.",
                            "type": "object",
                            "properties": {
                              "reason": {
                                "type": "string",
                                "description": "Why a rebuild is recommended, written to show to users."
                              },
                              "at": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                "description": "When the recommendation was made."
                              }
                            },
                            "required": ["reason", "at"]
                          },
                          "hasWebSource": {
                            "type": "boolean",
                            "description": "Whether the knowledge base has at least one website source."
                          },
                          "hasDatasetSource": {
                            "type": "boolean",
                            "description": "Whether the knowledge base has at least one Sanity dataset source."
                          },
                          "hasFileSource": {
                            "type": "boolean",
                            "description": "Whether the knowledge base has at least one uploaded file source."
                          },
                          "sourceChunks": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of source chunks in the live documents of the knowledge base's sources, whether or not they have been built: the sum of its sources' `chunkCount`. It includes the chunks counted by `excludedSourceChunks`, and those of documents whose content another document repeats, which builds skip. Documents still being converted add theirs once converted."
                          },
                          "excludedSourceChunks": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of source chunks in documents the organization's source chunk limit left out of builds. They count toward no limit, and the next build includes them once the limit has room."
                          },
                          "buildRestriction": {
                            "nullable": true,
                            "description": "Why a build request would be denied right now, or `null` if you can build. Only `GET .../knowledge-bases/{knowledgeBaseId}` checks it. List and create responses always return `null`.",
                            "type": "object",
                            "properties": {
                              "code": {
                                "type": "string",
                                "description": "A stable code for the restriction, such as `planLimitReached`."
                              },
                              "message": {
                                "type": "string",
                                "description": "A readable explanation that you can show to users."
                              }
                            },
                            "required": ["code", "message"]
                          },
                          "refreshInFlight": {
                            "type": "boolean",
                            "description": "Whether a refresh is running now. While it's `true`, a new refresh request makes the running one run once more when it ends instead of starting another. Only `GET .../knowledge-bases/{knowledgeBaseId}` computes it, so list responses return `false`."
                          },
                          "openIssueCount": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of open issues waiting for review. Always `0` before the first build."
                          },
                          "instructionCount": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of active instructions for the knowledge base."
                          },
                          "createdBy": {
                            "nullable": true,
                            "description": "Who created the knowledge base. `null` if unknown.",
                            "type": "object",
                            "properties": {
                              "id": {
                                "nullable": true,
                                "description": "The Sanity user ID, or `sanity-system` when Sanity Context made the change. `null` if unknown.",
                                "type": "string"
                              },
                              "displayName": {
                                "nullable": true,
                                "description": "The user's name when the action happened. `null` if unknown. For the current name, look up the user by `id`.",
                                "type": "string"
                              }
                            },
                            "required": ["id", "displayName"]
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                            "description": "When the knowledge base was created."
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                            "description": "When the knowledge base was last updated."
                          }
                        },
                        "required": [
                          "id",
                          "publicId",
                          "organizationId",
                          "title",
                          "description",
                          "state",
                          "activeJobId",
                          "isBuilding",
                          "buildStageState",
                          "lastCheckedAt",
                          "lastChangedAt",
                          "hasPendingChanges",
                          "pendingChanges",
                          "pipelineOutdated",
                          "rebuildRecommended",
                          "hasWebSource",
                          "hasDatasetSource",
                          "hasFileSource",
                          "sourceChunks",
                          "excludedSourceChunks",
                          "buildRestriction",
                          "refreshInFlight",
                          "openIssueCount",
                          "instructionCount",
                          "createdBy",
                          "createdAt",
                          "updatedAt"
                        ],
                        "description": "A knowledge base and its current state."
                      },
                      "description": "The items on this page."
                    },
                    "nextCursor": {
                      "nullable": true,
                      "description": "The cursor for the next page. Pass it as `cursor` to get more results. `null` when there are no more pages.",
                      "type": "string"
                    }
                  },
                  "required": ["data", "nextCursor"],
                  "description": "A page of knowledge bases."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createKnowledgeBase",
        "summary": "Create a knowledge base",
        "tags": ["knowledge-bases"],
        "description": "Creates a knowledge base in your organization. To add content to it, add a source. Set `draft` to `true` to create a draft, which needs no title or description until you finish it. If your organization's Context document store can't be used, the request returns `503` with code `contextStoreUnavailable` and you can retry.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "organizationId": {
                    "type": "string",
                    "minLength": 1,
                    "description": "The ID of the organization to create the knowledge base in."
                  },
                  "title": {
                    "description": "The knowledge base's title. Required unless `draft` is `true`.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "description": "A short description of what the knowledge base covers. Required unless `draft` is `true`.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "draft": {
                    "description": "Whether to create the knowledge base as a draft. You can add sources to a draft, and they sync right away, but you can't build it, and the list leaves it out unless you set `includeDrafts` to `true`. A draft counts toward your plan's knowledge base limit. To finish it, update it with `draft` set to `false`.",
                    "type": "boolean"
                  }
                },
                "required": ["organizationId"]
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "description": "A unique value, such as a UUID, that makes retries safe. A retry with the same key and body returns the first response instead of repeating the work."
          }
        ],
        "responses": {
          "201": {
            "description": "A knowledge base and its current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "An internal UUID for the knowledge base, still accepted wherever a `knowledgeBaseId` is expected. Use `publicId` instead."
                    },
                    "publicId": {
                      "type": "string",
                      "description": "The knowledge base's ID, such as `kb3do82whm`. Store this one, and pass it as `knowledgeBaseId` in paths and filters. Treat it as an opaque string."
                    },
                    "organizationId": {
                      "type": "string",
                      "description": "The ID of the organization that owns the knowledge base."
                    },
                    "title": {
                      "type": "string",
                      "description": "The knowledge base's title."
                    },
                    "description": {
                      "type": "string",
                      "description": "A short description of what the knowledge base covers."
                    },
                    "state": {
                      "type": "string",
                      "enum": ["draft", "created", "ready"],
                      "description": "The knowledge base's state. `draft`: still being set up, so it can't be built yet. `created`: not built yet. `ready`: built. Open issues and failed builds don't change the state. To check for open issues, use `openIssueCount`. To check for a running build, use `isBuilding`."
                    },
                    "activeJobId": {
                      "nullable": true,
                      "description": "The job ID of the most recent build, or `null` if no build has started. Check its progress with `GET .../jobs/{jobId}`.",
                      "type": "string"
                    },
                    "isBuilding": {
                      "type": "boolean",
                      "description": "Whether a build is running now."
                    },
                    "buildStageState": {
                      "nullable": true,
                      "description": "Progress of the most recent build, by stage. `null` until a build reports progress. It can briefly belong to an earlier build, so use it only when its `jobId` matches `activeJobId`.",
                      "type": "object",
                      "properties": {
                        "jobId": {
                          "type": "string",
                          "description": "The ID of the build job this progress belongs to."
                        },
                        "stages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "minLength": 1,
                                "description": "The stage's ID, such as `tldr` or `write`. Which stages a build runs changes between builds and knowledge bases, so treat it as an open string and handle IDs you don't recognize."
                              },
                              "weight": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 1,
                                "description": "The stage's share of the whole build, from 0 to 1. The weights of a build's stages sum to 1."
                              },
                              "status": {
                                "type": "string",
                                "enum": ["pending", "running", "done", "failed"],
                                "description": "The stage's status. `pending`: not started. `running`: in progress. `done`: finished. `failed`: the build ended before the stage finished."
                              },
                              "units": {
                                "description": "The stage's progress counts. Absent when the stage hasn't reported counts.",
                                "type": "object",
                                "properties": {
                                  "unit": {
                                    "type": "string",
                                    "enum": ["sources", "groups", "entries", "rounds"],
                                    "description": "What `done` and `total` count: `sources`, `groups` of related content, `entries`, or `rounds` of final fixes. A `rounds` stage has no `total`."
                                  },
                                  "done": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991,
                                    "description": "How many units the stage has finished."
                                  },
                                  "total": {
                                    "description": "How many units the stage will process. Absent when `unit` is `rounds`.",
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  }
                                },
                                "required": ["unit", "done"]
                              }
                            },
                            "required": ["id", "weight", "status"]
                          },
                          "description": "Every stage this build runs, in the order it runs them, with each stage's progress."
                        }
                      },
                      "required": ["jobId", "stages"]
                    },
                    "lastCheckedAt": {
                      "nullable": true,
                      "description": "When a refresh last checked the knowledge base for changes, whether or not anything changed. `null` until the first refresh.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "lastChangedAt": {
                      "nullable": true,
                      "description": "When the content last changed: the time of the most recent successful build. `null` if the knowledge base has never built.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "hasPendingChanges": {
                      "type": "boolean",
                      "description": "Whether sources were added, changed, or removed since the last successful build. A change a check already reviewed without filing an issue, or that a dismissed issue covered, no longer counts. Always `false` before the first build."
                    },
                    "pendingChanges": {
                      "nullable": true,
                      "description": "Counts of sources added, changed, and removed since the last successful build, excluding changes a check already reviewed without filing an issue or that a dismissed issue covered. Only `GET .../knowledge-bases/{knowledgeBaseId}` computes it. `null` in list responses and before the first build.",
                      "type": "object",
                      "properties": {
                        "added": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources added since the last successful build, including sources no successful build has included yet."
                        },
                        "changed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources whose content changed since the last successful build."
                        },
                        "removed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources that recent refreshes no longer find."
                        }
                      },
                      "required": ["added", "changed", "removed"]
                    },
                    "pipelineOutdated": {
                      "type": "boolean",
                      "description": "Whether Sanity Context has improved how it builds knowledge bases since the last successful build. Rebuild to apply the improvements. Always `false` before the first build."
                    },
                    "rebuildRecommended": {
                      "nullable": true,
                      "description": "A recommendation to rebuild, because new or changed content doesn't fit the current outline, or pages are out of date with changed sources and only a build updates them. `null` when there's no recommendation. A refresh where the content fits again, a successful build, or adding or removing sources clears it.",
                      "type": "object",
                      "properties": {
                        "reason": {
                          "type": "string",
                          "description": "Why a rebuild is recommended, written to show to users."
                        },
                        "at": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the recommendation was made."
                        }
                      },
                      "required": ["reason", "at"]
                    },
                    "hasWebSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one website source."
                    },
                    "hasDatasetSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one Sanity dataset source."
                    },
                    "hasFileSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one uploaded file source."
                    },
                    "sourceChunks": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of source chunks in the live documents of the knowledge base's sources, whether or not they have been built: the sum of its sources' `chunkCount`. It includes the chunks counted by `excludedSourceChunks`, and those of documents whose content another document repeats, which builds skip. Documents still being converted add theirs once converted."
                    },
                    "excludedSourceChunks": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of source chunks in documents the organization's source chunk limit left out of builds. They count toward no limit, and the next build includes them once the limit has room."
                    },
                    "buildRestriction": {
                      "nullable": true,
                      "description": "Why a build request would be denied right now, or `null` if you can build. Only `GET .../knowledge-bases/{knowledgeBaseId}` checks it. List and create responses always return `null`.",
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "description": "A stable code for the restriction, such as `planLimitReached`."
                        },
                        "message": {
                          "type": "string",
                          "description": "A readable explanation that you can show to users."
                        }
                      },
                      "required": ["code", "message"]
                    },
                    "refreshInFlight": {
                      "type": "boolean",
                      "description": "Whether a refresh is running now. While it's `true`, a new refresh request makes the running one run once more when it ends instead of starting another. Only `GET .../knowledge-bases/{knowledgeBaseId}` computes it, so list responses return `false`."
                    },
                    "openIssueCount": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of open issues waiting for review. Always `0` before the first build."
                    },
                    "instructionCount": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of active instructions for the knowledge base."
                    },
                    "createdBy": {
                      "nullable": true,
                      "description": "Who created the knowledge base. `null` if unknown.",
                      "type": "object",
                      "properties": {
                        "id": {
                          "nullable": true,
                          "description": "The Sanity user ID, or `sanity-system` when Sanity Context made the change. `null` if unknown.",
                          "type": "string"
                        },
                        "displayName": {
                          "nullable": true,
                          "description": "The user's name when the action happened. `null` if unknown. For the current name, look up the user by `id`.",
                          "type": "string"
                        }
                      },
                      "required": ["id", "displayName"]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the knowledge base was created."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the knowledge base was last updated."
                    }
                  },
                  "required": [
                    "id",
                    "publicId",
                    "organizationId",
                    "title",
                    "description",
                    "state",
                    "activeJobId",
                    "isBuilding",
                    "buildStageState",
                    "lastCheckedAt",
                    "lastChangedAt",
                    "hasPendingChanges",
                    "pendingChanges",
                    "pipelineOutdated",
                    "rebuildRecommended",
                    "hasWebSource",
                    "hasDatasetSource",
                    "hasFileSource",
                    "sourceChunks",
                    "excludedSourceChunks",
                    "buildRestriction",
                    "refreshInFlight",
                    "openIssueCount",
                    "instructionCount",
                    "createdBy",
                    "createdAt",
                    "updatedAt"
                  ],
                  "description": "A knowledge base and its current state."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}": {
      "get": {
        "operationId": "getKnowledgeBase",
        "summary": "Get a knowledge base",
        "tags": ["knowledge-bases"],
        "description": "Returns a knowledge base's metadata and state. `knowledgeBaseId` accepts the public ID (`kb...`) or the UUID, and you don't need to pass an organization. If you can't read the knowledge base, the request returns `404`. To read the built entries, query `sanity.context.entry` documents with GROQ from your organization's document store.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A knowledge base and its current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "An internal UUID for the knowledge base, still accepted wherever a `knowledgeBaseId` is expected. Use `publicId` instead."
                    },
                    "publicId": {
                      "type": "string",
                      "description": "The knowledge base's ID, such as `kb3do82whm`. Store this one, and pass it as `knowledgeBaseId` in paths and filters. Treat it as an opaque string."
                    },
                    "organizationId": {
                      "type": "string",
                      "description": "The ID of the organization that owns the knowledge base."
                    },
                    "title": {
                      "type": "string",
                      "description": "The knowledge base's title."
                    },
                    "description": {
                      "type": "string",
                      "description": "A short description of what the knowledge base covers."
                    },
                    "state": {
                      "type": "string",
                      "enum": ["draft", "created", "ready"],
                      "description": "The knowledge base's state. `draft`: still being set up, so it can't be built yet. `created`: not built yet. `ready`: built. Open issues and failed builds don't change the state. To check for open issues, use `openIssueCount`. To check for a running build, use `isBuilding`."
                    },
                    "activeJobId": {
                      "nullable": true,
                      "description": "The job ID of the most recent build, or `null` if no build has started. Check its progress with `GET .../jobs/{jobId}`.",
                      "type": "string"
                    },
                    "isBuilding": {
                      "type": "boolean",
                      "description": "Whether a build is running now."
                    },
                    "buildStageState": {
                      "nullable": true,
                      "description": "Progress of the most recent build, by stage. `null` until a build reports progress. It can briefly belong to an earlier build, so use it only when its `jobId` matches `activeJobId`.",
                      "type": "object",
                      "properties": {
                        "jobId": {
                          "type": "string",
                          "description": "The ID of the build job this progress belongs to."
                        },
                        "stages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "minLength": 1,
                                "description": "The stage's ID, such as `tldr` or `write`. Which stages a build runs changes between builds and knowledge bases, so treat it as an open string and handle IDs you don't recognize."
                              },
                              "weight": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 1,
                                "description": "The stage's share of the whole build, from 0 to 1. The weights of a build's stages sum to 1."
                              },
                              "status": {
                                "type": "string",
                                "enum": ["pending", "running", "done", "failed"],
                                "description": "The stage's status. `pending`: not started. `running`: in progress. `done`: finished. `failed`: the build ended before the stage finished."
                              },
                              "units": {
                                "description": "The stage's progress counts. Absent when the stage hasn't reported counts.",
                                "type": "object",
                                "properties": {
                                  "unit": {
                                    "type": "string",
                                    "enum": ["sources", "groups", "entries", "rounds"],
                                    "description": "What `done` and `total` count: `sources`, `groups` of related content, `entries`, or `rounds` of final fixes. A `rounds` stage has no `total`."
                                  },
                                  "done": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991,
                                    "description": "How many units the stage has finished."
                                  },
                                  "total": {
                                    "description": "How many units the stage will process. Absent when `unit` is `rounds`.",
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  }
                                },
                                "required": ["unit", "done"]
                              }
                            },
                            "required": ["id", "weight", "status"]
                          },
                          "description": "Every stage this build runs, in the order it runs them, with each stage's progress."
                        }
                      },
                      "required": ["jobId", "stages"]
                    },
                    "lastCheckedAt": {
                      "nullable": true,
                      "description": "When a refresh last checked the knowledge base for changes, whether or not anything changed. `null` until the first refresh.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "lastChangedAt": {
                      "nullable": true,
                      "description": "When the content last changed: the time of the most recent successful build. `null` if the knowledge base has never built.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "hasPendingChanges": {
                      "type": "boolean",
                      "description": "Whether sources were added, changed, or removed since the last successful build. A change a check already reviewed without filing an issue, or that a dismissed issue covered, no longer counts. Always `false` before the first build."
                    },
                    "pendingChanges": {
                      "nullable": true,
                      "description": "Counts of sources added, changed, and removed since the last successful build, excluding changes a check already reviewed without filing an issue or that a dismissed issue covered. Only `GET .../knowledge-bases/{knowledgeBaseId}` computes it. `null` in list responses and before the first build.",
                      "type": "object",
                      "properties": {
                        "added": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources added since the last successful build, including sources no successful build has included yet."
                        },
                        "changed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources whose content changed since the last successful build."
                        },
                        "removed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources that recent refreshes no longer find."
                        }
                      },
                      "required": ["added", "changed", "removed"]
                    },
                    "pipelineOutdated": {
                      "type": "boolean",
                      "description": "Whether Sanity Context has improved how it builds knowledge bases since the last successful build. Rebuild to apply the improvements. Always `false` before the first build."
                    },
                    "rebuildRecommended": {
                      "nullable": true,
                      "description": "A recommendation to rebuild, because new or changed content doesn't fit the current outline, or pages are out of date with changed sources and only a build updates them. `null` when there's no recommendation. A refresh where the content fits again, a successful build, or adding or removing sources clears it.",
                      "type": "object",
                      "properties": {
                        "reason": {
                          "type": "string",
                          "description": "Why a rebuild is recommended, written to show to users."
                        },
                        "at": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the recommendation was made."
                        }
                      },
                      "required": ["reason", "at"]
                    },
                    "hasWebSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one website source."
                    },
                    "hasDatasetSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one Sanity dataset source."
                    },
                    "hasFileSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one uploaded file source."
                    },
                    "sourceChunks": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of source chunks in the live documents of the knowledge base's sources, whether or not they have been built: the sum of its sources' `chunkCount`. It includes the chunks counted by `excludedSourceChunks`, and those of documents whose content another document repeats, which builds skip. Documents still being converted add theirs once converted."
                    },
                    "excludedSourceChunks": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of source chunks in documents the organization's source chunk limit left out of builds. They count toward no limit, and the next build includes them once the limit has room."
                    },
                    "buildRestriction": {
                      "nullable": true,
                      "description": "Why a build request would be denied right now, or `null` if you can build. Only `GET .../knowledge-bases/{knowledgeBaseId}` checks it. List and create responses always return `null`.",
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "description": "A stable code for the restriction, such as `planLimitReached`."
                        },
                        "message": {
                          "type": "string",
                          "description": "A readable explanation that you can show to users."
                        }
                      },
                      "required": ["code", "message"]
                    },
                    "refreshInFlight": {
                      "type": "boolean",
                      "description": "Whether a refresh is running now. While it's `true`, a new refresh request makes the running one run once more when it ends instead of starting another. Only `GET .../knowledge-bases/{knowledgeBaseId}` computes it, so list responses return `false`."
                    },
                    "openIssueCount": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of open issues waiting for review. Always `0` before the first build."
                    },
                    "instructionCount": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of active instructions for the knowledge base."
                    },
                    "createdBy": {
                      "nullable": true,
                      "description": "Who created the knowledge base. `null` if unknown.",
                      "type": "object",
                      "properties": {
                        "id": {
                          "nullable": true,
                          "description": "The Sanity user ID, or `sanity-system` when Sanity Context made the change. `null` if unknown.",
                          "type": "string"
                        },
                        "displayName": {
                          "nullable": true,
                          "description": "The user's name when the action happened. `null` if unknown. For the current name, look up the user by `id`.",
                          "type": "string"
                        }
                      },
                      "required": ["id", "displayName"]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the knowledge base was created."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the knowledge base was last updated."
                    }
                  },
                  "required": [
                    "id",
                    "publicId",
                    "organizationId",
                    "title",
                    "description",
                    "state",
                    "activeJobId",
                    "isBuilding",
                    "buildStageState",
                    "lastCheckedAt",
                    "lastChangedAt",
                    "hasPendingChanges",
                    "pendingChanges",
                    "pipelineOutdated",
                    "rebuildRecommended",
                    "hasWebSource",
                    "hasDatasetSource",
                    "hasFileSource",
                    "sourceChunks",
                    "excludedSourceChunks",
                    "buildRestriction",
                    "refreshInFlight",
                    "openIssueCount",
                    "instructionCount",
                    "createdBy",
                    "createdAt",
                    "updatedAt"
                  ],
                  "description": "A knowledge base and its current state."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateKnowledgeBase",
        "summary": "Update a knowledge base",
        "tags": ["knowledge-bases"],
        "description": "Updates the title or the description, or finishes a draft (`draft: false`). Fields equal to their current value are ignored, so sending the current values changes nothing. Finishing a draft with no title returns `422` with code `draftTitleRequired`. How often a website or dataset syncs is set on the source, with `PATCH .../sources/{sourceId}`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "description": "The knowledge base's new title.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "description": {
                    "description": "The knowledge base's new description.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "draft": {
                    "description": "Set to `false` to finish a draft, so it can be built and is listed with your other knowledge bases. The knowledge base needs a title, sent here or set before. Ignored when the knowledge base isn't a draft. A finished knowledge base can't become a draft again.",
                    "type": "boolean",
                    "enum": [false]
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A knowledge base and its current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "An internal UUID for the knowledge base, still accepted wherever a `knowledgeBaseId` is expected. Use `publicId` instead."
                    },
                    "publicId": {
                      "type": "string",
                      "description": "The knowledge base's ID, such as `kb3do82whm`. Store this one, and pass it as `knowledgeBaseId` in paths and filters. Treat it as an opaque string."
                    },
                    "organizationId": {
                      "type": "string",
                      "description": "The ID of the organization that owns the knowledge base."
                    },
                    "title": {
                      "type": "string",
                      "description": "The knowledge base's title."
                    },
                    "description": {
                      "type": "string",
                      "description": "A short description of what the knowledge base covers."
                    },
                    "state": {
                      "type": "string",
                      "enum": ["draft", "created", "ready"],
                      "description": "The knowledge base's state. `draft`: still being set up, so it can't be built yet. `created`: not built yet. `ready`: built. Open issues and failed builds don't change the state. To check for open issues, use `openIssueCount`. To check for a running build, use `isBuilding`."
                    },
                    "activeJobId": {
                      "nullable": true,
                      "description": "The job ID of the most recent build, or `null` if no build has started. Check its progress with `GET .../jobs/{jobId}`.",
                      "type": "string"
                    },
                    "isBuilding": {
                      "type": "boolean",
                      "description": "Whether a build is running now."
                    },
                    "buildStageState": {
                      "nullable": true,
                      "description": "Progress of the most recent build, by stage. `null` until a build reports progress. It can briefly belong to an earlier build, so use it only when its `jobId` matches `activeJobId`.",
                      "type": "object",
                      "properties": {
                        "jobId": {
                          "type": "string",
                          "description": "The ID of the build job this progress belongs to."
                        },
                        "stages": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "minLength": 1,
                                "description": "The stage's ID, such as `tldr` or `write`. Which stages a build runs changes between builds and knowledge bases, so treat it as an open string and handle IDs you don't recognize."
                              },
                              "weight": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 1,
                                "description": "The stage's share of the whole build, from 0 to 1. The weights of a build's stages sum to 1."
                              },
                              "status": {
                                "type": "string",
                                "enum": ["pending", "running", "done", "failed"],
                                "description": "The stage's status. `pending`: not started. `running`: in progress. `done`: finished. `failed`: the build ended before the stage finished."
                              },
                              "units": {
                                "description": "The stage's progress counts. Absent when the stage hasn't reported counts.",
                                "type": "object",
                                "properties": {
                                  "unit": {
                                    "type": "string",
                                    "enum": ["sources", "groups", "entries", "rounds"],
                                    "description": "What `done` and `total` count: `sources`, `groups` of related content, `entries`, or `rounds` of final fixes. A `rounds` stage has no `total`."
                                  },
                                  "done": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991,
                                    "description": "How many units the stage has finished."
                                  },
                                  "total": {
                                    "description": "How many units the stage will process. Absent when `unit` is `rounds`.",
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 9007199254740991
                                  }
                                },
                                "required": ["unit", "done"]
                              }
                            },
                            "required": ["id", "weight", "status"]
                          },
                          "description": "Every stage this build runs, in the order it runs them, with each stage's progress."
                        }
                      },
                      "required": ["jobId", "stages"]
                    },
                    "lastCheckedAt": {
                      "nullable": true,
                      "description": "When a refresh last checked the knowledge base for changes, whether or not anything changed. `null` until the first refresh.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "lastChangedAt": {
                      "nullable": true,
                      "description": "When the content last changed: the time of the most recent successful build. `null` if the knowledge base has never built.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "hasPendingChanges": {
                      "type": "boolean",
                      "description": "Whether sources were added, changed, or removed since the last successful build. A change a check already reviewed without filing an issue, or that a dismissed issue covered, no longer counts. Always `false` before the first build."
                    },
                    "pendingChanges": {
                      "nullable": true,
                      "description": "Counts of sources added, changed, and removed since the last successful build, excluding changes a check already reviewed without filing an issue or that a dismissed issue covered. Only `GET .../knowledge-bases/{knowledgeBaseId}` computes it. `null` in list responses and before the first build.",
                      "type": "object",
                      "properties": {
                        "added": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources added since the last successful build, including sources no successful build has included yet."
                        },
                        "changed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources whose content changed since the last successful build."
                        },
                        "removed": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "Sources that recent refreshes no longer find."
                        }
                      },
                      "required": ["added", "changed", "removed"]
                    },
                    "pipelineOutdated": {
                      "type": "boolean",
                      "description": "Whether Sanity Context has improved how it builds knowledge bases since the last successful build. Rebuild to apply the improvements. Always `false` before the first build."
                    },
                    "rebuildRecommended": {
                      "nullable": true,
                      "description": "A recommendation to rebuild, because new or changed content doesn't fit the current outline, or pages are out of date with changed sources and only a build updates them. `null` when there's no recommendation. A refresh where the content fits again, a successful build, or adding or removing sources clears it.",
                      "type": "object",
                      "properties": {
                        "reason": {
                          "type": "string",
                          "description": "Why a rebuild is recommended, written to show to users."
                        },
                        "at": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the recommendation was made."
                        }
                      },
                      "required": ["reason", "at"]
                    },
                    "hasWebSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one website source."
                    },
                    "hasDatasetSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one Sanity dataset source."
                    },
                    "hasFileSource": {
                      "type": "boolean",
                      "description": "Whether the knowledge base has at least one uploaded file source."
                    },
                    "sourceChunks": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of source chunks in the live documents of the knowledge base's sources, whether or not they have been built: the sum of its sources' `chunkCount`. It includes the chunks counted by `excludedSourceChunks`, and those of documents whose content another document repeats, which builds skip. Documents still being converted add theirs once converted."
                    },
                    "excludedSourceChunks": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of source chunks in documents the organization's source chunk limit left out of builds. They count toward no limit, and the next build includes them once the limit has room."
                    },
                    "buildRestriction": {
                      "nullable": true,
                      "description": "Why a build request would be denied right now, or `null` if you can build. Only `GET .../knowledge-bases/{knowledgeBaseId}` checks it. List and create responses always return `null`.",
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "description": "A stable code for the restriction, such as `planLimitReached`."
                        },
                        "message": {
                          "type": "string",
                          "description": "A readable explanation that you can show to users."
                        }
                      },
                      "required": ["code", "message"]
                    },
                    "refreshInFlight": {
                      "type": "boolean",
                      "description": "Whether a refresh is running now. While it's `true`, a new refresh request makes the running one run once more when it ends instead of starting another. Only `GET .../knowledge-bases/{knowledgeBaseId}` computes it, so list responses return `false`."
                    },
                    "openIssueCount": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of open issues waiting for review. Always `0` before the first build."
                    },
                    "instructionCount": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of active instructions for the knowledge base."
                    },
                    "createdBy": {
                      "nullable": true,
                      "description": "Who created the knowledge base. `null` if unknown.",
                      "type": "object",
                      "properties": {
                        "id": {
                          "nullable": true,
                          "description": "The Sanity user ID, or `sanity-system` when Sanity Context made the change. `null` if unknown.",
                          "type": "string"
                        },
                        "displayName": {
                          "nullable": true,
                          "description": "The user's name when the action happened. `null` if unknown. For the current name, look up the user by `id`.",
                          "type": "string"
                        }
                      },
                      "required": ["id", "displayName"]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the knowledge base was created."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the knowledge base was last updated."
                    }
                  },
                  "required": [
                    "id",
                    "publicId",
                    "organizationId",
                    "title",
                    "description",
                    "state",
                    "activeJobId",
                    "isBuilding",
                    "buildStageState",
                    "lastCheckedAt",
                    "lastChangedAt",
                    "hasPendingChanges",
                    "pendingChanges",
                    "pipelineOutdated",
                    "rebuildRecommended",
                    "hasWebSource",
                    "hasDatasetSource",
                    "hasFileSource",
                    "sourceChunks",
                    "excludedSourceChunks",
                    "buildRestriction",
                    "refreshInFlight",
                    "openIssueCount",
                    "instructionCount",
                    "createdBy",
                    "createdAt",
                    "updatedAt"
                  ],
                  "description": "A knowledge base and its current state."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteKnowledgeBase",
        "summary": "Delete a knowledge base",
        "tags": ["knowledge-bases"],
        "description": "Deletes the knowledge base and everything it owns: its sources, revisions, stored source files, and its documents in your organization's document store. While a build, refresh, apply, or sync is running, the request returns `409` with code `buildInFlight`. Retry after that work finishes.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "204": {
            "description": "The knowledge base was deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "nullable": true,
                  "enum": [null],
                  "description": "The knowledge base was deleted."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/build": {
      "post": {
        "operationId": "buildKnowledgeBase",
        "summary": "Start a knowledge base build",
        "tags": ["knowledge-bases"],
        "description": "Queues a build over the knowledge base's current sources and returns a job ID immediately. If a build is already running, the response returns that build's job ID instead of starting a second build. A draft can't be built: the request returns `409` with code `knowledgeBaseIsDraft`.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "description": "A unique value, such as a UUID, that makes retries safe. A retry with the same key and body returns the first response instead of repeating the work."
          }
        ],
        "responses": {
          "202": {
            "description": "A queued job that you can poll for progress.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jobId": {
                      "type": "string",
                      "description": "The queued job's ID. Check its progress with `GET .../jobs/{jobId}`. Treat it as an opaque string. Its format can change."
                    }
                  },
                  "required": ["jobId"],
                  "description": "A queued job that you can poll for progress."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/build/cancel": {
      "post": {
        "operationId": "cancelKnowledgeBaseBuild",
        "summary": "Cancel a knowledge base build",
        "tags": ["knowledge-bases"],
        "description": "Cancels the running build and resets the knowledge base so you can build it again. Returns `cancelled: false` when no build is running.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "The result of the cancel request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "cancelled": {
                      "type": "boolean",
                      "description": "Whether a running build was cancelled. `false` when no build was running."
                    }
                  },
                  "required": ["cancelled"],
                  "description": "The result of the cancel request."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources": {
      "get": {
        "operationId": "listSources",
        "summary": "List sources",
        "tags": ["sources"],
        "description": "Lists the sources of a knowledge base: the websites, Sanity datasets and files its documents come from, each with its document counts and its latest sync. Results are cursor-paginated.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "The `nextCursor` value from the previous page. Omit it to get the first page."
          },
          {
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "The maximum number of items to return."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of sources.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                "description": "The source's ID."
                              },
                              "knowledgeBaseId": {
                                "type": "string",
                                "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                              },
                              "title": {
                                "type": "string",
                                "description": "The source's title."
                              },
                              "documentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "The number of `active` and `missing` documents."
                              },
                              "convertedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents are converted to markdown, ready for builds."
                              },
                              "skippedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents have a file type that can't be converted."
                              },
                              "failedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents failed to convert or were too large to."
                              },
                              "chunkCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                              },
                              "lastSyncedAt": {
                                "nullable": true,
                                "description": "When a sync of the source last finished. `null` before the first one.",
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              "latestSync": {
                                "nullable": true,
                                "description": "The most recent sync, running or finished. `null` before the first one.",
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                    "description": "The sync's ID."
                                  },
                                  "sourceId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                    "description": "The ID of the source the sync read."
                                  },
                                  "mode": {
                                    "type": "string",
                                    "enum": ["full", "incremental"],
                                    "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                                  },
                                  "trigger": {
                                    "type": "string",
                                    "enum": ["schedule", "manual", "upload", "event", "push"],
                                    "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": ["running", "held", "completed", "failed", "cancelled"],
                                    "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                                  },
                                  "documentsSeen": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync read."
                                  },
                                  "documentsUpserted": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync added or changed."
                                  },
                                  "documentsUnchanged": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync read that had not changed."
                                  },
                                  "documentsDeleted": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync deleted."
                                  },
                                  "documentsMissing": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                                  },
                                  "heldDeletions": {
                                    "nullable": true,
                                    "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "partialReason": {
                                    "nullable": true,
                                    "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                                    "type": "string",
                                    "enum": [
                                      "page-limit",
                                      "source-limit",
                                      "stalled",
                                      "time-limit",
                                      null
                                    ]
                                  },
                                  "error": {
                                    "nullable": true,
                                    "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                                    "type": "string"
                                  },
                                  "createdAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                    "description": "When the sync started."
                                  },
                                  "finishedAt": {
                                    "nullable": true,
                                    "description": "When the sync finished. `null` while it is `running` or `held`.",
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  }
                                },
                                "required": [
                                  "id",
                                  "sourceId",
                                  "mode",
                                  "trigger",
                                  "status",
                                  "documentsSeen",
                                  "documentsUpserted",
                                  "documentsUnchanged",
                                  "documentsDeleted",
                                  "documentsMissing",
                                  "heldDeletions",
                                  "partialReason",
                                  "error",
                                  "createdAt",
                                  "finishedAt"
                                ]
                              },
                              "createdAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                "description": "When the source was added."
                              },
                              "updatedAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                "description": "When the source last changed."
                              },
                              "type": {
                                "type": "string",
                                "enum": ["web"],
                                "description": "The source type. `web` is a crawled website."
                              },
                              "url": {
                                "type": "string",
                                "description": "The URL the crawl starts from."
                              },
                              "crawlOptions": {
                                "type": "object",
                                "properties": {
                                  "includePaths": {
                                    "description": "Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.",
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "excludePaths": {
                                    "description": "Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.",
                                    "type": "array",
                                    "items": {
                                      "type": "string",
                                      "minLength": 1
                                    }
                                  },
                                  "maxDepth": {
                                    "description": "How many levels deep the crawl goes from the root URL.",
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "maximum": 9007199254740991
                                  },
                                  "sitemapOnly": {
                                    "description": "Whether to crawl only the pages listed in the site's sitemap.",
                                    "type": "boolean"
                                  },
                                  "ignoreQueryParameters": {
                                    "description": "Whether to treat URLs that differ only by query string as one page. New crawls set it to `true` unless you set it. Set it to `false` when the query string selects different content, such as pagination.",
                                    "type": "boolean"
                                  },
                                  "pageLimit": {
                                    "description": "The maximum number of pages to crawl. The crawl can stop sooner when the knowledge base reaches its source limit.",
                                    "type": "integer",
                                    "minimum": 0,
                                    "exclusiveMinimum": true,
                                    "maximum": 5000
                                  }
                                },
                                "description": "Options that control how a website is crawled."
                              },
                              "syncFrequency": {
                                "nullable": true,
                                "description": "How often the source syncs on its own: `weekly` or `monthly`. `null` when it syncs only when asked to.",
                                "type": "string",
                                "enum": ["weekly", "monthly", null]
                              }
                            },
                            "required": [
                              "id",
                              "knowledgeBaseId",
                              "title",
                              "documentCount",
                              "convertedDocumentCount",
                              "skippedDocumentCount",
                              "failedDocumentCount",
                              "chunkCount",
                              "lastSyncedAt",
                              "latestSync",
                              "createdAt",
                              "updatedAt",
                              "type",
                              "url",
                              "crawlOptions",
                              "syncFrequency"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                "description": "The source's ID."
                              },
                              "knowledgeBaseId": {
                                "type": "string",
                                "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                              },
                              "title": {
                                "type": "string",
                                "description": "The source's title."
                              },
                              "documentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "The number of `active` and `missing` documents."
                              },
                              "convertedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents are converted to markdown, ready for builds."
                              },
                              "skippedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents have a file type that can't be converted."
                              },
                              "failedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents failed to convert or were too large to."
                              },
                              "chunkCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                              },
                              "lastSyncedAt": {
                                "nullable": true,
                                "description": "When a sync of the source last finished. `null` before the first one.",
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              "latestSync": {
                                "nullable": true,
                                "description": "The most recent sync, running or finished. `null` before the first one.",
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                    "description": "The sync's ID."
                                  },
                                  "sourceId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                    "description": "The ID of the source the sync read."
                                  },
                                  "mode": {
                                    "type": "string",
                                    "enum": ["full", "incremental"],
                                    "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                                  },
                                  "trigger": {
                                    "type": "string",
                                    "enum": ["schedule", "manual", "upload", "event", "push"],
                                    "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": ["running", "held", "completed", "failed", "cancelled"],
                                    "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                                  },
                                  "documentsSeen": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync read."
                                  },
                                  "documentsUpserted": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync added or changed."
                                  },
                                  "documentsUnchanged": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync read that had not changed."
                                  },
                                  "documentsDeleted": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync deleted."
                                  },
                                  "documentsMissing": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                                  },
                                  "heldDeletions": {
                                    "nullable": true,
                                    "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "partialReason": {
                                    "nullable": true,
                                    "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                                    "type": "string",
                                    "enum": [
                                      "page-limit",
                                      "source-limit",
                                      "stalled",
                                      "time-limit",
                                      null
                                    ]
                                  },
                                  "error": {
                                    "nullable": true,
                                    "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                                    "type": "string"
                                  },
                                  "createdAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                    "description": "When the sync started."
                                  },
                                  "finishedAt": {
                                    "nullable": true,
                                    "description": "When the sync finished. `null` while it is `running` or `held`.",
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  }
                                },
                                "required": [
                                  "id",
                                  "sourceId",
                                  "mode",
                                  "trigger",
                                  "status",
                                  "documentsSeen",
                                  "documentsUpserted",
                                  "documentsUnchanged",
                                  "documentsDeleted",
                                  "documentsMissing",
                                  "heldDeletions",
                                  "partialReason",
                                  "error",
                                  "createdAt",
                                  "finishedAt"
                                ]
                              },
                              "createdAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                "description": "When the source was added."
                              },
                              "updatedAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                "description": "When the source last changed."
                              },
                              "type": {
                                "type": "string",
                                "enum": ["sanity-dataset"],
                                "description": "The source type. `sanity-dataset` is a GROQ query over a Sanity dataset."
                              },
                              "sanityProjectId": {
                                "type": "string",
                                "description": "The ID of the Sanity project the documents come from."
                              },
                              "sanityDatasetId": {
                                "type": "string",
                                "description": "The dataset the documents come from."
                              },
                              "query": {
                                "type": "string",
                                "description": "The GROQ query that selects the documents."
                              },
                              "syncFrequency": {
                                "nullable": true,
                                "description": "How often the source syncs on its own: `weekly` or `monthly`. `null` when it syncs only when asked to.",
                                "type": "string",
                                "enum": ["weekly", "monthly", null]
                              }
                            },
                            "required": [
                              "id",
                              "knowledgeBaseId",
                              "title",
                              "documentCount",
                              "convertedDocumentCount",
                              "skippedDocumentCount",
                              "failedDocumentCount",
                              "chunkCount",
                              "lastSyncedAt",
                              "latestSync",
                              "createdAt",
                              "updatedAt",
                              "type",
                              "sanityProjectId",
                              "sanityDatasetId",
                              "query",
                              "syncFrequency"
                            ]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "id": {
                                "type": "string",
                                "format": "uuid",
                                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                "description": "The source's ID."
                              },
                              "knowledgeBaseId": {
                                "type": "string",
                                "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                              },
                              "title": {
                                "type": "string",
                                "description": "The source's title."
                              },
                              "documentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "The number of `active` and `missing` documents."
                              },
                              "convertedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents are converted to markdown, ready for builds."
                              },
                              "skippedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents have a file type that can't be converted."
                              },
                              "failedDocumentCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "How many of those documents failed to convert or were too large to."
                              },
                              "chunkCount": {
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991,
                                "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                              },
                              "lastSyncedAt": {
                                "nullable": true,
                                "description": "When a sync of the source last finished. `null` before the first one.",
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                              },
                              "latestSync": {
                                "nullable": true,
                                "description": "The most recent sync, running or finished. `null` before the first one.",
                                "type": "object",
                                "properties": {
                                  "id": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                    "description": "The sync's ID."
                                  },
                                  "sourceId": {
                                    "type": "string",
                                    "format": "uuid",
                                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                                    "description": "The ID of the source the sync read."
                                  },
                                  "mode": {
                                    "type": "string",
                                    "enum": ["full", "incremental"],
                                    "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                                  },
                                  "trigger": {
                                    "type": "string",
                                    "enum": ["schedule", "manual", "upload", "event", "push"],
                                    "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                                  },
                                  "status": {
                                    "type": "string",
                                    "enum": ["running", "held", "completed", "failed", "cancelled"],
                                    "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                                  },
                                  "documentsSeen": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync read."
                                  },
                                  "documentsUpserted": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync added or changed."
                                  },
                                  "documentsUnchanged": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync read that had not changed."
                                  },
                                  "documentsDeleted": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of documents the sync deleted."
                                  },
                                  "documentsMissing": {
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991,
                                    "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                                  },
                                  "heldDeletions": {
                                    "nullable": true,
                                    "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                                    "type": "integer",
                                    "minimum": -9007199254740991,
                                    "maximum": 9007199254740991
                                  },
                                  "partialReason": {
                                    "nullable": true,
                                    "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                                    "type": "string",
                                    "enum": [
                                      "page-limit",
                                      "source-limit",
                                      "stalled",
                                      "time-limit",
                                      null
                                    ]
                                  },
                                  "error": {
                                    "nullable": true,
                                    "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                                    "type": "string"
                                  },
                                  "createdAt": {
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                    "description": "When the sync started."
                                  },
                                  "finishedAt": {
                                    "nullable": true,
                                    "description": "When the sync finished. `null` while it is `running` or `held`.",
                                    "type": "string",
                                    "format": "date-time",
                                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                                  }
                                },
                                "required": [
                                  "id",
                                  "sourceId",
                                  "mode",
                                  "trigger",
                                  "status",
                                  "documentsSeen",
                                  "documentsUpserted",
                                  "documentsUnchanged",
                                  "documentsDeleted",
                                  "documentsMissing",
                                  "heldDeletions",
                                  "partialReason",
                                  "error",
                                  "createdAt",
                                  "finishedAt"
                                ]
                              },
                              "createdAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                "description": "When the source was added."
                              },
                              "updatedAt": {
                                "type": "string",
                                "format": "date-time",
                                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                                "description": "When the source last changed."
                              },
                              "type": {
                                "type": "string",
                                "enum": ["files"],
                                "description": "The source type. `files` is an uploaded file or archive of files."
                              },
                              "filename": {
                                "nullable": true,
                                "description": "The name of the file last synced. `null` before the first upload.",
                                "type": "string"
                              },
                              "sizeBytes": {
                                "nullable": true,
                                "description": "The size of the file last synced, in bytes. `null` before the first upload.",
                                "type": "integer",
                                "minimum": -9007199254740991,
                                "maximum": 9007199254740991
                              }
                            },
                            "required": [
                              "id",
                              "knowledgeBaseId",
                              "title",
                              "documentCount",
                              "convertedDocumentCount",
                              "skippedDocumentCount",
                              "failedDocumentCount",
                              "chunkCount",
                              "lastSyncedAt",
                              "latestSync",
                              "createdAt",
                              "updatedAt",
                              "type",
                              "filename",
                              "sizeBytes"
                            ]
                          }
                        ],
                        "description": "Something that yields documents for a knowledge base: a website, a dataset or files."
                      },
                      "description": "The items on this page."
                    },
                    "nextCursor": {
                      "nullable": true,
                      "description": "The cursor for the next page. Pass it as `cursor` to get more results. `null` when there are no more pages.",
                      "type": "string"
                    }
                  },
                  "required": ["data", "nextCursor"],
                  "description": "A page of sources."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createSource",
        "summary": "Add a source",
        "tags": ["sources"],
        "description": "Adds a source to a knowledge base. Set `type` to choose what it reads:\n\n- `web`: a website, crawled from `url`\n- `sanity-dataset`: the documents a GROQ query selects in a Sanity dataset\n- `files`: files you upload with `POST .../sources/{sourceId}/uploads`, or text you send in `content`\n\nA website or dataset starts its first sync right away. A `files` source syncs when you upload a file, or right away when you send `content`: one request stores the text, adds the source and starts its sync. For a website, set `dryRun` to `true` to preview the crawl without adding the source.\n\nAdding a website that is already a source returns `409` with code `webSourceRootConflict`, and adding more websites than your limit allows returns `409` with code `webSourceRootLimitExceeded`. When the organization's knowledge bases already hold as many source chunks as its plan allows, returns `403` with code `planLimitReached` and adds nothing. Supports the `Idempotency-Key` header.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": ["web"],
                        "description": "The source type. `web` crawls a website."
                      },
                      "url": {
                        "type": "string",
                        "format": "uri",
                        "description": "The URL to start crawling from. It must be a public `http` or `https` URL."
                      },
                      "crawlOptions": {
                        "description": "Options for the crawl. Options you omit use the defaults.",
                        "type": "object",
                        "properties": {
                          "includePaths": {
                            "description": "Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.",
                            "type": "array",
                            "items": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "excludePaths": {
                            "description": "Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.",
                            "type": "array",
                            "items": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "maxDepth": {
                            "description": "How many levels deep the crawl goes from the root URL.",
                            "type": "integer",
                            "minimum": 0,
                            "exclusiveMinimum": true,
                            "maximum": 9007199254740991
                          },
                          "sitemapOnly": {
                            "description": "Whether to crawl only the pages listed in the site's sitemap.",
                            "type": "boolean"
                          },
                          "ignoreQueryParameters": {
                            "description": "Whether to treat URLs that differ only by query string as one page. New crawls set it to `true` unless you set it. Set it to `false` when the query string selects different content, such as pagination.",
                            "type": "boolean"
                          },
                          "pageLimit": {
                            "description": "The maximum number of pages to crawl. The crawl can stop sooner when the knowledge base reaches its source limit.",
                            "type": "integer",
                            "minimum": 0,
                            "exclusiveMinimum": true,
                            "maximum": 5000
                          }
                        }
                      },
                      "dryRun": {
                        "description": "Set to `true` to estimate what a crawl would fetch without adding the source. The response is then `200` with a preview of the pages the site has, grouped by path.",
                        "type": "boolean"
                      }
                    },
                    "required": ["type", "url"]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": ["sanity-dataset"],
                        "description": "The source type. `sanity-dataset` reads documents from a Sanity dataset."
                      },
                      "sanityProjectId": {
                        "type": "string",
                        "minLength": 1,
                        "description": "The ID of the Sanity project to read documents from. You need full read access to the dataset and, on its project, the Administrator or Developer role or a custom role that can create datasets."
                      },
                      "sanityDatasetId": {
                        "type": "string",
                        "minLength": 1,
                        "description": "The dataset to read documents from."
                      },
                      "query": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 10000,
                        "description": "A GROQ query that selects the documents, with an optional projection. Each sync runs it again."
                      }
                    },
                    "required": ["type", "sanityProjectId", "sanityDatasetId", "query"]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": ["files"],
                        "description": "The source type. `files` holds an uploaded file, or text sent with `content`."
                      },
                      "title": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200,
                        "description": "The source's title."
                      },
                      "content": {
                        "description": "Text or markdown for the source to hold, up to 1,000,000 bytes of UTF-8. The source syncs it at once, with no upload. Larger content goes through `POST .../sources/{sourceId}/uploads`.",
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 1000000
                      },
                      "contentType": {
                        "description": "The format of `content`: `text/markdown` (the default) or `text/plain`. Only with `content`.",
                        "type": "string",
                        "enum": ["text/markdown", "text/plain"]
                      }
                    },
                    "required": ["type", "title"]
                  }
                ],
                "description": "The source to add. The `type` field sets its kind."
              }
            }
          },
          "description": "The source to add. The `type` field sets its kind."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "description": "A unique value, such as a UUID, that makes retries safe. A retry with the same key and body returns the first response instead of repeating the work."
          }
        ],
        "responses": {
          "200": {
            "description": "The preview of a crawl, when `dryRun` is `true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalPages": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991,
                      "description": "How many pages the crawl would fetch, roughly."
                    },
                    "truncated": {
                      "type": "boolean",
                      "description": "Whether the site has more pages than the preview counted."
                    },
                    "groups": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "prefix": {
                            "type": "string",
                            "description": "The path the pages in the group share, such as `/docs/`."
                          },
                          "count": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 9007199254740991,
                            "description": "How many pages the group has."
                          }
                        },
                        "required": ["prefix", "count"],
                        "description": "A group of pages under one path."
                      },
                      "description": "The largest groups of pages by path, largest first."
                    },
                    "otherCount": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991,
                      "description": "How many pages are outside `groups`."
                    }
                  },
                  "required": ["totalPages", "truncated", "groups", "otherCount"],
                  "description": "The preview of a crawl, when `dryRun` is `true`."
                }
              }
            }
          },
          "201": {
            "description": "Something that yields documents for a knowledge base: a website, a dataset or files.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["web"],
                          "description": "The source type. `web` is a crawled website."
                        },
                        "url": {
                          "type": "string",
                          "description": "The URL the crawl starts from."
                        },
                        "crawlOptions": {
                          "type": "object",
                          "properties": {
                            "includePaths": {
                              "description": "Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.",
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "excludePaths": {
                              "description": "Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.",
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "maxDepth": {
                              "description": "How many levels deep the crawl goes from the root URL.",
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 9007199254740991
                            },
                            "sitemapOnly": {
                              "description": "Whether to crawl only the pages listed in the site's sitemap.",
                              "type": "boolean"
                            },
                            "ignoreQueryParameters": {
                              "description": "Whether to treat URLs that differ only by query string as one page. New crawls set it to `true` unless you set it. Set it to `false` when the query string selects different content, such as pagination.",
                              "type": "boolean"
                            },
                            "pageLimit": {
                              "description": "The maximum number of pages to crawl. The crawl can stop sooner when the knowledge base reaches its source limit.",
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 5000
                            }
                          },
                          "description": "Options that control how a website is crawled."
                        },
                        "syncFrequency": {
                          "nullable": true,
                          "description": "How often the source syncs on its own: `weekly` or `monthly`. `null` when it syncs only when asked to.",
                          "type": "string",
                          "enum": ["weekly", "monthly", null]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "url",
                        "crawlOptions",
                        "syncFrequency"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["sanity-dataset"],
                          "description": "The source type. `sanity-dataset` is a GROQ query over a Sanity dataset."
                        },
                        "sanityProjectId": {
                          "type": "string",
                          "description": "The ID of the Sanity project the documents come from."
                        },
                        "sanityDatasetId": {
                          "type": "string",
                          "description": "The dataset the documents come from."
                        },
                        "query": {
                          "type": "string",
                          "description": "The GROQ query that selects the documents."
                        },
                        "syncFrequency": {
                          "nullable": true,
                          "description": "How often the source syncs on its own: `weekly` or `monthly`. `null` when it syncs only when asked to.",
                          "type": "string",
                          "enum": ["weekly", "monthly", null]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "sanityProjectId",
                        "sanityDatasetId",
                        "query",
                        "syncFrequency"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["files"],
                          "description": "The source type. `files` is an uploaded file or archive of files."
                        },
                        "filename": {
                          "nullable": true,
                          "description": "The name of the file last synced. `null` before the first upload.",
                          "type": "string"
                        },
                        "sizeBytes": {
                          "nullable": true,
                          "description": "The size of the file last synced, in bytes. `null` before the first upload.",
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "filename",
                        "sizeBytes"
                      ]
                    }
                  ],
                  "description": "Something that yields documents for a knowledge base: a website, a dataset or files."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}": {
      "get": {
        "operationId": "getSource",
        "summary": "Get a source",
        "tags": ["sources"],
        "description": "Returns a source with its settings, document counts and latest sync.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "Something that yields documents for a knowledge base: a website, a dataset or files.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["web"],
                          "description": "The source type. `web` is a crawled website."
                        },
                        "url": {
                          "type": "string",
                          "description": "The URL the crawl starts from."
                        },
                        "crawlOptions": {
                          "type": "object",
                          "properties": {
                            "includePaths": {
                              "description": "Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.",
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "excludePaths": {
                              "description": "Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.",
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "maxDepth": {
                              "description": "How many levels deep the crawl goes from the root URL.",
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 9007199254740991
                            },
                            "sitemapOnly": {
                              "description": "Whether to crawl only the pages listed in the site's sitemap.",
                              "type": "boolean"
                            },
                            "ignoreQueryParameters": {
                              "description": "Whether to treat URLs that differ only by query string as one page. New crawls set it to `true` unless you set it. Set it to `false` when the query string selects different content, such as pagination.",
                              "type": "boolean"
                            },
                            "pageLimit": {
                              "description": "The maximum number of pages to crawl. The crawl can stop sooner when the knowledge base reaches its source limit.",
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 5000
                            }
                          },
                          "description": "Options that control how a website is crawled."
                        },
                        "syncFrequency": {
                          "nullable": true,
                          "description": "How often the source syncs on its own: `weekly` or `monthly`. `null` when it syncs only when asked to.",
                          "type": "string",
                          "enum": ["weekly", "monthly", null]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "url",
                        "crawlOptions",
                        "syncFrequency"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["sanity-dataset"],
                          "description": "The source type. `sanity-dataset` is a GROQ query over a Sanity dataset."
                        },
                        "sanityProjectId": {
                          "type": "string",
                          "description": "The ID of the Sanity project the documents come from."
                        },
                        "sanityDatasetId": {
                          "type": "string",
                          "description": "The dataset the documents come from."
                        },
                        "query": {
                          "type": "string",
                          "description": "The GROQ query that selects the documents."
                        },
                        "syncFrequency": {
                          "nullable": true,
                          "description": "How often the source syncs on its own: `weekly` or `monthly`. `null` when it syncs only when asked to.",
                          "type": "string",
                          "enum": ["weekly", "monthly", null]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "sanityProjectId",
                        "sanityDatasetId",
                        "query",
                        "syncFrequency"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["files"],
                          "description": "The source type. `files` is an uploaded file or archive of files."
                        },
                        "filename": {
                          "nullable": true,
                          "description": "The name of the file last synced. `null` before the first upload.",
                          "type": "string"
                        },
                        "sizeBytes": {
                          "nullable": true,
                          "description": "The size of the file last synced, in bytes. `null` before the first upload.",
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "filename",
                        "sizeBytes"
                      ]
                    }
                  ],
                  "description": "Something that yields documents for a knowledge base: a website, a dataset or files."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateSource",
        "summary": "Update a source",
        "tags": ["sources"],
        "description": "Changes a source's title, a website's crawl options, a dataset's query, or how often a website or dataset syncs on its own. New crawl options delete the documents whose path they leave out. When that would delete all of the source's documents, or five or more that are over a fifth of them, the request returns `409` with code `sourceDeletionsUnconfirmed` until you send it again with `confirmDeletions` set to `true`. New crawl options sent while the source syncs return `409` with code `syncInProgress`; send them again once the sync finishes. A new query queues a sync, which removes the documents the query no longer selects.\n\nCrawl options on a source that isn't a website, a query on one that isn't a dataset, or a sync frequency on a `files` source, return `422` with code `sourceTypeMismatch`. Setting a sync frequency on a plan without scheduled syncs returns `403` with code `featureNotInPlan`; setting it to `null` always works.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "description": "The source's title.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "crawlOptions": {
                    "description": "For a `web` source, the crawl options, replacing the stored ones. Documents whose path the new include and exclude paths leave out are deleted.",
                    "type": "object",
                    "properties": {
                      "includePaths": {
                        "description": "Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "excludePaths": {
                        "description": "Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.",
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "maxDepth": {
                        "description": "How many levels deep the crawl goes from the root URL.",
                        "type": "integer",
                        "minimum": 0,
                        "exclusiveMinimum": true,
                        "maximum": 9007199254740991
                      },
                      "sitemapOnly": {
                        "description": "Whether to crawl only the pages listed in the site's sitemap.",
                        "type": "boolean"
                      },
                      "ignoreQueryParameters": {
                        "description": "Whether to treat URLs that differ only by query string as one page. New crawls set it to `true` unless you set it. Set it to `false` when the query string selects different content, such as pagination.",
                        "type": "boolean"
                      },
                      "pageLimit": {
                        "description": "The maximum number of pages to crawl. The crawl can stop sooner when the knowledge base reaches its source limit.",
                        "type": "integer",
                        "minimum": 0,
                        "exclusiveMinimum": true,
                        "maximum": 5000
                      }
                    }
                  },
                  "query": {
                    "description": "For a `sanity-dataset` source, the GROQ query, replacing the stored one. A sync is queued, and removes the documents the query no longer returns.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000
                  },
                  "syncFrequency": {
                    "description": "For a `web` or `sanity-dataset` source, how often it syncs on its own: `weekly` or `monthly`. `null` stops scheduled syncs, and you can still start a sync yourself. Setting a frequency requires a plan that includes scheduled syncs; without one, the request returns `403` with code `featureNotInPlan`.",
                    "nullable": true,
                    "type": "string",
                    "enum": ["weekly", "monthly", null]
                  },
                  "confirmDeletions": {
                    "description": "Set to `true` to apply new crawl options that delete many documents. Without it, a change that would delete all of the documents, or five or more that are over a fifth of them, returns `409` with code `sourceDeletionsUnconfirmed`.",
                    "type": "boolean"
                  }
                },
                "description": "The changes to make to a source."
              }
            }
          },
          "description": "The changes to make to a source."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "Something that yields documents for a knowledge base: a website, a dataset or files.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["web"],
                          "description": "The source type. `web` is a crawled website."
                        },
                        "url": {
                          "type": "string",
                          "description": "The URL the crawl starts from."
                        },
                        "crawlOptions": {
                          "type": "object",
                          "properties": {
                            "includePaths": {
                              "description": "Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.",
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "excludePaths": {
                              "description": "Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.",
                              "type": "array",
                              "items": {
                                "type": "string",
                                "minLength": 1
                              }
                            },
                            "maxDepth": {
                              "description": "How many levels deep the crawl goes from the root URL.",
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 9007199254740991
                            },
                            "sitemapOnly": {
                              "description": "Whether to crawl only the pages listed in the site's sitemap.",
                              "type": "boolean"
                            },
                            "ignoreQueryParameters": {
                              "description": "Whether to treat URLs that differ only by query string as one page. New crawls set it to `true` unless you set it. Set it to `false` when the query string selects different content, such as pagination.",
                              "type": "boolean"
                            },
                            "pageLimit": {
                              "description": "The maximum number of pages to crawl. The crawl can stop sooner when the knowledge base reaches its source limit.",
                              "type": "integer",
                              "minimum": 0,
                              "exclusiveMinimum": true,
                              "maximum": 5000
                            }
                          },
                          "description": "Options that control how a website is crawled."
                        },
                        "syncFrequency": {
                          "nullable": true,
                          "description": "How often the source syncs on its own: `weekly` or `monthly`. `null` when it syncs only when asked to.",
                          "type": "string",
                          "enum": ["weekly", "monthly", null]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "url",
                        "crawlOptions",
                        "syncFrequency"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["sanity-dataset"],
                          "description": "The source type. `sanity-dataset` is a GROQ query over a Sanity dataset."
                        },
                        "sanityProjectId": {
                          "type": "string",
                          "description": "The ID of the Sanity project the documents come from."
                        },
                        "sanityDatasetId": {
                          "type": "string",
                          "description": "The dataset the documents come from."
                        },
                        "query": {
                          "type": "string",
                          "description": "The GROQ query that selects the documents."
                        },
                        "syncFrequency": {
                          "nullable": true,
                          "description": "How often the source syncs on its own: `weekly` or `monthly`. `null` when it syncs only when asked to.",
                          "type": "string",
                          "enum": ["weekly", "monthly", null]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "sanityProjectId",
                        "sanityDatasetId",
                        "query",
                        "syncFrequency"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "The source's ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the source belongs to."
                        },
                        "title": {
                          "type": "string",
                          "description": "The source's title."
                        },
                        "documentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of `active` and `missing` documents."
                        },
                        "convertedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents are converted to markdown, ready for builds."
                        },
                        "skippedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents have a file type that can't be converted."
                        },
                        "failedDocumentCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "How many of those documents failed to convert or were too large to."
                        },
                        "chunkCount": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The number of chunks in its documents' markdown, the unit usage is counted in."
                        },
                        "lastSyncedAt": {
                          "nullable": true,
                          "description": "When a sync of the source last finished. `null` before the first one.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "latestSync": {
                          "nullable": true,
                          "description": "The most recent sync, running or finished. `null` before the first one.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The sync's ID."
                            },
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the sync read."
                            },
                            "mode": {
                              "type": "string",
                              "enum": ["full", "incremental"],
                              "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                            },
                            "trigger": {
                              "type": "string",
                              "enum": ["schedule", "manual", "upload", "event", "push"],
                              "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["running", "held", "completed", "failed", "cancelled"],
                              "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                            },
                            "documentsSeen": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read."
                            },
                            "documentsUpserted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync added or changed."
                            },
                            "documentsUnchanged": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync read that had not changed."
                            },
                            "documentsDeleted": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of documents the sync deleted."
                            },
                            "documentsMissing": {
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991,
                              "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                              "type": "integer",
                              "minimum": -9007199254740991,
                              "maximum": 9007199254740991
                            },
                            "partialReason": {
                              "nullable": true,
                              "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                              "type": "string",
                              "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                            },
                            "error": {
                              "nullable": true,
                              "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                              "type": "string"
                            },
                            "createdAt": {
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                              "description": "When the sync started."
                            },
                            "finishedAt": {
                              "nullable": true,
                              "description": "When the sync finished. `null` while it is `running` or `held`.",
                              "type": "string",
                              "format": "date-time",
                              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                            }
                          },
                          "required": [
                            "id",
                            "sourceId",
                            "mode",
                            "trigger",
                            "status",
                            "documentsSeen",
                            "documentsUpserted",
                            "documentsUnchanged",
                            "documentsDeleted",
                            "documentsMissing",
                            "heldDeletions",
                            "partialReason",
                            "error",
                            "createdAt",
                            "finishedAt"
                          ]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source was added."
                        },
                        "updatedAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the source last changed."
                        },
                        "type": {
                          "type": "string",
                          "enum": ["files"],
                          "description": "The source type. `files` is an uploaded file or archive of files."
                        },
                        "filename": {
                          "nullable": true,
                          "description": "The name of the file last synced. `null` before the first upload.",
                          "type": "string"
                        },
                        "sizeBytes": {
                          "nullable": true,
                          "description": "The size of the file last synced, in bytes. `null` before the first upload.",
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "title",
                        "documentCount",
                        "convertedDocumentCount",
                        "skippedDocumentCount",
                        "failedDocumentCount",
                        "chunkCount",
                        "lastSyncedAt",
                        "latestSync",
                        "createdAt",
                        "updatedAt",
                        "type",
                        "filename",
                        "sizeBytes"
                      ]
                    }
                  ],
                  "description": "Something that yields documents for a knowledge base: a website, a dataset or files."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteSource",
        "summary": "Delete a source",
        "tags": ["sources"],
        "description": "Removes a source and its documents from the knowledge base, and starts a refresh that removes their citations from entries and deletes the entries left with none. A source no other knowledge base uses stops syncing and is deleted once that refresh has run.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "204": {
            "description": "The source was deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "nullable": true,
                  "enum": [null],
                  "description": "The source was deleted."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs": {
      "get": {
        "operationId": "listSyncs",
        "summary": "List a source's syncs",
        "tags": ["sources"],
        "description": "Lists the syncs of a source, newest first. Results are cursor-paginated.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "The `nextCursor` value from the previous page. Omit it to get the first page."
          },
          {
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "The maximum number of items to return."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of syncs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                            "description": "The sync's ID."
                          },
                          "sourceId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                            "description": "The ID of the source the sync read."
                          },
                          "mode": {
                            "type": "string",
                            "enum": ["full", "incremental"],
                            "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                          },
                          "trigger": {
                            "type": "string",
                            "enum": ["schedule", "manual", "upload", "event", "push"],
                            "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                          },
                          "status": {
                            "type": "string",
                            "enum": ["running", "held", "completed", "failed", "cancelled"],
                            "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                          },
                          "documentsSeen": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of documents the sync read."
                          },
                          "documentsUpserted": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of documents the sync added or changed."
                          },
                          "documentsUnchanged": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of documents the sync read that had not changed."
                          },
                          "documentsDeleted": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of documents the sync deleted."
                          },
                          "documentsMissing": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                          },
                          "heldDeletions": {
                            "nullable": true,
                            "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "partialReason": {
                            "nullable": true,
                            "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                            "type": "string",
                            "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                          },
                          "error": {
                            "nullable": true,
                            "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                            "description": "When the sync started."
                          },
                          "finishedAt": {
                            "nullable": true,
                            "description": "When the sync finished. `null` while it is `running` or `held`.",
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          }
                        },
                        "required": [
                          "id",
                          "sourceId",
                          "mode",
                          "trigger",
                          "status",
                          "documentsSeen",
                          "documentsUpserted",
                          "documentsUnchanged",
                          "documentsDeleted",
                          "documentsMissing",
                          "heldDeletions",
                          "partialReason",
                          "error",
                          "createdAt",
                          "finishedAt"
                        ],
                        "description": "One run of a source's connector."
                      },
                      "description": "The items on this page."
                    },
                    "nextCursor": {
                      "nullable": true,
                      "description": "The cursor for the next page. Pass it as `cursor` to get more results. `null` when there are no more pages.",
                      "type": "string"
                    }
                  },
                  "required": ["data", "nextCursor"],
                  "description": "A page of syncs."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "startSync",
        "summary": "Sync a source",
        "tags": ["sources"],
        "description": "Starts a sync of the source. A website or dataset is read again: its sync is queued, and starts once any sync of the source that is running ends, including the first one that started when it was added. Asking again while one waits queues nothing more. Follow it with the source's `latestSync`.\n\nFor a `files` source, set `uploadId` to the upload whose file the source should hold from now on; without it, the source reads its current file again. Its sync starts at once and returns a job ID to poll; the finished job's `result` names the sync and whether it is `held`. While a sync of a `files` source is running, including the first one, the request returns `409` with code `syncInProgress` and leaves the upload for a later request. An `uploadId` whose file never arrived returns `404` with code `uploadNotFound`, and an `uploadId` on a source that isn't `files` returns `422` with code `sourceTypeMismatch`.\n\nSupports the `Idempotency-Key` header.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "nullable": true,
                "type": "object",
                "properties": {
                  "uploadId": {
                    "description": "For a `files` source, the `uploadId` of the file to sync, from `POST .../sources/{sourceId}/uploads`. Without it, a `files` source reads its current file again. Not allowed for other types.",
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  }
                },
                "description": "What a new sync reads."
              }
            }
          },
          "description": "What a new sync reads."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "description": "A unique value, such as a UUID, that makes retries safe. A retry with the same key and body returns the first response instead of repeating the work."
          }
        ],
        "responses": {
          "202": {
            "description": "The sync that was started or queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sourceId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The ID of the source that will sync."
                    },
                    "jobId": {
                      "nullable": true,
                      "description": "For a `files` source, the ID of the sync's job. Check its progress with `GET .../jobs/{jobId}`; once it succeeds, its `result` names the sync and whether it is `held`. `null` for a website or dataset, whose sync is queued on the source: follow it with the source's `latestSync`.",
                      "type": "string"
                    }
                  },
                  "required": ["sourceId", "jobId"],
                  "description": "The sync that was started or queued."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs/{syncId}": {
      "get": {
        "operationId": "getSync",
        "summary": "Get a sync",
        "tags": ["sources"],
        "description": "Returns one sync of a source with its status and counts.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "syncId",
            "required": true,
            "description": "The sync's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "One run of a source's connector.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The sync's ID."
                    },
                    "sourceId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The ID of the source the sync read."
                    },
                    "mode": {
                      "type": "string",
                      "enum": ["full", "incremental"],
                      "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                    },
                    "trigger": {
                      "type": "string",
                      "enum": ["schedule", "manual", "upload", "event", "push"],
                      "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                    },
                    "status": {
                      "type": "string",
                      "enum": ["running", "held", "completed", "failed", "cancelled"],
                      "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                    },
                    "documentsSeen": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync read."
                    },
                    "documentsUpserted": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync added or changed."
                    },
                    "documentsUnchanged": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync read that had not changed."
                    },
                    "documentsDeleted": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync deleted."
                    },
                    "documentsMissing": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                    },
                    "heldDeletions": {
                      "nullable": true,
                      "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "partialReason": {
                      "nullable": true,
                      "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                      "type": "string",
                      "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                    },
                    "error": {
                      "nullable": true,
                      "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the sync started."
                    },
                    "finishedAt": {
                      "nullable": true,
                      "description": "When the sync finished. `null` while it is `running` or `held`.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "sourceId",
                    "mode",
                    "trigger",
                    "status",
                    "documentsSeen",
                    "documentsUpserted",
                    "documentsUnchanged",
                    "documentsDeleted",
                    "documentsMissing",
                    "heldDeletions",
                    "partialReason",
                    "error",
                    "createdAt",
                    "finishedAt"
                  ],
                  "description": "One run of a source's connector."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs/{syncId}/confirm": {
      "post": {
        "operationId": "confirmSync",
        "summary": "Confirm a held sync's deletions",
        "tags": ["sources"],
        "description": "Deletes the documents a `held` sync didn't find, unless a sync has found them since, completes the sync, and starts a refresh of each knowledge base that uses the source, which removes their citations from entries. A sync that isn't `held` returns `409` with code `syncNotHeld`.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "syncId",
            "required": true,
            "description": "The sync's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "One run of a source's connector.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The sync's ID."
                    },
                    "sourceId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The ID of the source the sync read."
                    },
                    "mode": {
                      "type": "string",
                      "enum": ["full", "incremental"],
                      "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                    },
                    "trigger": {
                      "type": "string",
                      "enum": ["schedule", "manual", "upload", "event", "push"],
                      "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                    },
                    "status": {
                      "type": "string",
                      "enum": ["running", "held", "completed", "failed", "cancelled"],
                      "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                    },
                    "documentsSeen": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync read."
                    },
                    "documentsUpserted": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync added or changed."
                    },
                    "documentsUnchanged": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync read that had not changed."
                    },
                    "documentsDeleted": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync deleted."
                    },
                    "documentsMissing": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                    },
                    "heldDeletions": {
                      "nullable": true,
                      "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "partialReason": {
                      "nullable": true,
                      "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                      "type": "string",
                      "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                    },
                    "error": {
                      "nullable": true,
                      "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the sync started."
                    },
                    "finishedAt": {
                      "nullable": true,
                      "description": "When the sync finished. `null` while it is `running` or `held`.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "sourceId",
                    "mode",
                    "trigger",
                    "status",
                    "documentsSeen",
                    "documentsUpserted",
                    "documentsUnchanged",
                    "documentsDeleted",
                    "documentsMissing",
                    "heldDeletions",
                    "partialReason",
                    "error",
                    "createdAt",
                    "finishedAt"
                  ],
                  "description": "One run of a source's connector."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs/{syncId}/discard": {
      "post": {
        "operationId": "discardSync",
        "summary": "Discard a held sync's deletions",
        "tags": ["sources"],
        "description": "Completes a `held` sync without deleting anything: every document stays as it is. A sync that isn't `held` returns `409` with code `syncNotHeld`.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "syncId",
            "required": true,
            "description": "The sync's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "One run of a source's connector.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The sync's ID."
                    },
                    "sourceId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The ID of the source the sync read."
                    },
                    "mode": {
                      "type": "string",
                      "enum": ["full", "incremental"],
                      "description": "`full` reads the whole source and removes what it no longer finds. `incremental` reads only what changed since the last sync."
                    },
                    "trigger": {
                      "type": "string",
                      "enum": ["schedule", "manual", "upload", "event", "push"],
                      "description": "What started the sync: `schedule`, `manual` (an API call or the dashboard), `upload` (a new file), `event` or `push`."
                    },
                    "status": {
                      "type": "string",
                      "enum": ["running", "held", "completed", "failed", "cancelled"],
                      "description": "The sync's status. `running`: still reading or converting. `held`: the sync would delete every document of the source, or five or more that are over a fifth of them, and waits for you to confirm or discard the deletion; the next sync of the source cancels it and holds again if the deletion still stands. `completed`, `failed` and `cancelled` are final."
                    },
                    "documentsSeen": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync read."
                    },
                    "documentsUpserted": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync added or changed."
                    },
                    "documentsUnchanged": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync read that had not changed."
                    },
                    "documentsDeleted": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of documents the sync deleted."
                    },
                    "documentsMissing": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of web pages the sync marked `missing` because several crawls in a row didn't find them."
                    },
                    "heldDeletions": {
                      "nullable": true,
                      "description": "How many documents the held deletion would remove. Set while the sync is `held`, and kept after you confirm or discard it. `null` when the sync was never held.",
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "partialReason": {
                      "nullable": true,
                      "description": "Why the sync stopped before it read the whole source, so it removed nothing. `page-limit`: the crawl reached its page limit. `source-limit`: the knowledge base had no room for more documents. `stalled`: the crawl stopped making progress. `time-limit`: the crawl ran out of time. `null` when the sync read the whole source, or hasn't finished.",
                      "type": "string",
                      "enum": ["page-limit", "source-limit", "stalled", "time-limit", null]
                    },
                    "error": {
                      "nullable": true,
                      "description": "Why the sync failed, written to show to users. `null` unless `status` is `failed`.",
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the sync started."
                    },
                    "finishedAt": {
                      "nullable": true,
                      "description": "When the sync finished. `null` while it is `running` or `held`.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "sourceId",
                    "mode",
                    "trigger",
                    "status",
                    "documentsSeen",
                    "documentsUpserted",
                    "documentsUnchanged",
                    "documentsDeleted",
                    "documentsMissing",
                    "heldDeletions",
                    "partialReason",
                    "error",
                    "createdAt",
                    "finishedAt"
                  ],
                  "description": "One run of a source's connector."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/uploads": {
      "post": {
        "operationId": "startSourceUpload",
        "summary": "Upload a file to a source",
        "tags": ["sources"],
        "description": "Returns a single-use signed URL for one file of a `files` source, valid for one hour. To add the file:\n\n1. Send the file in a `PUT` request to `uploadUrl`.\n2. Call `POST .../sources/{sourceId}/syncs` with the `uploadId`.\n\nThe file can be a single document or a zip, tar or gzip archive of them. It replaces the source's current file when it syncs. An upload no sync takes within 24 hours is deleted. A source that isn't `files` returns `422` with code `sourceTypeMismatch`. When the organization's knowledge bases already hold as many source chunks as its plan allows, returns `403` with code `planLimitReached`. Supports the `Idempotency-Key` header.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filename": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500,
                    "description": "The file's name."
                  },
                  "contentType": {
                    "description": "The media type of the file. When set, the `PUT` request must send the same `Content-Type` header.",
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": ["filename"],
                "description": "The file to upload."
              }
            }
          },
          "description": "The file to upload."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "sourceId",
            "required": true,
            "description": "The source's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "Idempotency-Key",
            "required": false,
            "description": "A unique value, such as a UUID, that makes retries safe. A retry with the same key and body returns the first response instead of repeating the work."
          }
        ],
        "responses": {
          "201": {
            "description": "Where to upload the file.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uploadId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The ID of the upload. Pass it to `POST .../syncs` once the file is uploaded."
                    },
                    "uploadUrl": {
                      "type": "string",
                      "format": "uri",
                      "description": "A signed URL to send the file to in one `PUT` request. It expires after one hour."
                    }
                  },
                  "required": ["uploadId", "uploadUrl"],
                  "description": "Where to upload the file."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sync": {
      "post": {
        "operationId": "syncAllSources",
        "summary": "Sync every source",
        "tags": ["sources"],
        "description": "Queues a sync of every website and dataset source, which starts once any sync of the source that is running ends. `files` sources sync when you upload a file. New documents, from these syncs or waiting from earlier ones, are then placed in the knowledge base right away instead of waiting to be placed together with the documents that follow them. This covers the documents that arrive within an hour of the request. A refresh writes a limited number of entries, so a large batch is placed over several refreshes.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "202": {
            "description": "The syncs that were queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sourceIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "description": "The IDs of the sources that will sync. Follow each with the source's `latestSync`. `files` sources aren't included: they sync when you upload a file."
                    }
                  },
                  "required": ["sourceIds"],
                  "description": "The syncs that were queued."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/documents": {
      "get": {
        "operationId": "listDocuments",
        "summary": "List documents",
        "tags": ["documents"],
        "description": "Lists the documents in a knowledge base: the pages, dataset documents and files its sources yield, which builds read and cite. Results are cursor-paginated, and you can filter them by `source` and `state`.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "cursor",
            "required": false,
            "description": "The `nextCursor` value from the previous page. Omit it to get the first page."
          },
          {
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            },
            "in": "query",
            "name": "limit",
            "required": false,
            "description": "The maximum number of items to return."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "query",
            "name": "source",
            "required": false,
            "description": "Return only the documents of this source."
          },
          {
            "schema": {
              "type": "string",
              "enum": ["active", "missing", "deleted"]
            },
            "in": "query",
            "name": "state",
            "required": false,
            "description": "Return only documents in this state. Without it, `deleted` documents are left out."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "ids",
            "required": false,
            "description": "Comma-separated IDs of the documents to return, up to 200, in any state. Use it to look up the documents entry citations point at."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of documents.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                            "description": "The document's ID. Entry citations point at it."
                          },
                          "sourceId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                            "description": "The ID of the source the document comes from."
                          },
                          "sourceType": {
                            "type": "string",
                            "enum": ["web", "sanity-dataset", "files"],
                            "description": "The type of the source the document comes from."
                          },
                          "externalId": {
                            "type": "string",
                            "description": "The document's identity in its source: the page URL, the dataset document `_id`, or the file's path in the upload."
                          },
                          "title": {
                            "type": "string",
                            "description": "The document's title, or its `externalId` when it has none."
                          },
                          "url": {
                            "nullable": true,
                            "description": "Where the document lives on the web. `null` for files and dataset documents.",
                            "type": "string"
                          },
                          "state": {
                            "type": "string",
                            "enum": ["active", "missing", "deleted"],
                            "description": "The document's state. `active`: in the knowledge base. `missing`: several crawls in a row didn't find the page, but it stays in the knowledge base until you delete or keep it. `deleted`: removed from the source, or by you."
                          },
                          "mime": {
                            "nullable": true,
                            "description": "The media type of the document as read. `null` before its content was read.",
                            "type": "string"
                          },
                          "sizeBytes": {
                            "nullable": true,
                            "description": "The size of the document as read, in bytes. `null` before its content was read.",
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991
                          },
                          "conversion": {
                            "type": "string",
                            "enum": ["pending", "converted", "unsupported", "oversized", "failed"],
                            "description": "How far the current content got through conversion to markdown, the text builds read and cite. `pending`: not converted yet. `converted`: ready. `unsupported`: the file type has no converter. `oversized`: too large to convert. `failed`: conversion failed, see `conversionError`."
                          },
                          "conversionError": {
                            "nullable": true,
                            "description": "Why conversion failed. `null` unless `conversion` is `failed` or `oversized`.",
                            "type": "string"
                          },
                          "excludedAt": {
                            "nullable": true,
                            "description": "When a build left the document out because the organization's source chunk limit had no room for it. No build reads it until a later build finds room, which includes it automatically. `null` while builds include it.",
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "documentUpdatedAt": {
                            "nullable": true,
                            "description": "When the document says it was last updated: from a page's meta tags, a file's own metadata, or a dataset document's `_updatedAt`. `null` when it doesn't say.",
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          },
                          "lastSeenAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                            "description": "When a sync last found the document in its source."
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                            "description": "When the document was first read."
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                            "description": "When the document last changed."
                          }
                        },
                        "required": [
                          "id",
                          "sourceId",
                          "sourceType",
                          "externalId",
                          "title",
                          "url",
                          "state",
                          "mime",
                          "sizeBytes",
                          "conversion",
                          "conversionError",
                          "excludedAt",
                          "documentUpdatedAt",
                          "lastSeenAt",
                          "createdAt",
                          "updatedAt"
                        ],
                        "description": "One page, dataset document or file that a source yields."
                      },
                      "description": "The items on this page."
                    },
                    "nextCursor": {
                      "nullable": true,
                      "description": "The cursor for the next page. Pass it as `cursor` to get more results. `null` when there are no more pages.",
                      "type": "string"
                    }
                  },
                  "required": ["data", "nextCursor"],
                  "description": "A page of documents."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}": {
      "get": {
        "operationId": "getDocument",
        "summary": "Get a document",
        "tags": ["documents"],
        "description": "Returns a document with its conversion status and the chunks of its markdown. Entry citations point at a document's chunks.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "documentId",
            "required": true,
            "description": "The document's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A document with the chunks of its markdown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The document's ID. Entry citations point at it."
                    },
                    "sourceId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The ID of the source the document comes from."
                    },
                    "sourceType": {
                      "type": "string",
                      "enum": ["web", "sanity-dataset", "files"],
                      "description": "The type of the source the document comes from."
                    },
                    "externalId": {
                      "type": "string",
                      "description": "The document's identity in its source: the page URL, the dataset document `_id`, or the file's path in the upload."
                    },
                    "title": {
                      "type": "string",
                      "description": "The document's title, or its `externalId` when it has none."
                    },
                    "url": {
                      "nullable": true,
                      "description": "Where the document lives on the web. `null` for files and dataset documents.",
                      "type": "string"
                    },
                    "state": {
                      "type": "string",
                      "enum": ["active", "missing", "deleted"],
                      "description": "The document's state. `active`: in the knowledge base. `missing`: several crawls in a row didn't find the page, but it stays in the knowledge base until you delete or keep it. `deleted`: removed from the source, or by you."
                    },
                    "mime": {
                      "nullable": true,
                      "description": "The media type of the document as read. `null` before its content was read.",
                      "type": "string"
                    },
                    "sizeBytes": {
                      "nullable": true,
                      "description": "The size of the document as read, in bytes. `null` before its content was read.",
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "conversion": {
                      "type": "string",
                      "enum": ["pending", "converted", "unsupported", "oversized", "failed"],
                      "description": "How far the current content got through conversion to markdown, the text builds read and cite. `pending`: not converted yet. `converted`: ready. `unsupported`: the file type has no converter. `oversized`: too large to convert. `failed`: conversion failed, see `conversionError`."
                    },
                    "conversionError": {
                      "nullable": true,
                      "description": "Why conversion failed. `null` unless `conversion` is `failed` or `oversized`.",
                      "type": "string"
                    },
                    "excludedAt": {
                      "nullable": true,
                      "description": "When a build left the document out because the organization's source chunk limit had no room for it. No build reads it until a later build finds room, which includes it automatically. `null` while builds include it.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "documentUpdatedAt": {
                      "nullable": true,
                      "description": "When the document says it was last updated: from a page's meta tags, a file's own metadata, or a dataset document's `_updatedAt`. `null` when it doesn't say.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "lastSeenAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When a sync last found the document in its source."
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the document was first read."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the document last changed."
                    },
                    "chunks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                            "description": "The chunk's ID. Entry citations point at it."
                          },
                          "headingPath": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "description": "The headings above the chunk, outermost first. Empty before the first heading."
                          },
                          "lineStart": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The chunk's first line in the markdown, from 1."
                          },
                          "lineEnd": {
                            "type": "integer",
                            "minimum": -9007199254740991,
                            "maximum": 9007199254740991,
                            "description": "The chunk's last line in the markdown, inclusive."
                          }
                        },
                        "required": ["id", "headingPath", "lineStart", "lineEnd"],
                        "description": "A section of a document's markdown, cut at headings."
                      },
                      "description": "The chunks of the document's current markdown, in order. Empty until `conversion` is `converted`."
                    }
                  },
                  "required": [
                    "id",
                    "sourceId",
                    "sourceType",
                    "externalId",
                    "title",
                    "url",
                    "state",
                    "mime",
                    "sizeBytes",
                    "conversion",
                    "conversionError",
                    "excludedAt",
                    "documentUpdatedAt",
                    "lastSeenAt",
                    "createdAt",
                    "updatedAt",
                    "chunks"
                  ],
                  "description": "A document with the chunks of its markdown."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateDocument",
        "summary": "Keep a missing document",
        "tags": ["documents"],
        "description": "Keeps a `missing` web page in the knowledge base by setting its `state` back to `active`. A document that isn't `missing` returns `409` with code `documentInvalidState`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": ["active"],
                    "description": "Set to `active` to keep a `missing` page in the knowledge base. The count of crawls that missed it starts again."
                  }
                },
                "required": ["state"],
                "description": "The changes to make to a document."
              }
            }
          },
          "description": "The changes to make to a document."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "documentId",
            "required": true,
            "description": "The document's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "One page, dataset document or file that a source yields.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The document's ID. Entry citations point at it."
                    },
                    "sourceId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The ID of the source the document comes from."
                    },
                    "sourceType": {
                      "type": "string",
                      "enum": ["web", "sanity-dataset", "files"],
                      "description": "The type of the source the document comes from."
                    },
                    "externalId": {
                      "type": "string",
                      "description": "The document's identity in its source: the page URL, the dataset document `_id`, or the file's path in the upload."
                    },
                    "title": {
                      "type": "string",
                      "description": "The document's title, or its `externalId` when it has none."
                    },
                    "url": {
                      "nullable": true,
                      "description": "Where the document lives on the web. `null` for files and dataset documents.",
                      "type": "string"
                    },
                    "state": {
                      "type": "string",
                      "enum": ["active", "missing", "deleted"],
                      "description": "The document's state. `active`: in the knowledge base. `missing`: several crawls in a row didn't find the page, but it stays in the knowledge base until you delete or keep it. `deleted`: removed from the source, or by you."
                    },
                    "mime": {
                      "nullable": true,
                      "description": "The media type of the document as read. `null` before its content was read.",
                      "type": "string"
                    },
                    "sizeBytes": {
                      "nullable": true,
                      "description": "The size of the document as read, in bytes. `null` before its content was read.",
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991
                    },
                    "conversion": {
                      "type": "string",
                      "enum": ["pending", "converted", "unsupported", "oversized", "failed"],
                      "description": "How far the current content got through conversion to markdown, the text builds read and cite. `pending`: not converted yet. `converted`: ready. `unsupported`: the file type has no converter. `oversized`: too large to convert. `failed`: conversion failed, see `conversionError`."
                    },
                    "conversionError": {
                      "nullable": true,
                      "description": "Why conversion failed. `null` unless `conversion` is `failed` or `oversized`.",
                      "type": "string"
                    },
                    "excludedAt": {
                      "nullable": true,
                      "description": "When a build left the document out because the organization's source chunk limit had no room for it. No build reads it until a later build finds room, which includes it automatically. `null` while builds include it.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "documentUpdatedAt": {
                      "nullable": true,
                      "description": "When the document says it was last updated: from a page's meta tags, a file's own metadata, or a dataset document's `_updatedAt`. `null` when it doesn't say.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "lastSeenAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When a sync last found the document in its source."
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the document was first read."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the document last changed."
                    }
                  },
                  "required": [
                    "id",
                    "sourceId",
                    "sourceType",
                    "externalId",
                    "title",
                    "url",
                    "state",
                    "mime",
                    "sizeBytes",
                    "conversion",
                    "conversionError",
                    "excludedAt",
                    "documentUpdatedAt",
                    "lastSeenAt",
                    "createdAt",
                    "updatedAt"
                  ],
                  "description": "One page, dataset document or file that a source yields."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteDocument",
        "summary": "Delete a document",
        "tags": ["documents"],
        "description": "Deletes a document from its source. A page that is still on the website comes back on the next sync of its source unless the crawl options exclude it. Entries that cite the document stay the same until the next build or refresh, which removes the citations.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "documentId",
            "required": true,
            "description": "The document's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "204": {
            "description": "The document was deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "nullable": true,
                  "enum": [null],
                  "description": "The document was deleted."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}/content": {
      "get": {
        "operationId": "getDocumentContent",
        "summary": "Get a document's markdown",
        "tags": ["documents"],
        "description": "Returns the markdown a document converted to: the text builds read, and the line numbers citations use. Set `chunk` or `lines` to get part of it, and `format` to `markdown` or `plain` to get the text alone instead of JSON. Until the document is converted, the request returns `409` with code `documentNotConverted`. With `format=raw` it returns the document as its source gave it, as an attachment, or `409` with code `documentNotStored` when the document was too large to keep.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": ["json", "markdown", "plain", "raw"]
            },
            "in": "query",
            "name": "format",
            "required": false,
            "description": "Response format. `json` (default) returns the markdown with its line numbers. `markdown` and `plain` return the markdown alone, ready to pass to a model. `raw` returns the bytes the source gave, before conversion: the uploaded file, the crawled page, the dataset document as JSON."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "query",
            "name": "chunk",
            "required": false,
            "description": "Return only this chunk's lines. Citations name the chunk they quote."
          },
          {
            "schema": {
              "type": "string",
              "pattern": "^\\d+(-\\d+)?$"
            },
            "in": "query",
            "name": "lines",
            "required": false,
            "description": "Return only these lines, from 1 and inclusive: `10-20`, or `10` for line 10 to the end. A range past the end returns up to the last line."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "in": "path",
            "name": "documentId",
            "required": true,
            "description": "The document's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A document's markdown, or a range of its lines.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "documentId": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                      "description": "The document's ID."
                    },
                    "chunkId": {
                      "nullable": true,
                      "description": "The chunk the content was limited to. `null` when no `chunk` was requested.",
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "content": {
                      "type": "string",
                      "description": "The document's markdown, or the requested lines of it."
                    },
                    "totalLines": {
                      "type": "integer",
                      "minimum": -9007199254740991,
                      "maximum": 9007199254740991,
                      "description": "The number of lines in the whole markdown."
                    },
                    "slice": {
                      "type": "object",
                      "properties": {
                        "start": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The first line returned."
                        },
                        "end": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991,
                          "description": "The last line returned."
                        }
                      },
                      "required": ["start", "end"],
                      "description": "The lines returned, from 1 and inclusive. Shorter than requested when the range runs past the end. Both are `0` when no lines are returned."
                    }
                  },
                  "required": ["documentId", "chunkId", "content", "totalLines", "slice"],
                  "description": "A document's markdown, or a range of its lines."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/entries/{entryPath}/rebuild": {
      "post": {
        "operationId": "rebuildEntry",
        "summary": "Rebuild an entry from its sources",
        "tags": ["entries"],
        "description": "Queues a rewrite of the entry at `entryPath` from its cited sources and the active instructions, and returns a job ID immediately. The response also lists the other entries built from any of the same sources. An instruction applies to every entry built from its sources, so those entries can change too. Returns `422` with code `entryDocumentInvalid` if the entry document was edited into a shape the API cannot read.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "entryPath",
            "required": true,
            "description": "The entry's slash-delimited path, such as `pricing/plans/free`, URL-encoded."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "202": {
            "description": "The job that rebuilds the entry, and the other entries that share its sources.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jobId": {
                      "type": "string",
                      "description": "ID of the job that rebuilds the entry. Poll it with `GET .../jobs/{jobId}`."
                    },
                    "affectedEntries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "The entry's document ID."
                          },
                          "path": {
                            "type": "string",
                            "description": "The entry's path, such as `products/api/webhooks`."
                          },
                          "title": {
                            "type": "string",
                            "description": "The entry's title."
                          }
                        },
                        "required": ["id", "path", "title"],
                        "description": "Another entry that cites one of the same sources as the rebuilt entry."
                      },
                      "description": "Other entries built from any of this entry's sources. An instruction applies to every entry built from its sources, so these entries can change when they are next rebuilt."
                    }
                  },
                  "required": ["jobId", "affectedEntries"],
                  "description": "The job that rebuilds the entry, and the other entries that share its sources."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/jobs/{jobId}": {
      "get": {
        "operationId": "getJob",
        "summary": "Get a job",
        "tags": ["jobs"],
        "description": "Returns the status of a background job, such as a build, sync, or refresh. The endpoint that starts the work returns the job ID. A job cancelled before it started never ran, so it returns 404.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "jobId",
            "required": true,
            "description": "The job ID returned by the endpoint that started the work."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A background job, such as a build, an update or a sync, and its status. `kind` says which, and determines the shape of `result`.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "The job's ID. Treat it as an opaque string. Its format can change."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the job belongs to."
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "queued",
                            "running",
                            "succeeded",
                            "failed",
                            "cancelled"
                          ],
                          "description": "The job's status. `queued`: waiting for build capacity. `running`: in progress. `succeeded`: finished successfully. `failed`: stopped with an error. `cancelled`: stopped before it finished. `pending` isn't currently returned."
                        },
                        "startedAt": {
                          "nullable": true,
                          "description": "When the job started.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "completedAt": {
                          "nullable": true,
                          "description": "When the job finished. `null` while the job is queued or running.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "error": {
                          "description": "A readable reason the job failed or was cancelled. `null` for any other status.",
                          "nullable": true,
                          "type": "string"
                        },
                        "kind": {
                          "type": "string",
                          "enum": ["build"]
                        },
                        "result": {
                          "description": "The job's output. Only present when `status` is `succeeded`.",
                          "type": "object",
                          "properties": {
                            "revisionId": {
                              "type": "string",
                              "description": "The revision the build produced."
                            },
                            "entryCount": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991,
                              "description": "How many entries the built outline has."
                            },
                            "issuesCreated": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991,
                              "description": "How many issues the build filed."
                            },
                            "criticalIssueCount": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991,
                              "description": "How many of those issues are critical."
                            }
                          },
                          "required": [
                            "revisionId",
                            "entryCount",
                            "issuesCreated",
                            "criticalIssueCount"
                          ]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "status",
                        "startedAt",
                        "completedAt",
                        "kind"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "The job's ID. Treat it as an opaque string. Its format can change."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the job belongs to."
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "queued",
                            "running",
                            "succeeded",
                            "failed",
                            "cancelled"
                          ],
                          "description": "The job's status. `queued`: waiting for build capacity. `running`: in progress. `succeeded`: finished successfully. `failed`: stopped with an error. `cancelled`: stopped before it finished. `pending` isn't currently returned."
                        },
                        "startedAt": {
                          "nullable": true,
                          "description": "When the job started.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "completedAt": {
                          "nullable": true,
                          "description": "When the job finished. `null` while the job is queued or running.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "error": {
                          "description": "A readable reason the job failed or was cancelled. `null` for any other status.",
                          "nullable": true,
                          "type": "string"
                        },
                        "kind": {
                          "type": "string",
                          "enum": ["update"]
                        },
                        "result": {
                          "description": "The job's output. Only present when `status` is `succeeded`.",
                          "type": "object",
                          "properties": {
                            "revisionId": {
                              "nullable": true,
                              "description": "The revision the update produced. `null` when no entry changed.",
                              "type": "string"
                            },
                            "entriesRewritten": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991,
                              "description": "How many entries were rewritten."
                            }
                          },
                          "required": ["revisionId", "entriesRewritten"]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "status",
                        "startedAt",
                        "completedAt",
                        "kind"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "The job's ID. Treat it as an opaque string. Its format can change."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb…`) of the knowledge base the job belongs to."
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "pending",
                            "queued",
                            "running",
                            "succeeded",
                            "failed",
                            "cancelled"
                          ],
                          "description": "The job's status. `queued`: waiting for build capacity. `running`: in progress. `succeeded`: finished successfully. `failed`: stopped with an error. `cancelled`: stopped before it finished. `pending` isn't currently returned."
                        },
                        "startedAt": {
                          "nullable": true,
                          "description": "When the job started.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "completedAt": {
                          "nullable": true,
                          "description": "When the job finished. `null` while the job is queued or running.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "error": {
                          "description": "A readable reason the job failed or was cancelled. `null` for any other status.",
                          "nullable": true,
                          "type": "string"
                        },
                        "kind": {
                          "type": "string",
                          "enum": ["sync"]
                        },
                        "result": {
                          "description": "The job's output. Only present when `status` is `succeeded`. A job can succeed with its sync `held`: check `result.status`.",
                          "type": "object",
                          "properties": {
                            "sourceId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the source the job synced."
                            },
                            "syncId": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                              "description": "The ID of the sync the job ran. Follow it with `GET .../sources/{sourceId}/syncs/{syncId}`."
                            },
                            "status": {
                              "type": "string",
                              "enum": ["completed", "held"],
                              "description": "The sync's status when the job finished. `completed`: the sync applied every change. `held`: the sync would delete many documents and waits for you to confirm or discard the deletion (`POST .../syncs/{syncId}/confirm` or `.../discard`). The sync's own `status` shows whether that has happened since."
                            },
                            "heldDeletions": {
                              "nullable": true,
                              "description": "How many documents the held deletion would remove. `null` unless `status` is `held`.",
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": ["sourceId", "syncId", "status", "heldDeletions"]
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "status",
                        "startedAt",
                        "completedAt",
                        "kind"
                      ]
                    }
                  ],
                  "description": "A background job, such as a build, an update or a sync, and its status. `kind` says which, and determines the shape of `result`."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/issues/apply": {
      "post": {
        "operationId": "applyIssues",
        "summary": "Accept and apply issues",
        "tags": ["issues"],
        "description": "Accepts the issues in `issueIds`, then queues a job that applies them, rewrites the affected entries, and saves a new revision. Returns a job ID. IDs of issues that no longer exist are skipped. Returns `409` with code `issueNotAutoApplicable`, and accepts none of the issues, if any of them cannot be applied: a `conflict` (resolve it with `POST .../issues/{issueId}/resolve`), or an `update_required` issue whose `scopePath` is `*` or names an entry that no longer exists. Dismiss those instead.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "issueIds": {
                    "minItems": 1,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1
                    },
                    "description": "The IDs of the issues to accept and apply."
                  }
                },
                "required": ["issueIds"]
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "202": {
            "description": "A queued job that you can poll for progress.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jobId": {
                      "type": "string",
                      "description": "The queued job's ID. Check its progress with `GET .../jobs/{jobId}`. Treat it as an opaque string. Its format can change."
                    }
                  },
                  "required": ["jobId"],
                  "description": "A queued job that you can poll for progress."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/dismiss": {
      "post": {
        "operationId": "dismissIssue",
        "summary": "Dismiss an issue",
        "tags": ["issues"],
        "description": "Marks the issue as rejected. If the issue already left triage, the request returns it unchanged. Returns `422` with code `issueDocumentInvalid` if the issue document was edited into a shape the API cannot verify. Returns `409` with code `issueTransitionConflict` if another change to the issue happened at the same time. You can safely retry a `409`.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "issueId",
            "required": true,
            "description": "The issue's document ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "An issue found in a knowledge base, and its triage status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The issue's document ID. A later build that finds the same issue in unchanged sources reuses this ID, so your triage decision is kept."
                    },
                    "knowledgeBaseId": {
                      "type": "string",
                      "description": "The ID (`kb...`) of the knowledge base the issue belongs to."
                    },
                    "content": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "severity": {
                              "type": "string",
                              "enum": ["critical", "suggestion"],
                              "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                            },
                            "scopePath": {
                              "type": "string",
                              "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                            },
                            "issue": {
                              "type": "string",
                              "description": "What the problem is, in one or two sentences."
                            },
                            "suggestedFix": {
                              "type": "string",
                              "description": "What to do to fix the issue."
                            },
                            "kind": {
                              "type": "string",
                              "enum": ["conflict"],
                              "description": "The issue type. `conflict` means two or more positions disagree on the same fact, and you choose which one is correct."
                            },
                            "claimKey": {
                              "type": "string",
                              "description": "A key naming the disputed fact, such as `free_tier.request_limit`. It never includes the disputed value, so every side shares it."
                            },
                            "context": {
                              "description": "One sentence that explains the question, when it needs one.",
                              "type": "string"
                            },
                            "sides": {
                              "minItems": 2,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "claim": {
                                    "type": "string",
                                    "description": "The position as a self-contained sentence. This is the option you choose from."
                                  },
                                  "value": {
                                    "description": "The disputed value on its own, such as `10,000/month`, without the sentence.",
                                    "type": "string"
                                  },
                                  "entryPaths": {
                                    "description": "Paths of the entries that state this position.",
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "documentIds": {
                                    "description": "IDs of the documents that directly back this position.",
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "where": {
                                    "description": "The documents that state this value, by the names you know them by.",
                                    "type": "string"
                                  },
                                  "citations": {
                                    "description": "Quotes from the documents that state this value, copied word for word and checked against each document. A document whose wording could not be checked has none.",
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "_key": {
                                          "type": "string",
                                          "pattern": "^[a-z2-7]{10}$",
                                          "description": "Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a `[^key]` marker."
                                        },
                                        "_type": {
                                          "type": "string",
                                          "enum": ["sanity.context.citation"]
                                        },
                                        "documentId": {
                                          "type": "string",
                                          "description": "ID of the document the quote comes from. Read it with `GET .../documents/{documentId}/content`."
                                        },
                                        "chunkId": {
                                          "type": "string",
                                          "minLength": 1,
                                          "description": "ID of the chunk of the document that holds the quote's first line. A chunk is the text under one heading, and keeps its ID across versions of the document while its headings stay the same."
                                        },
                                        "title": {
                                          "type": "string",
                                          "description": "The document's name when the entry was written."
                                        },
                                        "url": {
                                          "description": "Where the document lives on the web. Absent for uploaded files and datasets.",
                                          "type": "string"
                                        },
                                        "quote": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 300,
                                          "description": "The passage from the document that backs the claims, copied word for word."
                                        },
                                        "prefix": {
                                          "type": "string",
                                          "maxLength": 32,
                                          "description": "Up to 32 characters of document text just before the quote, to tell repeats apart."
                                        },
                                        "suffix": {
                                          "type": "string",
                                          "maxLength": 32,
                                          "description": "Up to 32 characters of document text just after the quote, to tell repeats apart."
                                        },
                                        "lineStart": {
                                          "type": "integer",
                                          "minimum": 1,
                                          "maximum": 9007199254740991,
                                          "description": "First line of the quote in the document, counting from 1. Line numbers match `GET .../documents/{documentId}/content`. A hint: the quote is the stable locator."
                                        },
                                        "lineEnd": {
                                          "type": "integer",
                                          "minimum": 1,
                                          "maximum": 9007199254740991,
                                          "description": "Last line of the quote, inclusive."
                                        }
                                      },
                                      "required": [
                                        "_key",
                                        "_type",
                                        "documentId",
                                        "chunkId",
                                        "title",
                                        "quote",
                                        "prefix",
                                        "suffix",
                                        "lineStart",
                                        "lineEnd"
                                      ]
                                    }
                                  },
                                  "authority": {
                                    "description": "How much weight the sources behind this position carry. `primary`: your own content, such as uploaded files and pages on your own site. `secondary`: other sources. `community`: forums and Q&A sites.",
                                    "type": "string",
                                    "enum": ["primary", "secondary", "community"]
                                  }
                                },
                                "required": ["claim"],
                                "description": "One position in a conflict, and the entries and documents it comes from."
                              },
                              "description": "The conflicting positions, at least two. To resolve the conflict, pass the index of one side as `resolution`."
                            },
                            "suggested": {
                              "description": "Index in `sides` of the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.",
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": [
                            "severity",
                            "scopePath",
                            "issue",
                            "suggestedFix",
                            "kind",
                            "claimKey",
                            "sides"
                          ],
                          "description": "A conflict: two or more positions disagree on the same fact, and you choose which one is correct."
                        },
                        {
                          "type": "object",
                          "properties": {
                            "severity": {
                              "type": "string",
                              "enum": ["critical", "suggestion"],
                              "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                            },
                            "scopePath": {
                              "type": "string",
                              "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                            },
                            "issue": {
                              "type": "string",
                              "description": "What the problem is, in one or two sentences."
                            },
                            "suggestedFix": {
                              "type": "string",
                              "description": "What to do to fix the issue."
                            },
                            "kind": {
                              "type": "string",
                              "enum": ["update_required"],
                              "description": "The issue type. `update_required` means an entry is out of date with its sources or contradicts an instruction, and needs a rewrite."
                            },
                            "citedDocumentIds": {
                              "description": "IDs of the documents that led to the issue.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "claimKey": {
                              "description": "A key naming the specific finding, when the check that found it sets one.",
                              "type": "string"
                            },
                            "involvedScopes": {
                              "description": "Paths of the entries the issue involves, when it spans more than one entry.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": ["severity", "scopePath", "issue", "suggestedFix", "kind"],
                          "description": "An entry that needs a rewrite: it is out of date with its sources or contradicts an instruction."
                        }
                      ],
                      "description": "What the issue found. The shape depends on `kind`."
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "accepted", "rejected"],
                      "description": "The triage status. `open`: waiting for triage. `accepted`: accepted with `POST .../issues/apply`, or a conflict resolved to one side. `rejected`: dismissed. A rejected issue stays rejected. You can return an accepted conflict to `open` with `POST .../issues/{issueId}/reopen`."
                    },
                    "resolution": {
                      "nullable": true,
                      "description": "Index in `content.sides` of the side chosen when the conflict was resolved. For a conflict on a single entry, index `0` is the entry's current content. `null` until a conflict is resolved, and always `null` for other issue types.",
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "resolvedBy": {
                      "nullable": true,
                      "description": "Who triaged the issue, so you can review what your agents decided. `null` while the issue is open, or when the caller could not be identified.",
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Sanity user ID of the person or robot that triaged the issue."
                        },
                        "kind": {
                          "type": "string",
                          "enum": ["user", "robot"],
                          "description": "`user` when a person made the decision. `robot` when a robot token did, such as an agent."
                        }
                      },
                      "required": ["id", "kind"]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the issue was first filed."
                    },
                    "resolvedAt": {
                      "nullable": true,
                      "description": "When the issue left `open`. `null` while the issue is open.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "knowledgeBaseId",
                    "content",
                    "status",
                    "resolution",
                    "resolvedBy",
                    "createdAt",
                    "resolvedAt"
                  ],
                  "description": "An issue found in a knowledge base, and its triage status."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/resolve": {
      "post": {
        "operationId": "resolveIssue",
        "summary": "Resolve a conflict issue",
        "tags": ["issues"],
        "description": "Resolves a conflict issue by choosing one of its sides. Set `resolution` to the index of a side in `content.sides`. For a conflict on a single entry, index `0` is the entry's current content, so choosing it keeps the entry as it is. Choosing any other side rewrites the entry, and the returned `jobId` tracks the rewrite. The decision becomes a standing instruction for every future build, and `resolvedBy` records who made it. To change a decision, resolve the accepted conflict again. Other issue types, dismissed conflicts, and out-of-range indexes return `422` with code `issueNotResolvable`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "resolution": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9007199254740991,
                    "description": "The index of the chosen side in the issue's `content.sides`."
                  }
                },
                "required": ["resolution"]
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "issueId",
            "required": true,
            "description": "The issue's document ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "The resolved issue, plus the job that rewrites the entry when the decision changes it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "issue": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "The issue's document ID. A later build that finds the same issue in unchanged sources reuses this ID, so your triage decision is kept."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb...`) of the knowledge base the issue belongs to."
                        },
                        "content": {
                          "oneOf": [
                            {
                              "type": "object",
                              "properties": {
                                "severity": {
                                  "type": "string",
                                  "enum": ["critical", "suggestion"],
                                  "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                                },
                                "scopePath": {
                                  "type": "string",
                                  "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                                },
                                "issue": {
                                  "type": "string",
                                  "description": "What the problem is, in one or two sentences."
                                },
                                "suggestedFix": {
                                  "type": "string",
                                  "description": "What to do to fix the issue."
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": ["conflict"],
                                  "description": "The issue type. `conflict` means two or more positions disagree on the same fact, and you choose which one is correct."
                                },
                                "claimKey": {
                                  "type": "string",
                                  "description": "A key naming the disputed fact, such as `free_tier.request_limit`. It never includes the disputed value, so every side shares it."
                                },
                                "context": {
                                  "description": "One sentence that explains the question, when it needs one.",
                                  "type": "string"
                                },
                                "sides": {
                                  "minItems": 2,
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "claim": {
                                        "type": "string",
                                        "description": "The position as a self-contained sentence. This is the option you choose from."
                                      },
                                      "value": {
                                        "description": "The disputed value on its own, such as `10,000/month`, without the sentence.",
                                        "type": "string"
                                      },
                                      "entryPaths": {
                                        "description": "Paths of the entries that state this position.",
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      },
                                      "documentIds": {
                                        "description": "IDs of the documents that directly back this position.",
                                        "type": "array",
                                        "items": {
                                          "type": "string"
                                        }
                                      },
                                      "where": {
                                        "description": "The documents that state this value, by the names you know them by.",
                                        "type": "string"
                                      },
                                      "citations": {
                                        "description": "Quotes from the documents that state this value, copied word for word and checked against each document. A document whose wording could not be checked has none.",
                                        "type": "array",
                                        "items": {
                                          "type": "object",
                                          "properties": {
                                            "_key": {
                                              "type": "string",
                                              "pattern": "^[a-z2-7]{10}$",
                                              "description": "Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a `[^key]` marker."
                                            },
                                            "_type": {
                                              "type": "string",
                                              "enum": ["sanity.context.citation"]
                                            },
                                            "documentId": {
                                              "type": "string",
                                              "description": "ID of the document the quote comes from. Read it with `GET .../documents/{documentId}/content`."
                                            },
                                            "chunkId": {
                                              "type": "string",
                                              "minLength": 1,
                                              "description": "ID of the chunk of the document that holds the quote's first line. A chunk is the text under one heading, and keeps its ID across versions of the document while its headings stay the same."
                                            },
                                            "title": {
                                              "type": "string",
                                              "description": "The document's name when the entry was written."
                                            },
                                            "url": {
                                              "description": "Where the document lives on the web. Absent for uploaded files and datasets.",
                                              "type": "string"
                                            },
                                            "quote": {
                                              "type": "string",
                                              "minLength": 1,
                                              "maxLength": 300,
                                              "description": "The passage from the document that backs the claims, copied word for word."
                                            },
                                            "prefix": {
                                              "type": "string",
                                              "maxLength": 32,
                                              "description": "Up to 32 characters of document text just before the quote, to tell repeats apart."
                                            },
                                            "suffix": {
                                              "type": "string",
                                              "maxLength": 32,
                                              "description": "Up to 32 characters of document text just after the quote, to tell repeats apart."
                                            },
                                            "lineStart": {
                                              "type": "integer",
                                              "minimum": 1,
                                              "maximum": 9007199254740991,
                                              "description": "First line of the quote in the document, counting from 1. Line numbers match `GET .../documents/{documentId}/content`. A hint: the quote is the stable locator."
                                            },
                                            "lineEnd": {
                                              "type": "integer",
                                              "minimum": 1,
                                              "maximum": 9007199254740991,
                                              "description": "Last line of the quote, inclusive."
                                            }
                                          },
                                          "required": [
                                            "_key",
                                            "_type",
                                            "documentId",
                                            "chunkId",
                                            "title",
                                            "quote",
                                            "prefix",
                                            "suffix",
                                            "lineStart",
                                            "lineEnd"
                                          ]
                                        }
                                      },
                                      "authority": {
                                        "description": "How much weight the sources behind this position carry. `primary`: your own content, such as uploaded files and pages on your own site. `secondary`: other sources. `community`: forums and Q&A sites.",
                                        "type": "string",
                                        "enum": ["primary", "secondary", "community"]
                                      }
                                    },
                                    "required": ["claim"],
                                    "description": "One position in a conflict, and the entries and documents it comes from."
                                  },
                                  "description": "The conflicting positions, at least two. To resolve the conflict, pass the index of one side as `resolution`."
                                },
                                "suggested": {
                                  "description": "Index in `sides` of the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.",
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                }
                              },
                              "required": [
                                "severity",
                                "scopePath",
                                "issue",
                                "suggestedFix",
                                "kind",
                                "claimKey",
                                "sides"
                              ],
                              "description": "A conflict: two or more positions disagree on the same fact, and you choose which one is correct."
                            },
                            {
                              "type": "object",
                              "properties": {
                                "severity": {
                                  "type": "string",
                                  "enum": ["critical", "suggestion"],
                                  "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                                },
                                "scopePath": {
                                  "type": "string",
                                  "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                                },
                                "issue": {
                                  "type": "string",
                                  "description": "What the problem is, in one or two sentences."
                                },
                                "suggestedFix": {
                                  "type": "string",
                                  "description": "What to do to fix the issue."
                                },
                                "kind": {
                                  "type": "string",
                                  "enum": ["update_required"],
                                  "description": "The issue type. `update_required` means an entry is out of date with its sources or contradicts an instruction, and needs a rewrite."
                                },
                                "citedDocumentIds": {
                                  "description": "IDs of the documents that led to the issue.",
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                },
                                "claimKey": {
                                  "description": "A key naming the specific finding, when the check that found it sets one.",
                                  "type": "string"
                                },
                                "involvedScopes": {
                                  "description": "Paths of the entries the issue involves, when it spans more than one entry.",
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  }
                                }
                              },
                              "required": [
                                "severity",
                                "scopePath",
                                "issue",
                                "suggestedFix",
                                "kind"
                              ],
                              "description": "An entry that needs a rewrite: it is out of date with its sources or contradicts an instruction."
                            }
                          ],
                          "description": "What the issue found. The shape depends on `kind`."
                        },
                        "status": {
                          "type": "string",
                          "enum": ["open", "accepted", "rejected"],
                          "description": "The triage status. `open`: waiting for triage. `accepted`: accepted with `POST .../issues/apply`, or a conflict resolved to one side. `rejected`: dismissed. A rejected issue stays rejected. You can return an accepted conflict to `open` with `POST .../issues/{issueId}/reopen`."
                        },
                        "resolution": {
                          "nullable": true,
                          "description": "Index in `content.sides` of the side chosen when the conflict was resolved. For a conflict on a single entry, index `0` is the entry's current content. `null` until a conflict is resolved, and always `null` for other issue types.",
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 9007199254740991
                        },
                        "resolvedBy": {
                          "nullable": true,
                          "description": "Who triaged the issue, so you can review what your agents decided. `null` while the issue is open, or when the caller could not be identified.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string",
                              "description": "Sanity user ID of the person or robot that triaged the issue."
                            },
                            "kind": {
                              "type": "string",
                              "enum": ["user", "robot"],
                              "description": "`user` when a person made the decision. `robot` when a robot token did, such as an agent."
                            }
                          },
                          "required": ["id", "kind"]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the issue was first filed."
                        },
                        "resolvedAt": {
                          "nullable": true,
                          "description": "When the issue left `open`. `null` while the issue is open.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "content",
                        "status",
                        "resolution",
                        "resolvedBy",
                        "createdAt",
                        "resolvedAt"
                      ],
                      "description": "The resolved conflict issue, now `accepted`."
                    },
                    "jobId": {
                      "nullable": true,
                      "description": "ID of the job that rewrites the entry to match the chosen side. Poll it with `GET .../jobs/{jobId}`. `null` when nothing is rewritten: you chose index `0`, or the conflict applies to the whole knowledge base.",
                      "type": "string"
                    }
                  },
                  "required": ["issue", "jobId"],
                  "description": "The resolved issue, plus the job that rewrites the entry when the decision changes it."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/reopen": {
      "post": {
        "operationId": "reopenIssue",
        "summary": "Reopen an accepted conflict",
        "tags": ["issues"],
        "description": "Returns an accepted conflict issue to triage, clears its resolution, and deletes the instruction the resolution created. Reopening an open or dismissed conflict returns it unchanged. Other issue types return `422` with code `issueNotResolvable`.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "issueId",
            "required": true,
            "description": "The issue's document ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "An issue found in a knowledge base, and its triage status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The issue's document ID. A later build that finds the same issue in unchanged sources reuses this ID, so your triage decision is kept."
                    },
                    "knowledgeBaseId": {
                      "type": "string",
                      "description": "The ID (`kb...`) of the knowledge base the issue belongs to."
                    },
                    "content": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "severity": {
                              "type": "string",
                              "enum": ["critical", "suggestion"],
                              "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                            },
                            "scopePath": {
                              "type": "string",
                              "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                            },
                            "issue": {
                              "type": "string",
                              "description": "What the problem is, in one or two sentences."
                            },
                            "suggestedFix": {
                              "type": "string",
                              "description": "What to do to fix the issue."
                            },
                            "kind": {
                              "type": "string",
                              "enum": ["conflict"],
                              "description": "The issue type. `conflict` means two or more positions disagree on the same fact, and you choose which one is correct."
                            },
                            "claimKey": {
                              "type": "string",
                              "description": "A key naming the disputed fact, such as `free_tier.request_limit`. It never includes the disputed value, so every side shares it."
                            },
                            "context": {
                              "description": "One sentence that explains the question, when it needs one.",
                              "type": "string"
                            },
                            "sides": {
                              "minItems": 2,
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "claim": {
                                    "type": "string",
                                    "description": "The position as a self-contained sentence. This is the option you choose from."
                                  },
                                  "value": {
                                    "description": "The disputed value on its own, such as `10,000/month`, without the sentence.",
                                    "type": "string"
                                  },
                                  "entryPaths": {
                                    "description": "Paths of the entries that state this position.",
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "documentIds": {
                                    "description": "IDs of the documents that directly back this position.",
                                    "type": "array",
                                    "items": {
                                      "type": "string"
                                    }
                                  },
                                  "where": {
                                    "description": "The documents that state this value, by the names you know them by.",
                                    "type": "string"
                                  },
                                  "citations": {
                                    "description": "Quotes from the documents that state this value, copied word for word and checked against each document. A document whose wording could not be checked has none.",
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "_key": {
                                          "type": "string",
                                          "pattern": "^[a-z2-7]{10}$",
                                          "description": "Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a `[^key]` marker."
                                        },
                                        "_type": {
                                          "type": "string",
                                          "enum": ["sanity.context.citation"]
                                        },
                                        "documentId": {
                                          "type": "string",
                                          "description": "ID of the document the quote comes from. Read it with `GET .../documents/{documentId}/content`."
                                        },
                                        "chunkId": {
                                          "type": "string",
                                          "minLength": 1,
                                          "description": "ID of the chunk of the document that holds the quote's first line. A chunk is the text under one heading, and keeps its ID across versions of the document while its headings stay the same."
                                        },
                                        "title": {
                                          "type": "string",
                                          "description": "The document's name when the entry was written."
                                        },
                                        "url": {
                                          "description": "Where the document lives on the web. Absent for uploaded files and datasets.",
                                          "type": "string"
                                        },
                                        "quote": {
                                          "type": "string",
                                          "minLength": 1,
                                          "maxLength": 300,
                                          "description": "The passage from the document that backs the claims, copied word for word."
                                        },
                                        "prefix": {
                                          "type": "string",
                                          "maxLength": 32,
                                          "description": "Up to 32 characters of document text just before the quote, to tell repeats apart."
                                        },
                                        "suffix": {
                                          "type": "string",
                                          "maxLength": 32,
                                          "description": "Up to 32 characters of document text just after the quote, to tell repeats apart."
                                        },
                                        "lineStart": {
                                          "type": "integer",
                                          "minimum": 1,
                                          "maximum": 9007199254740991,
                                          "description": "First line of the quote in the document, counting from 1. Line numbers match `GET .../documents/{documentId}/content`. A hint: the quote is the stable locator."
                                        },
                                        "lineEnd": {
                                          "type": "integer",
                                          "minimum": 1,
                                          "maximum": 9007199254740991,
                                          "description": "Last line of the quote, inclusive."
                                        }
                                      },
                                      "required": [
                                        "_key",
                                        "_type",
                                        "documentId",
                                        "chunkId",
                                        "title",
                                        "quote",
                                        "prefix",
                                        "suffix",
                                        "lineStart",
                                        "lineEnd"
                                      ]
                                    }
                                  },
                                  "authority": {
                                    "description": "How much weight the sources behind this position carry. `primary`: your own content, such as uploaded files and pages on your own site. `secondary`: other sources. `community`: forums and Q&A sites.",
                                    "type": "string",
                                    "enum": ["primary", "secondary", "community"]
                                  }
                                },
                                "required": ["claim"],
                                "description": "One position in a conflict, and the entries and documents it comes from."
                              },
                              "description": "The conflicting positions, at least two. To resolve the conflict, pass the index of one side as `resolution`."
                            },
                            "suggested": {
                              "description": "Index in `sides` of the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.",
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 9007199254740991
                            }
                          },
                          "required": [
                            "severity",
                            "scopePath",
                            "issue",
                            "suggestedFix",
                            "kind",
                            "claimKey",
                            "sides"
                          ],
                          "description": "A conflict: two or more positions disagree on the same fact, and you choose which one is correct."
                        },
                        {
                          "type": "object",
                          "properties": {
                            "severity": {
                              "type": "string",
                              "enum": ["critical", "suggestion"],
                              "description": "How serious the issue is. `critical`: content is wrong or missing in a way that can mislead an agent. `suggestion`: a change that improves quality."
                            },
                            "scopePath": {
                              "type": "string",
                              "description": "Path of the entry the issue is about, or `*` when it applies to the whole knowledge base."
                            },
                            "issue": {
                              "type": "string",
                              "description": "What the problem is, in one or two sentences."
                            },
                            "suggestedFix": {
                              "type": "string",
                              "description": "What to do to fix the issue."
                            },
                            "kind": {
                              "type": "string",
                              "enum": ["update_required"],
                              "description": "The issue type. `update_required` means an entry is out of date with its sources or contradicts an instruction, and needs a rewrite."
                            },
                            "citedDocumentIds": {
                              "description": "IDs of the documents that led to the issue.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            },
                            "claimKey": {
                              "description": "A key naming the specific finding, when the check that found it sets one.",
                              "type": "string"
                            },
                            "involvedScopes": {
                              "description": "Paths of the entries the issue involves, when it spans more than one entry.",
                              "type": "array",
                              "items": {
                                "type": "string"
                              }
                            }
                          },
                          "required": ["severity", "scopePath", "issue", "suggestedFix", "kind"],
                          "description": "An entry that needs a rewrite: it is out of date with its sources or contradicts an instruction."
                        }
                      ],
                      "description": "What the issue found. The shape depends on `kind`."
                    },
                    "status": {
                      "type": "string",
                      "enum": ["open", "accepted", "rejected"],
                      "description": "The triage status. `open`: waiting for triage. `accepted`: accepted with `POST .../issues/apply`, or a conflict resolved to one side. `rejected`: dismissed. A rejected issue stays rejected. You can return an accepted conflict to `open` with `POST .../issues/{issueId}/reopen`."
                    },
                    "resolution": {
                      "nullable": true,
                      "description": "Index in `content.sides` of the side chosen when the conflict was resolved. For a conflict on a single entry, index `0` is the entry's current content. `null` until a conflict is resolved, and always `null` for other issue types.",
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991
                    },
                    "resolvedBy": {
                      "nullable": true,
                      "description": "Who triaged the issue, so you can review what your agents decided. `null` while the issue is open, or when the caller could not be identified.",
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "Sanity user ID of the person or robot that triaged the issue."
                        },
                        "kind": {
                          "type": "string",
                          "enum": ["user", "robot"],
                          "description": "`user` when a person made the decision. `robot` when a robot token did, such as an agent."
                        }
                      },
                      "required": ["id", "kind"]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the issue was first filed."
                    },
                    "resolvedAt": {
                      "nullable": true,
                      "description": "When the issue left `open`. `null` while the issue is open.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "knowledgeBaseId",
                    "content",
                    "status",
                    "resolution",
                    "resolvedBy",
                    "createdAt",
                    "resolvedAt"
                  ],
                  "description": "An issue found in a knowledge base, and its triage status."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructions": {
      "post": {
        "operationId": "createInstruction",
        "summary": "Create an instruction",
        "tags": ["instructions"],
        "description": "Creates a standing instruction for how entries built from its documents are written. Every instruction applies to specific documents, set in `scopeDocumentIds`. To rebuild entries under the new instruction right away, pass their paths in `rebuildPaths`. The response includes the rebuild job ID, or `null` if the rebuild could not start. The instruction is saved either way. After the instruction is saved, a background check files issues for entries that contradict it. If you already checked the instruction for contradictions, set `verified` to skip the background check. If the requested rebuild does not start, the background check runs even when `verified` is set.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "statement": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000,
                    "description": "The instruction in plain language. Builds follow it over what the sources say."
                  },
                  "scopeDocumentIds": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "description": "IDs of the documents the instruction applies to. Builds apply it when they write entries built from these documents. IDs of documents that no longer exist are dropped. If none exist, the request returns `422` with code `instructionScopeVanished`."
                  },
                  "rebuildPaths": {
                    "description": "Paths of entries to rebuild under the new instruction right away. The response returns the rebuild job ID in `rebuildJobId`.",
                    "minItems": 1,
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "verified": {
                    "description": "Whether you already checked the instruction for entries that contradict it. When `true`, the background check that files issues for those entries is skipped. It still runs if the rebuild you requested in `rebuildPaths` does not start.",
                    "type": "boolean"
                  }
                },
                "required": ["statement", "scopeDocumentIds"],
                "description": "The instruction to create, and any entries to rebuild under it."
              }
            }
          },
          "description": "The instruction to create, and any entries to rebuild under it."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "201": {
            "description": "The created instruction, and the rebuild it started.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "instruction": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "description": "The instruction's document ID."
                        },
                        "knowledgeBaseId": {
                          "type": "string",
                          "description": "The ID (`kb...`) of the knowledge base the instruction belongs to."
                        },
                        "origin": {
                          "type": "string",
                          "enum": ["conflict", "human"],
                          "description": "How the instruction was created. `human`: someone wrote it. `conflict`: it records the side chosen when a conflict issue was resolved. Both kinds work the same way in builds."
                        },
                        "status": {
                          "type": "string",
                          "enum": ["active", "archived"],
                          "description": "Whether builds apply the instruction. `active`: builds apply it. `archived`: a refresh found that its documents no longer support it, so builds stop applying it. To reactivate an archived instruction, update it."
                        },
                        "statement": {
                          "type": "string",
                          "description": "The instruction in plain language. Builds follow it over what the sources say."
                        },
                        "scopeDocumentIds": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "description": "IDs of the documents the instruction applies to. Builds apply it when they write entries built from these documents. An empty array means all of its documents were removed, so it applies to no entries."
                        },
                        "archivedAt": {
                          "nullable": true,
                          "description": "When a refresh archived the instruction. `null` while it is active.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        },
                        "archivedReason": {
                          "nullable": true,
                          "description": "Why the instruction was archived. `null` while it is active.",
                          "type": "string"
                        },
                        "sourceIssueId": {
                          "nullable": true,
                          "description": "ID of the conflict issue this instruction records. `null` when `origin` is `human`.",
                          "type": "string"
                        },
                        "createdBy": {
                          "nullable": true,
                          "description": "Who created the instruction. `null` for instructions created by resolving a conflict, and when the creator is unknown.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "nullable": true,
                              "description": "The Sanity user ID, or `sanity-system` when Sanity Context made the change. `null` if unknown.",
                              "type": "string"
                            },
                            "displayName": {
                              "nullable": true,
                              "description": "The user's name when the action happened. `null` if unknown. For the current name, look up the user by `id`.",
                              "type": "string"
                            }
                          },
                          "required": ["id", "displayName"]
                        },
                        "updatedBy": {
                          "nullable": true,
                          "description": "Who last updated the instruction through the API. `null` when it was never updated, or when the person is unknown.",
                          "type": "object",
                          "properties": {
                            "id": {
                              "nullable": true,
                              "description": "The Sanity user ID, or `sanity-system` when Sanity Context made the change. `null` if unknown.",
                              "type": "string"
                            },
                            "displayName": {
                              "nullable": true,
                              "description": "The user's name when the action happened. `null` if unknown. For the current name, look up the user by `id`.",
                              "type": "string"
                            }
                          },
                          "required": ["id", "displayName"]
                        },
                        "createdAt": {
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                          "description": "When the instruction was created."
                        },
                        "updatedAt": {
                          "nullable": true,
                          "description": "When the instruction last changed, including changes a refresh makes. `null` when the time is unknown.",
                          "type": "string",
                          "format": "date-time",
                          "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                        }
                      },
                      "required": [
                        "id",
                        "knowledgeBaseId",
                        "origin",
                        "status",
                        "statement",
                        "scopeDocumentIds",
                        "archivedAt",
                        "archivedReason",
                        "sourceIssueId",
                        "createdBy",
                        "updatedBy",
                        "createdAt",
                        "updatedAt"
                      ],
                      "description": "The created instruction."
                    },
                    "rebuildJobId": {
                      "nullable": true,
                      "description": "ID of the job that rebuilds the entries in `rebuildPaths`. Poll it with `GET .../jobs/{jobId}`. `null` when you didn't pass `rebuildPaths` or the rebuild could not start. The instruction is saved either way.",
                      "type": "string"
                    }
                  },
                  "required": ["instruction", "rebuildJobId"],
                  "description": "The created instruction, and the rebuild it started."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructions/check": {
      "post": {
        "operationId": "checkInstruction",
        "summary": "Check an instruction for contradictions",
        "tags": ["instructions"],
        "description": "Checks every entry built from any of the documents in `scopeDocumentIds` against `statement`, and returns the entries that contradict it. Nothing is saved. Run it before `POST .../instructions` to find the entries a new instruction would contradict, then pass their paths as `rebuildPaths` and set `verified`. Each checked entry is one model call that counts toward the organization's model spend, and the response waits for all of them, so a check over many entries can take a while. To list the entries without checking them, set `candidatesOnly`; this makes no model calls. To check only some entries, pass their paths in `paths`. Together, these let you check one entry per request and show progress.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "statement": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000,
                    "description": "The instruction in plain language, as you would pass it to create."
                  },
                  "scopeDocumentIds": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    },
                    "description": "IDs of the documents the instruction will be tied to. The check covers every entry built from any of them."
                  },
                  "excludeEntryId": {
                    "description": "ID of an entry to leave out of the check, such as the entry the instruction was drafted from.",
                    "type": "string",
                    "minLength": 1
                  },
                  "candidatesOnly": {
                    "description": "Set to `true` to list the entries the check would cover in `candidates` without checking them. This makes no model calls.",
                    "type": "boolean"
                  },
                  "paths": {
                    "description": "Paths of the entries to check. Paths of entries the check would not cover are ignored. Omit it to check every entry built from the documents.",
                    "minItems": 1,
                    "maxItems": 200,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                },
                "required": ["statement", "scopeDocumentIds"],
                "description": "An instruction to check before creating it."
              }
            }
          },
          "description": "An instruction to check before creating it."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "The result of checking an instruction. Nothing is saved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "checked": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 9007199254740991,
                      "description": "How many entries were checked. Entries with no text, and entries whose check failed, are not counted and not reported. `0` when `candidatesOnly` is set."
                    },
                    "contradictions": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "The entry's document ID."
                          },
                          "path": {
                            "type": "string",
                            "description": "The entry's path, such as `products/api/webhooks`."
                          },
                          "title": {
                            "type": "string",
                            "description": "The entry's title."
                          },
                          "issue": {
                            "type": "string",
                            "description": "What the entry says now, and why it contradicts the instruction."
                          }
                        },
                        "required": ["id", "path", "title", "issue"]
                      },
                      "description": "The entries that contradict the instruction, ordered by path. Empty when `candidatesOnly` is set."
                    },
                    "candidates": {
                      "description": "The entries the check covers, ordered by path. Only present when `candidatesOnly` is set.",
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "The entry's document ID."
                          },
                          "path": {
                            "type": "string",
                            "description": "The entry's path, such as `products/api/webhooks`."
                          },
                          "title": {
                            "type": "string",
                            "description": "The entry's title."
                          }
                        },
                        "required": ["id", "path", "title"]
                      }
                    }
                  },
                  "required": ["checked", "contradictions"],
                  "description": "The result of checking an instruction. Nothing is saved."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructions/draft": {
      "post": {
        "operationId": "draftInstruction",
        "summary": "Draft an instruction from feedback",
        "tags": ["instructions"],
        "description": "Turns free-form feedback, such as \"this is wrong\" or \"never say X\", into a proposed instruction: a statement and the documents it applies to. The documents come from `scopeDocumentIds` if you set it, or otherwise from the documents of the entry in `entryId`. Nothing is saved. Review and edit the draft, then create it with `POST .../instructions`. Each draft is one model call that counts toward the organization's model spend. If the model call fails, the request returns `502` with code `instructionDraftFailed`; retry, or write the instruction yourself.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "feedback": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000,
                    "description": "What should change, in your own words, such as \"this is wrong\" or \"never say X\"."
                  },
                  "entryId": {
                    "description": "ID of the entry the feedback is about. The draft reads the entry and its documents for context. If the entry doesn't exist, the request returns `404` with code `entryNotFound`.",
                    "type": "string",
                    "minLength": 1
                  },
                  "excerpt": {
                    "description": "The passage of the entry the feedback is about, so the draft addresses that claim.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 4000
                  },
                  "scopeDocumentIds": {
                    "description": "IDs of the documents to tie the instruction to. Omit it to use the documents of the entry in `entryId`. If neither gives any documents, the request returns `422` with code `instructionScopeVanished`.",
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    }
                  }
                },
                "required": ["feedback"],
                "description": "Feedback to turn into a proposed instruction."
              }
            }
          },
          "description": "Feedback to turn into a proposed instruction."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A proposed instruction. Nothing is saved: pass it to `POST .../instructions` to create it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "statement": {
                      "type": "string",
                      "description": "The proposed instruction in plain language, written as a standing rule."
                    },
                    "scopeDocumentIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "description": "IDs of the documents the instruction should be tied to: `scopeDocumentIds` from the request, or the documents of the entry in `entryId`. Always at least one."
                    }
                  },
                  "required": ["statement", "scopeDocumentIds"],
                  "description": "A proposed instruction. Nothing is saved: pass it to `POST .../instructions` to create it."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructions/{instructionId}": {
      "patch": {
        "operationId": "updateInstruction",
        "summary": "Update an instruction",
        "tags": ["instructions"],
        "description": "Updates the instruction's statement or documents. The change applies from the next build. Any update also reactivates an archived instruction and ties it to the current content of its documents.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "statement": {
                    "description": "The new instruction text. Omit it to keep the current text.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2000
                  },
                  "scopeDocumentIds": {
                    "description": "IDs of the documents the instruction applies to. Replaces the current list. Omit it to keep the current documents. IDs of documents that no longer exist are dropped. If none exist, the request returns `422` with code `instructionScopeVanished`.",
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uuid",
                      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                    }
                  }
                },
                "description": "The changes to make to an instruction. Set `statement`, `scopeDocumentIds`, or both. Any update also reactivates an archived instruction."
              }
            }
          },
          "description": "The changes to make to an instruction. Set `statement`, `scopeDocumentIds`, or both. Any update also reactivates an archived instruction."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "instructionId",
            "required": true,
            "description": "The instruction's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "A standing instruction that shapes how entries built from its documents are written.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The instruction's document ID."
                    },
                    "knowledgeBaseId": {
                      "type": "string",
                      "description": "The ID (`kb...`) of the knowledge base the instruction belongs to."
                    },
                    "origin": {
                      "type": "string",
                      "enum": ["conflict", "human"],
                      "description": "How the instruction was created. `human`: someone wrote it. `conflict`: it records the side chosen when a conflict issue was resolved. Both kinds work the same way in builds."
                    },
                    "status": {
                      "type": "string",
                      "enum": ["active", "archived"],
                      "description": "Whether builds apply the instruction. `active`: builds apply it. `archived`: a refresh found that its documents no longer support it, so builds stop applying it. To reactivate an archived instruction, update it."
                    },
                    "statement": {
                      "type": "string",
                      "description": "The instruction in plain language. Builds follow it over what the sources say."
                    },
                    "scopeDocumentIds": {
                      "type": "array",
                      "items": {
                        "type": "string",
                        "format": "uuid",
                        "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                      },
                      "description": "IDs of the documents the instruction applies to. Builds apply it when they write entries built from these documents. An empty array means all of its documents were removed, so it applies to no entries."
                    },
                    "archivedAt": {
                      "nullable": true,
                      "description": "When a refresh archived the instruction. `null` while it is active.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "archivedReason": {
                      "nullable": true,
                      "description": "Why the instruction was archived. `null` while it is active.",
                      "type": "string"
                    },
                    "sourceIssueId": {
                      "nullable": true,
                      "description": "ID of the conflict issue this instruction records. `null` when `origin` is `human`.",
                      "type": "string"
                    },
                    "createdBy": {
                      "nullable": true,
                      "description": "Who created the instruction. `null` for instructions created by resolving a conflict, and when the creator is unknown.",
                      "type": "object",
                      "properties": {
                        "id": {
                          "nullable": true,
                          "description": "The Sanity user ID, or `sanity-system` when Sanity Context made the change. `null` if unknown.",
                          "type": "string"
                        },
                        "displayName": {
                          "nullable": true,
                          "description": "The user's name when the action happened. `null` if unknown. For the current name, look up the user by `id`.",
                          "type": "string"
                        }
                      },
                      "required": ["id", "displayName"]
                    },
                    "updatedBy": {
                      "nullable": true,
                      "description": "Who last updated the instruction through the API. `null` when it was never updated, or when the person is unknown.",
                      "type": "object",
                      "properties": {
                        "id": {
                          "nullable": true,
                          "description": "The Sanity user ID, or `sanity-system` when Sanity Context made the change. `null` if unknown.",
                          "type": "string"
                        },
                        "displayName": {
                          "nullable": true,
                          "description": "The user's name when the action happened. `null` if unknown. For the current name, look up the user by `id`.",
                          "type": "string"
                        }
                      },
                      "required": ["id", "displayName"]
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the instruction was created."
                    },
                    "updatedAt": {
                      "nullable": true,
                      "description": "When the instruction last changed, including changes a refresh makes. `null` when the time is unknown.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "knowledgeBaseId",
                    "origin",
                    "status",
                    "statement",
                    "scopeDocumentIds",
                    "archivedAt",
                    "archivedReason",
                    "sourceIssueId",
                    "createdBy",
                    "updatedBy",
                    "createdAt",
                    "updatedAt"
                  ],
                  "description": "A standing instruction that shapes how entries built from its documents are written."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteInstruction",
        "summary": "Delete an instruction",
        "tags": ["instructions"],
        "description": "Deletes the instruction. Builds stop applying it from the next run. Entries already written under it keep their text until they are rebuilt; pass `rebuild=true` to rebuild every entry built from its documents right away.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "enum": ["true", "false"]
            },
            "in": "query",
            "name": "rebuild",
            "required": false,
            "description": "Set to `true` to rebuild every entry built from the instruction's documents once it is deleted, so pages written under the instruction reflect their documents again. The response returns the rebuild job ID in `rebuildJobId`."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "knowledgeBaseId",
            "required": true,
            "description": "The knowledge base's ID (`kb...`), its `publicId`. Its UUID `id` is also accepted."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "instructionId",
            "required": true,
            "description": "The instruction's ID."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          }
        ],
        "responses": {
          "200": {
            "description": "The rebuild the delete started, if any.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "rebuildJobId": {
                      "nullable": true,
                      "description": "ID of the job that rebuilds the entries built from the instruction's documents. Poll it with `GET .../jobs/{jobId}`. `null` when you didn't pass `rebuild=true`, no entry is built from those documents, or the rebuild could not start. The instruction is deleted either way.",
                      "type": "string"
                    }
                  },
                  "required": ["rebuildJobId"],
                  "description": "The rebuild the delete started, if any."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/organizations/{organizationId}/mcp": {
      "post": {
        "operationId": "createMcpEndpoint",
        "summary": "Create an MCP endpoint",
        "tags": ["mcp"],
        "description": "Creates an MCP endpoint with a title, a name, and the sources it serves. A source is a knowledge base, identified by its ID (`kb…`), or a dataset, identified as `<projectId>.<datasetName>`. An endpoint can serve any number of knowledge bases and at most one dataset, all at once. A GROQ filter is only kept when the endpoint has a dataset. The name must be unique in your organization, and you can't change it later. Duplicate sources with the same `type` and `id` are combined. The response includes the `url` agents connect to. To list or inspect endpoints, query `sanity.context.mcp` documents with GROQ from your organization's document store. Requires the `sanity.context.mcp.create` grant on the organization, which the Administrator and Developer roles have. Adding a dataset also requires full read access to the dataset and, on its project, the Administrator or Developer role or a custom role that can create datasets.\n\nA taken name returns `409` with code `mcpEndpointNameConflict`. A knowledge base that doesn't exist in the organization returns `422` with code `mcpSourceKnowledgeBaseNotFound`, and an invalid GROQ filter returns `422` with code `invalidGroqFilter`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "The endpoint's display title, up to 100 characters."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 64,
                    "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$",
                    "description": "The endpoint's name, used in its URL. Lowercase letters, digits and single hyphens, up to 64 characters, unique in the organization. It can't be changed after the endpoint is created. `by-name` and names shaped like an endpoint ID are reserved."
                  },
                  "sources": {
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": ["knowledge-base"],
                              "description": "The source type. `knowledge-base` serves a whole knowledge base."
                            },
                            "id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The knowledge base ID (`kb…`)."
                            }
                          },
                          "required": ["type", "id"]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": ["dataset"],
                              "description": "The source type. `dataset` serves documents from a Sanity dataset, limited by the MCP endpoint's `groqFilter` when set."
                            },
                            "id": {
                              "type": "string",
                              "pattern": "^[a-z0-9]+\\.[a-z0-9][a-z0-9_-]*$",
                              "description": "The dataset, as `<projectId>.<datasetName>`."
                            },
                            "workspace": {
                              "default": null,
                              "description": "The studio workspace whose schema agents use, by name. `null` uses the studio's first workspace.",
                              "nullable": true,
                              "type": "string",
                              "minLength": 1
                            },
                            "perspective": {
                              "default": null,
                              "description": "The perspective agents query the dataset with: `published`, `drafts`, or `raw`. `null` uses `published`.",
                              "nullable": true,
                              "type": "string",
                              "enum": ["published", "drafts", "raw", null]
                            },
                            "semanticSearch": {
                              "default": null,
                              "description": "Whether agents can use semantic search on the dataset. `false` turns it off. `true` or `null` use it while the dataset has embeddings enabled and the organization has embeddings usage left.",
                              "nullable": true,
                              "type": "boolean"
                            }
                          },
                          "required": ["type", "id"]
                        }
                      ],
                      "description": "A content source that an MCP endpoint serves: a knowledge base or a Sanity dataset."
                    },
                    "description": "The content the endpoint serves: up to 100 sources, any number of knowledge bases and at most one dataset, served together. Order has no meaning. With no sources, agents can't connect until one is added."
                  },
                  "instructions": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000,
                    "description": "Instructions for connecting agents, up to 10,000 characters."
                  },
                  "groqFilter": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000,
                    "description": "A GROQ filter that limits which documents the endpoint's dataset source serves, such as `_type in [\"post\", \"author\"]`. Knowledge base sources aren't filtered. Kept only while the endpoint has a dataset source."
                  }
                },
                "required": ["title", "name", "sources"],
                "description": "CreateMcpEndpointInput"
              }
            }
          },
          "description": "CreateMcpEndpointInput"
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "201": {
            "description": "McpEndpoint",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The endpoint's ID (`mcp…`). Update and delete accept it or the endpoint's name."
                    },
                    "organizationId": {
                      "type": "string",
                      "description": "The ID of the organization that owns the endpoint."
                    },
                    "title": {
                      "type": "string",
                      "description": "The endpoint's display title."
                    },
                    "name": {
                      "type": "string",
                      "description": "The endpoint's name, used in its URL. It can't be changed."
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": ["knowledge-base"],
                                "description": "The source type. `knowledge-base` serves a whole knowledge base."
                              },
                              "id": {
                                "type": "string",
                                "minLength": 1,
                                "description": "The knowledge base ID (`kb…`)."
                              }
                            },
                            "required": ["type", "id"]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": ["dataset"],
                                "description": "The source type. `dataset` serves documents from a Sanity dataset, limited by the MCP endpoint's `groqFilter` when set."
                              },
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z0-9]+\\.[a-z0-9][a-z0-9_-]*$",
                                "description": "The dataset, as `<projectId>.<datasetName>`."
                              },
                              "workspace": {
                                "default": null,
                                "description": "The studio workspace whose schema agents use, by name. `null` uses the studio's first workspace.",
                                "nullable": true,
                                "type": "string",
                                "minLength": 1
                              },
                              "perspective": {
                                "default": null,
                                "description": "The perspective agents query the dataset with: `published`, `drafts`, or `raw`. `null` uses `published`.",
                                "nullable": true,
                                "type": "string",
                                "enum": ["published", "drafts", "raw", null]
                              },
                              "semanticSearch": {
                                "default": null,
                                "description": "Whether agents can use semantic search on the dataset. `false` turns it off. `true` or `null` use it while the dataset has embeddings enabled and the organization has embeddings usage left.",
                                "nullable": true,
                                "type": "boolean"
                              }
                            },
                            "required": ["type", "id", "workspace", "perspective", "semanticSearch"]
                          }
                        ],
                        "description": "A content source that an MCP endpoint serves: a knowledge base or a Sanity dataset."
                      },
                      "description": "The content the endpoint serves: any number of knowledge bases and at most one dataset, served together. With no sources, agents can't connect until one is added."
                    },
                    "instructions": {
                      "nullable": true,
                      "description": "Instructions for connecting agents, or `null` if none are set.",
                      "type": "string"
                    },
                    "groqFilter": {
                      "nullable": true,
                      "description": "The GROQ filter that limits the endpoint's dataset source, or `null` if none is set or the endpoint has no dataset.",
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri",
                      "description": "The URL agents connect to."
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the endpoint was created, as an ISO 8601 timestamp."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the endpoint was last edited, as an ISO 8601 timestamp. Agents using the endpoint don't change it."
                    },
                    "lastUsedAt": {
                      "nullable": true,
                      "description": "When an agent last used the endpoint, as an ISO 8601 timestamp. It's recorded at most once a day, so it can be up to a day behind. `null` if the endpoint hasn't been used since usage tracking started.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "organizationId",
                    "title",
                    "name",
                    "sources",
                    "instructions",
                    "groqFilter",
                    "url",
                    "createdAt",
                    "updatedAt",
                    "lastUsedAt"
                  ],
                  "description": "McpEndpoint"
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/organizations/{organizationId}/mcp/{mcpEndpoint}": {
      "patch": {
        "operationId": "updateMcpEndpoint",
        "summary": "Update an MCP endpoint",
        "tags": ["mcp"],
        "description": "Updates the title, sources, instructions, or GROQ filter of the endpoint with that name or ID. To clear an optional field, set it to `null`. An endpoint can have at most one dataset source, and removing it clears the GROQ filter. You can't change the name, so the endpoint URL stays the same. Requires the `sanity.context.mcp.update` grant on the organization. Adding a dataset source requires full read access to the dataset and, on its project, the Administrator or Developer role or a custom role that can create datasets. Changing the GROQ filter requires the same access for the endpoint's dataset. Sending the current values changes nothing.\n\nAn unknown endpoint returns `404` with code `mcpEndpointNotFound`. A knowledge base that doesn't exist in the organization returns `422` with code `mcpSourceKnowledgeBaseNotFound`, and an invalid GROQ filter returns `422` with code `invalidGroqFilter`. If the endpoint changed while the update was in progress, the update returns `409` with code `mcpEndpointEditConflict` and changes nothing. You can safely retry it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100,
                    "description": "The endpoint's display title, up to 100 characters."
                  },
                  "sources": {
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": ["knowledge-base"],
                              "description": "The source type. `knowledge-base` serves a whole knowledge base."
                            },
                            "id": {
                              "type": "string",
                              "minLength": 1,
                              "description": "The knowledge base ID (`kb…`)."
                            }
                          },
                          "required": ["type", "id"]
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": ["dataset"],
                              "description": "The source type. `dataset` serves documents from a Sanity dataset, limited by the MCP endpoint's `groqFilter` when set."
                            },
                            "id": {
                              "type": "string",
                              "pattern": "^[a-z0-9]+\\.[a-z0-9][a-z0-9_-]*$",
                              "description": "The dataset, as `<projectId>.<datasetName>`."
                            },
                            "workspace": {
                              "default": null,
                              "description": "The studio workspace whose schema agents use, by name. `null` uses the studio's first workspace.",
                              "nullable": true,
                              "type": "string",
                              "minLength": 1
                            },
                            "perspective": {
                              "default": null,
                              "description": "The perspective agents query the dataset with: `published`, `drafts`, or `raw`. `null` uses `published`.",
                              "nullable": true,
                              "type": "string",
                              "enum": ["published", "drafts", "raw", null]
                            },
                            "semanticSearch": {
                              "default": null,
                              "description": "Whether agents can use semantic search on the dataset. `false` turns it off. `true` or `null` use it while the dataset has embeddings enabled and the organization has embeddings usage left.",
                              "nullable": true,
                              "type": "boolean"
                            }
                          },
                          "required": ["type", "id"]
                        }
                      ],
                      "description": "A content source that an MCP endpoint serves: a knowledge base or a Sanity dataset."
                    },
                    "description": "The content the endpoint serves: up to 100 sources, any number of knowledge bases and at most one dataset, served together. Order has no meaning. With no sources, agents can't connect until one is added."
                  },
                  "instructions": {
                    "description": "Instructions for connecting agents, up to 10,000 characters. `null` removes them.",
                    "nullable": true,
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000
                  },
                  "groqFilter": {
                    "description": "A GROQ filter that limits the endpoint's dataset source. `null` removes it.",
                    "nullable": true,
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 10000
                  }
                },
                "description": "UpdateMcpEndpointInput"
              }
            }
          },
          "description": "UpdateMcpEndpointInput"
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "mcpEndpoint",
            "required": true,
            "description": "The MCP endpoint's name, as in its URL, or its ID (`mcp…`). Names can't take the shape of an ID, so either one identifies the endpoint."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "200": {
            "description": "McpEndpoint",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The endpoint's ID (`mcp…`). Update and delete accept it or the endpoint's name."
                    },
                    "organizationId": {
                      "type": "string",
                      "description": "The ID of the organization that owns the endpoint."
                    },
                    "title": {
                      "type": "string",
                      "description": "The endpoint's display title."
                    },
                    "name": {
                      "type": "string",
                      "description": "The endpoint's name, used in its URL. It can't be changed."
                    },
                    "sources": {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": ["knowledge-base"],
                                "description": "The source type. `knowledge-base` serves a whole knowledge base."
                              },
                              "id": {
                                "type": "string",
                                "minLength": 1,
                                "description": "The knowledge base ID (`kb…`)."
                              }
                            },
                            "required": ["type", "id"]
                          },
                          {
                            "type": "object",
                            "properties": {
                              "type": {
                                "type": "string",
                                "enum": ["dataset"],
                                "description": "The source type. `dataset` serves documents from a Sanity dataset, limited by the MCP endpoint's `groqFilter` when set."
                              },
                              "id": {
                                "type": "string",
                                "pattern": "^[a-z0-9]+\\.[a-z0-9][a-z0-9_-]*$",
                                "description": "The dataset, as `<projectId>.<datasetName>`."
                              },
                              "workspace": {
                                "default": null,
                                "description": "The studio workspace whose schema agents use, by name. `null` uses the studio's first workspace.",
                                "nullable": true,
                                "type": "string",
                                "minLength": 1
                              },
                              "perspective": {
                                "default": null,
                                "description": "The perspective agents query the dataset with: `published`, `drafts`, or `raw`. `null` uses `published`.",
                                "nullable": true,
                                "type": "string",
                                "enum": ["published", "drafts", "raw", null]
                              },
                              "semanticSearch": {
                                "default": null,
                                "description": "Whether agents can use semantic search on the dataset. `false` turns it off. `true` or `null` use it while the dataset has embeddings enabled and the organization has embeddings usage left.",
                                "nullable": true,
                                "type": "boolean"
                              }
                            },
                            "required": ["type", "id", "workspace", "perspective", "semanticSearch"]
                          }
                        ],
                        "description": "A content source that an MCP endpoint serves: a knowledge base or a Sanity dataset."
                      },
                      "description": "The content the endpoint serves: any number of knowledge bases and at most one dataset, served together. With no sources, agents can't connect until one is added."
                    },
                    "instructions": {
                      "nullable": true,
                      "description": "Instructions for connecting agents, or `null` if none are set.",
                      "type": "string"
                    },
                    "groqFilter": {
                      "nullable": true,
                      "description": "The GROQ filter that limits the endpoint's dataset source, or `null` if none is set or the endpoint has no dataset.",
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri",
                      "description": "The URL agents connect to."
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the endpoint was created, as an ISO 8601 timestamp."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the endpoint was last edited, as an ISO 8601 timestamp. Agents using the endpoint don't change it."
                    },
                    "lastUsedAt": {
                      "nullable": true,
                      "description": "When an agent last used the endpoint, as an ISO 8601 timestamp. It's recorded at most once a day, so it can be up to a day behind. `null` if the endpoint hasn't been used since usage tracking started.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    }
                  },
                  "required": [
                    "id",
                    "organizationId",
                    "title",
                    "name",
                    "sources",
                    "instructions",
                    "groqFilter",
                    "url",
                    "createdAt",
                    "updatedAt",
                    "lastUsedAt"
                  ],
                  "description": "McpEndpoint"
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteMcpEndpoint",
        "summary": "Delete an MCP endpoint",
        "tags": ["mcp"],
        "description": "Deletes the MCP endpoint with that name or ID. Agents connected through it lose access, and its name can be used again. Requires the `sanity.context.mcp.delete` grant on the organization. An unknown endpoint returns `404` with code `mcpEndpointNotFound`.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "mcpEndpoint",
            "required": true,
            "description": "The MCP endpoint's name, as in its URL, or its ID (`mcp…`). Names can't take the shape of an ID, so either one identifies the endpoint."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "204": {
            "description": "Default Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "nullable": true,
                  "enum": [null]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "serveMcpEndpoint",
        "summary": "Connect to an MCP endpoint",
        "tags": ["mcp"],
        "description": "Receives Model Context Protocol (MCP) messages from agents over streamable HTTP (JSON-RPC 2.0). Agents send MCP messages in `POST` requests to this URL. `mcpEndpoint` is the permanent URL name of the endpoint. Errors are JSON-RPC error objects, not the standard error response.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "instructions",
            "required": false,
            "description": "Agent instructions that replace the endpoint's configured instructions for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "perspective",
            "required": false,
            "description": "The perspective for GROQ queries: `published` (default), `previewDrafts`, `raw`, or a release. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "embeddings",
            "required": false,
            "description": "Set to `true` or `false` to turn semantic search on or off. Omit it to use the dataset source setting. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "groqFilter",
            "required": false,
            "description": "A GROQ filter that narrows the endpoint's configured content filter for this request. Documents must match both. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string",
              "enum": ["knowledge_base", "groq"]
            },
            "in": "query",
            "name": "mode",
            "required": false,
            "description": "Serves only one side of the endpoint for this request: `knowledge_base` serves its knowledge bases and `groq` serves its dataset. Omit it to serve every source the endpoint has. A request whose chosen side the endpoint doesn't have is refused. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "knowledgeBases",
            "required": false,
            "description": "Comma-separated knowledge base public IDs (`kb...`) that replace the endpoint's knowledge base sources for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "linkResolver",
            "required": false,
            "description": "A JSON array that adds `_url` fields to query results. Each item has `types` (document types), `baseUrl`, and an optional `slugExpression`, a GROQ expression that defaults to `slug.current`. Invalid JSON is ignored."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "workspace",
            "required": false,
            "description": "The studio workspace to use. Replaces the dataset source's workspace for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "mcpEndpoint",
            "required": true,
            "description": "The MCP endpoint's name, set when the endpoint was created."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response"
          }
        }
      }
    },
    "/{apiVersion}/context/organizations/{organizationId}/mcp/{mcpEndpoint}/initial-context": {
      "get": {
        "operationId": "getMcpEndpointInitialContext",
        "summary": "Get an MCP endpoint's initial context",
        "tags": ["mcp"],
        "description": "Returns the same text as the `initial_context` MCP tool, as plain text you can add to a system prompt. `heading_offset` shifts markdown headings down by that many levels. The default is `1`, so `#` becomes `##`.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "instructions",
            "required": false,
            "description": "Agent instructions that replace the endpoint's configured instructions for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "perspective",
            "required": false,
            "description": "The perspective for GROQ queries: `published` (default), `previewDrafts`, `raw`, or a release. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "embeddings",
            "required": false,
            "description": "Set to `true` or `false` to turn semantic search on or off. Omit it to use the dataset source setting. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "groqFilter",
            "required": false,
            "description": "A GROQ filter that narrows the endpoint's configured content filter for this request. Documents must match both. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string",
              "enum": ["knowledge_base", "groq"]
            },
            "in": "query",
            "name": "mode",
            "required": false,
            "description": "Serves only one side of the endpoint for this request: `knowledge_base` serves its knowledge bases and `groq` serves its dataset. Omit it to serve every source the endpoint has. A request whose chosen side the endpoint doesn't have is refused. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "knowledgeBases",
            "required": false,
            "description": "Comma-separated knowledge base public IDs (`kb...`) that replace the endpoint's knowledge base sources for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "linkResolver",
            "required": false,
            "description": "A JSON array that adds `_url` fields to query results. Each item has `types` (document types), `baseUrl`, and an optional `slugExpression`, a GROQ expression that defaults to `slug.current`. Invalid JSON is ignored."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "workspace",
            "required": false,
            "description": "The studio workspace to use. Replaces the dataset source's workspace for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "heading_offset",
            "required": false,
            "description": "How many levels to shift markdown headings down, from `0` to `6`. Defaults to `1`, so `#` becomes `##`."
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "mcpEndpoint",
            "required": true,
            "description": "The MCP endpoint's name, set when the endpoint was created."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response"
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/organizations/{organizationId}/mcp/{mcpEndpoint}/status": {
      "get": {
        "operationId": "getMcpEndpointStatus",
        "summary": "Check an MCP endpoint",
        "tags": ["mcp"],
        "description": "Checks whether the endpoint is ready for agents, and whether your credentials can read what it serves. A failed check returns `200` with that check's `ok` set to `false`, so you can see every problem at once. `ready` summarizes the result. Returns `404` if the endpoint doesn't exist.",
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "instructions",
            "required": false,
            "description": "Agent instructions that replace the endpoint's configured instructions for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "perspective",
            "required": false,
            "description": "The perspective for GROQ queries: `published` (default), `previewDrafts`, `raw`, or a release. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "embeddings",
            "required": false,
            "description": "Set to `true` or `false` to turn semantic search on or off. Omit it to use the dataset source setting. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "groqFilter",
            "required": false,
            "description": "A GROQ filter that narrows the endpoint's configured content filter for this request. Documents must match both. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string",
              "enum": ["knowledge_base", "groq"]
            },
            "in": "query",
            "name": "mode",
            "required": false,
            "description": "Serves only one side of the endpoint for this request: `knowledge_base` serves its knowledge bases and `groq` serves its dataset. Omit it to serve every source the endpoint has. A request whose chosen side the endpoint doesn't have is refused. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "knowledgeBases",
            "required": false,
            "description": "Comma-separated knowledge base public IDs (`kb...`) that replace the endpoint's knowledge base sources for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "linkResolver",
            "required": false,
            "description": "A JSON array that adds `_url` fields to query results. Each item has `types` (document types), `baseUrl`, and an optional `slugExpression`, a GROQ expression that defaults to `slug.current`. Invalid JSON is ignored."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "query",
            "name": "workspace",
            "required": false,
            "description": "The studio workspace to use. Replaces the dataset source's workspace for this request. Deprecated: refused from API version `v2026-11-03`. Configure it on the MCP endpoint instead.",
            "deprecated": true
          },
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "in": "path",
            "name": "mcpEndpoint",
            "required": true,
            "description": "The MCP endpoint's name, set when the endpoint was created."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "200": {
            "description": "Default Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ready": {
                      "type": "boolean",
                      "description": "Whether every check that applies to the connection passed, except `semanticSearch` and `access`. When `true`, the endpoint is ready for an agent whose credentials can read what it serves."
                    },
                    "requiredOk": {
                      "type": "boolean",
                      "deprecated": true,
                      "description": "Deprecated: use `ready`, which always has the same value."
                    },
                    "checks": {
                      "type": "object",
                      "properties": {
                        "studio": {
                          "nullable": true,
                          "description": "Whether a deployed studio serves the endpoint's dataset. Its schema tells the agent which document types exist. `null` when the connection doesn't query a dataset.",
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [true],
                                  "description": "The check passed."
                                },
                                "workspace": {
                                  "type": "string",
                                  "description": "The name of the studio workspace the connection uses."
                                },
                                "workspaceTitle": {
                                  "type": "string",
                                  "description": "The workspace's title."
                                },
                                "workspaceAutoSelected": {
                                  "type": "boolean",
                                  "description": "Whether the workspace was picked automatically because none was set. It is `false` when the dataset source's `workspace` chose it, or a `workspace` query parameter on versions before `v2026-11-03`."
                                },
                                "availableWorkspaces": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "name": {
                                        "type": "string",
                                        "description": "The workspace's name."
                                      },
                                      "title": {
                                        "type": "string",
                                        "description": "The workspace's title."
                                      }
                                    },
                                    "required": ["name", "title"]
                                  },
                                  "description": "The deployed studio's workspaces for the endpoint's dataset."
                                }
                              },
                              "required": [
                                "ok",
                                "workspace",
                                "workspaceTitle",
                                "workspaceAutoSelected",
                                "availableWorkspaces"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [false],
                                  "description": "The check failed."
                                },
                                "error": {
                                  "type": "string",
                                  "description": "Why the check failed, written to show to users."
                                }
                              },
                              "required": ["ok", "error"]
                            }
                          ]
                        },
                        "semanticSearch": {
                          "nullable": true,
                          "description": "Whether semantic search works on the endpoint's dataset. `null` when the connection doesn't query a dataset, or when semantic search is on but the dataset doesn't have embeddings enabled. It never affects `ready`: without it, the agent searches with GROQ only.",
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [true],
                                  "description": "The check passed."
                                },
                                "status": {
                                  "nullable": true,
                                  "description": "The dataset's embeddings index status, if known.",
                                  "type": "string"
                                },
                                "withinUsageLimit": {
                                  "nullable": true,
                                  "description": "Whether the project is within its embeddings usage limit, or `null` if it couldn't be checked.",
                                  "type": "boolean"
                                },
                                "active": {
                                  "type": "boolean",
                                  "description": "Whether agents connecting now can use semantic search. On versions before `v2026-11-03`, `?embeddings=true` forces the tool on for agents even when this is `false`."
                                },
                                "inactiveReason": {
                                  "nullable": true,
                                  "description": "Why semantic search isn't active: `turnedOff` when the dataset source has it off, `datasetEmbeddingsNotReady` while the dataset's embeddings are still being prepared, and `usageLimitReached` when the organization has no embeddings usage left. `null` when it is active.",
                                  "type": "string",
                                  "enum": [
                                    "turnedOff",
                                    "datasetEmbeddingsNotReady",
                                    "usageLimitReached",
                                    null
                                  ]
                                }
                              },
                              "required": [
                                "ok",
                                "status",
                                "withinUsageLimit",
                                "active",
                                "inactiveReason"
                              ]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [false],
                                  "description": "The check failed."
                                },
                                "error": {
                                  "type": "string",
                                  "description": "Why the check failed, written to show to users."
                                }
                              },
                              "required": ["ok", "error"]
                            }
                          ]
                        },
                        "schema": {
                          "nullable": true,
                          "description": "Whether the studio's schema has document types the agent can query. `null` when the connection doesn't query a dataset.",
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [true],
                                  "description": "The check passed."
                                },
                                "documentTypes": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991,
                                  "description": "The number of document types the agent can query, after the endpoint's GROQ filter."
                                },
                                "perspective": {
                                  "type": "string",
                                  "description": "The perspective agents query the dataset with, such as `published` or `drafts`."
                                }
                              },
                              "required": ["ok", "documentTypes", "perspective"]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [false],
                                  "description": "The check failed."
                                },
                                "error": {
                                  "type": "string",
                                  "description": "Why the check failed, written to show to users."
                                }
                              },
                              "required": ["ok", "error"]
                            }
                          ]
                        },
                        "knowledgeBases": {
                          "nullable": true,
                          "description": "Whether every knowledge base the connection serves exists and has been built. `null` when the connection doesn't serve knowledge bases.",
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [true],
                                  "description": "The check passed."
                                },
                                "resolved": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  },
                                  "description": "The IDs of the knowledge bases the connection serves."
                                }
                              },
                              "required": ["ok", "resolved"]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [false],
                                  "description": "The check failed."
                                },
                                "resolved": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  },
                                  "description": "The IDs of the knowledge bases that exist."
                                },
                                "missing": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  },
                                  "description": "The IDs of knowledge bases that don't exist in the organization."
                                },
                                "unbuilt": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  },
                                  "description": "The IDs of knowledge bases that haven't been built yet. Build them before connecting an agent."
                                },
                                "error": {
                                  "type": "string",
                                  "description": "Why the check failed, written to show to users."
                                }
                              },
                              "required": ["ok", "resolved", "missing", "unbuilt", "error"]
                            }
                          ]
                        },
                        "access": {
                          "nullable": true,
                          "description": "Whether your credentials can read the knowledge bases the connection serves. It never affects `ready`: agents connect with their own credentials, so check with the agent's token to know whether that agent can connect. `null` when the connection serves no knowledge bases that exist.",
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [true],
                                  "description": "You can read every knowledge base."
                                }
                              },
                              "required": ["ok"]
                            },
                            {
                              "type": "object",
                              "properties": {
                                "ok": {
                                  "type": "boolean",
                                  "enum": [false],
                                  "description": "You can't read some of the knowledge bases."
                                },
                                "denied": {
                                  "type": "array",
                                  "items": {
                                    "type": "string"
                                  },
                                  "description": "The IDs of knowledge bases your credentials can't read."
                                },
                                "error": {
                                  "type": "string",
                                  "description": "What you lack, written to show to users."
                                }
                              },
                              "required": ["ok", "denied", "error"]
                            }
                          ]
                        }
                      },
                      "required": [
                        "studio",
                        "semanticSearch",
                        "schema",
                        "knowledgeBases",
                        "access"
                      ],
                      "description": "One result per check. A check is `null` when it doesn't apply to the connection."
                    }
                  },
                  "required": ["ready", "requiredOk", "checks"]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    },
    "/{apiVersion}/context/organizations/{organizationId}/conversations/{threadId}": {
      "put": {
        "operationId": "saveConversation",
        "summary": "Record a conversation",
        "tags": ["conversations"],
        "description": "Creates or updates the recorded conversation for one thread. `threadId` identifies the conversation within your organization, so saving with the same `threadId` updates the same conversation. Requires Context Editor access or higher.\n\nEach save replaces the stored messages. `metadata`, `sharing`, and the model fields change only when you include them. `tokenUsage` is cumulative: send the usage for one generation call, and the API adds it to the conversation total. Usage is added only when the save changes the messages, so retries don't count it twice.\n\nTo report a failure, set `error` on the message where it happened: the tool result for a failed tool call, or the assistant message for a turn that failed instead of answering. The Insights dashboard highlights conversations with a failed turn and counts failed tool calls separately, because agents often recover from them.\n\nThe last write for a thread wins, so retries are safe. `sharing` records whether you share telemetry with Sanity: metrics only, or full transcripts.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "messages": {
                    "maxItems": 1000,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "role": {
                          "type": "string",
                          "enum": ["user", "assistant", "system", "tool"],
                          "description": "Who sent the message. `user` is the person talking to the agent, `assistant` is the agent, `system` is a system prompt, and `tool` is a tool call or tool result."
                        },
                        "content": {
                          "default": null,
                          "description": "The message text. `null` when the message has no text, such as a tool call.",
                          "nullable": true,
                          "type": "string",
                          "maxLength": 20000
                        },
                        "toolName": {
                          "default": null,
                          "description": "The name of the tool for a `tool` message. `null` on other messages.",
                          "nullable": true,
                          "type": "string"
                        },
                        "toolType": {
                          "default": null,
                          "description": "The kind of `tool` message. `call` is the agent calling the tool, and `result` is what the tool returned. `null` on other messages.",
                          "nullable": true,
                          "type": "string",
                          "enum": ["call", "result", null]
                        },
                        "error": {
                          "default": null,
                          "description": "Why this step failed, including any stack trace. Set it on the tool result for a failed tool call, or on the assistant message for a turn that failed instead of answering. `null` when the step succeeded.",
                          "nullable": true,
                          "type": "string",
                          "maxLength": 20000
                        }
                      },
                      "required": ["role"],
                      "description": "One message in a conversation transcript."
                    },
                    "description": "The full transcript so far, in order. It replaces the stored messages."
                  },
                  "modelProvider": {
                    "description": "The provider of the model the agent used. When absent, the stored value stays unchanged.",
                    "type": "string"
                  },
                  "modelId": {
                    "description": "The ID of the model the agent used. When absent, the stored value stays unchanged.",
                    "type": "string"
                  },
                  "tokenUsage": {
                    "description": "Token usage for one generation call. The API adds it to the conversation total, but only when this save changes the messages.",
                    "type": "object",
                    "properties": {
                      "inputTokens": {
                        "description": "The number of input tokens.",
                        "type": "number"
                      },
                      "outputTokens": {
                        "description": "The number of output tokens.",
                        "type": "number"
                      },
                      "totalTokens": {
                        "description": "The total number of tokens.",
                        "type": "number"
                      }
                    }
                  },
                  "metadata": {
                    "description": "Up to 20 tags that describe the conversation. Well-known keys are `mcpEndpoints` (names of the MCP endpoints the conversation used), `app`, and `environment`. Add any other keys you need. Replaces the stored metadata. When absent, the stored value stays unchanged.",
                    "type": "object",
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 256
                        },
                        {
                          "maxItems": 20,
                          "type": "array",
                          "items": {
                            "type": "string",
                            "maxLength": 256
                          }
                        }
                      ]
                    }
                  },
                  "sharing": {
                    "description": "Your choice to share conversation telemetry with Sanity. Replaces the stored setting. When absent, the stored value stays unchanged.",
                    "type": "object",
                    "properties": {
                      "metrics": {
                        "description": "Whether to share classification metrics with Sanity: scores, sentiment, content gap counts, message counts and sizes, tool names, and model and token usage. Message content is not included.",
                        "type": "boolean"
                      },
                      "conversations": {
                        "description": "Whether to share full conversation transcripts with Sanity. When `true`, the API also sets `metrics` to `true`.",
                        "type": "boolean"
                      },
                      "contact": {
                        "description": "How the Sanity team can reach you about your agent, such as an email address or a Discord handle.",
                        "type": "string",
                        "maxLength": 200
                      }
                    }
                  }
                },
                "required": ["messages"],
                "description": "A conversation transcript to save for one thread."
              }
            }
          },
          "description": "A conversation transcript to save for one thread."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "in": "path",
            "name": "threadId",
            "required": true,
            "description": "Your ID for the conversation thread, unique within your organization. Up to 200 characters."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "200": {
            "description": "A recorded agent conversation: its transcript, metadata, token usage, and classification.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The conversation ID, unique within the organization. It matches the `_id` of the conversation document in your document store."
                    },
                    "threadId": {
                      "type": "string",
                      "description": "Your identifier for the conversation thread, unique within the organization. Saving with the same `threadId` updates the same conversation."
                    },
                    "metadata": {
                      "nullable": true,
                      "description": "Tags that describe the conversation, such as `mcpEndpoints`, `app`, and `environment`. Filter on them in GROQ queries. `null` until a save includes `metadata`.",
                      "type": "object",
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 256
                          },
                          {
                            "maxItems": 20,
                            "type": "array",
                            "items": {
                              "type": "string",
                              "maxLength": 256
                            }
                          }
                        ]
                      }
                    },
                    "startedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the API received the first save for this thread, as an ISO 8601 timestamp."
                    },
                    "messagesUpdatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the conversation was last saved, as an ISO 8601 timestamp."
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "role": {
                            "type": "string",
                            "enum": ["user", "assistant", "system", "tool"],
                            "description": "Who sent the message. `user` is the person talking to the agent, `assistant` is the agent, `system` is a system prompt, and `tool` is a tool call or tool result."
                          },
                          "content": {
                            "default": null,
                            "description": "The message text. `null` when the message has no text, such as a tool call.",
                            "nullable": true,
                            "type": "string",
                            "maxLength": 20000
                          },
                          "toolName": {
                            "default": null,
                            "description": "The name of the tool for a `tool` message. `null` on other messages.",
                            "nullable": true,
                            "type": "string"
                          },
                          "toolType": {
                            "default": null,
                            "description": "The kind of `tool` message. `call` is the agent calling the tool, and `result` is what the tool returned. `null` on other messages.",
                            "nullable": true,
                            "type": "string",
                            "enum": ["call", "result", null]
                          },
                          "error": {
                            "default": null,
                            "description": "Why this step failed, including any stack trace. Set it on the tool result for a failed tool call, or on the assistant message for a turn that failed instead of answering. `null` when the step succeeded.",
                            "nullable": true,
                            "type": "string",
                            "maxLength": 20000
                          },
                          "timestamp": {
                            "default": null,
                            "description": "When the API first received this message, as an ISO 8601 timestamp. The API sets it. Resending an unchanged message at the same position keeps its timestamp. `null` for messages recorded before timestamps existed.",
                            "nullable": true,
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          }
                        },
                        "required": [
                          "role",
                          "content",
                          "toolName",
                          "toolType",
                          "error",
                          "timestamp"
                        ],
                        "description": "One message in a conversation transcript, with the time the API received it."
                      },
                      "description": "The conversation transcript, in order. Each save replaces it."
                    },
                    "modelProvider": {
                      "nullable": true,
                      "description": "The provider of the model the agent used. `null` until a save includes `modelProvider`.",
                      "type": "string"
                    },
                    "modelId": {
                      "nullable": true,
                      "description": "The ID of the model the agent used. `null` until a save includes `modelId`.",
                      "type": "string"
                    },
                    "tokenUsage": {
                      "nullable": true,
                      "description": "The running total of token usage for the conversation. `null` until a save includes `tokenUsage`.",
                      "type": "object",
                      "properties": {
                        "inputTokens": {
                          "description": "The number of input tokens.",
                          "type": "number"
                        },
                        "outputTokens": {
                          "description": "The number of output tokens.",
                          "type": "number"
                        },
                        "totalTokens": {
                          "description": "The total number of tokens.",
                          "type": "number"
                        }
                      }
                    },
                    "coreMetrics": {
                      "nullable": true,
                      "description": "The latest classification result. `null` until you record one.",
                      "type": "object",
                      "properties": {
                        "successScore": {
                          "description": "How well the agent resolved the user's needs, from 1 to 10.",
                          "type": "number"
                        },
                        "sentiment": {
                          "description": "The overall sentiment of the conversation.",
                          "type": "string",
                          "enum": ["positive", "neutral", "negative"]
                        },
                        "contentGaps": {
                          "description": "Topics the agent couldn't answer because it lacked content.",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "classifiedAt": {
                      "nullable": true,
                      "description": "When the latest classification result was recorded, as an ISO 8601 timestamp. The API sets it. `null` until you record a result.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "classificationError": {
                      "nullable": true,
                      "description": "Why your classifier couldn't classify the conversation. `null` when no failure is recorded. Recording a result clears it.",
                      "type": "string"
                    },
                    "sharing": {
                      "nullable": true,
                      "description": "Your choice to share conversation telemetry with Sanity. `null` until a save includes `sharing`.",
                      "type": "object",
                      "properties": {
                        "metrics": {
                          "description": "Whether to share classification metrics with Sanity: scores, sentiment, content gap counts, message counts and sizes, tool names, and model and token usage. Message content is not included.",
                          "type": "boolean"
                        },
                        "conversations": {
                          "description": "Whether to share full conversation transcripts with Sanity. When `true`, the API also sets `metrics` to `true`.",
                          "type": "boolean"
                        },
                        "contact": {
                          "description": "How the Sanity team can reach you about your agent, such as an email address or a Discord handle.",
                          "type": "string",
                          "maxLength": 200
                        }
                      }
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the conversation was created, as an ISO 8601 timestamp."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the conversation was last changed, as an ISO 8601 timestamp."
                    }
                  },
                  "required": [
                    "id",
                    "threadId",
                    "metadata",
                    "startedAt",
                    "messagesUpdatedAt",
                    "messages",
                    "modelProvider",
                    "modelId",
                    "tokenUsage",
                    "coreMetrics",
                    "classifiedAt",
                    "classificationError",
                    "sharing",
                    "createdAt",
                    "updatedAt"
                  ],
                  "description": "A recorded agent conversation: its transcript, metadata, token usage, and classification."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "classifyConversation",
        "summary": "Record a conversation classification",
        "tags": ["conversations"],
        "description": "Records the classification your own model produced for one thread. Send exactly one of these fields:\n\n- `coreMetrics`: the classification result. The API sets `classifiedAt` and clears any recorded failure.\n- `classificationError`: why classification failed. Any earlier result stays unchanged.\n\nRequires the same access as recording a conversation. The last write wins, so a new classification replaces the previous one.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "coreMetrics": {
                    "description": "The classification result. The API sets `classifiedAt` and clears any recorded `classificationError`.",
                    "type": "object",
                    "properties": {
                      "successScore": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 10,
                        "description": "How well the agent resolved the user's needs, as an integer from 1 to 10."
                      },
                      "sentiment": {
                        "type": "string",
                        "enum": ["positive", "neutral", "negative"],
                        "description": "The overall sentiment of the conversation."
                      },
                      "contentGaps": {
                        "maxItems": 50,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "maxLength": 200
                        },
                        "description": "Topics the agent couldn't answer because it lacked content."
                      }
                    },
                    "required": ["successScore", "sentiment", "contentGaps"]
                  },
                  "classificationError": {
                    "description": "Why your classifier couldn't classify the conversation. Any earlier classification result stays unchanged.",
                    "type": "string",
                    "maxLength": 500
                  }
                },
                "description": "A classification result or failure for one conversation. Send exactly one of `coreMetrics` or `classificationError`."
              }
            }
          },
          "description": "A classification result or failure for one conversation. Send exactly one of `coreMetrics` or `classificationError`."
        },
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "in": "path",
            "name": "threadId",
            "required": true,
            "description": "Your ID for the conversation thread, unique within your organization. Up to 200 characters."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "200": {
            "description": "A recorded agent conversation: its transcript, metadata, token usage, and classification.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "The conversation ID, unique within the organization. It matches the `_id` of the conversation document in your document store."
                    },
                    "threadId": {
                      "type": "string",
                      "description": "Your identifier for the conversation thread, unique within the organization. Saving with the same `threadId` updates the same conversation."
                    },
                    "metadata": {
                      "nullable": true,
                      "description": "Tags that describe the conversation, such as `mcpEndpoints`, `app`, and `environment`. Filter on them in GROQ queries. `null` until a save includes `metadata`.",
                      "type": "object",
                      "additionalProperties": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 256
                          },
                          {
                            "maxItems": 20,
                            "type": "array",
                            "items": {
                              "type": "string",
                              "maxLength": 256
                            }
                          }
                        ]
                      }
                    },
                    "startedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the API received the first save for this thread, as an ISO 8601 timestamp."
                    },
                    "messagesUpdatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the conversation was last saved, as an ISO 8601 timestamp."
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "role": {
                            "type": "string",
                            "enum": ["user", "assistant", "system", "tool"],
                            "description": "Who sent the message. `user` is the person talking to the agent, `assistant` is the agent, `system` is a system prompt, and `tool` is a tool call or tool result."
                          },
                          "content": {
                            "default": null,
                            "description": "The message text. `null` when the message has no text, such as a tool call.",
                            "nullable": true,
                            "type": "string",
                            "maxLength": 20000
                          },
                          "toolName": {
                            "default": null,
                            "description": "The name of the tool for a `tool` message. `null` on other messages.",
                            "nullable": true,
                            "type": "string"
                          },
                          "toolType": {
                            "default": null,
                            "description": "The kind of `tool` message. `call` is the agent calling the tool, and `result` is what the tool returned. `null` on other messages.",
                            "nullable": true,
                            "type": "string",
                            "enum": ["call", "result", null]
                          },
                          "error": {
                            "default": null,
                            "description": "Why this step failed, including any stack trace. Set it on the tool result for a failed tool call, or on the assistant message for a turn that failed instead of answering. `null` when the step succeeded.",
                            "nullable": true,
                            "type": "string",
                            "maxLength": 20000
                          },
                          "timestamp": {
                            "default": null,
                            "description": "When the API first received this message, as an ISO 8601 timestamp. The API sets it. Resending an unchanged message at the same position keeps its timestamp. `null` for messages recorded before timestamps existed.",
                            "nullable": true,
                            "type": "string",
                            "format": "date-time",
                            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                          }
                        },
                        "required": [
                          "role",
                          "content",
                          "toolName",
                          "toolType",
                          "error",
                          "timestamp"
                        ],
                        "description": "One message in a conversation transcript, with the time the API received it."
                      },
                      "description": "The conversation transcript, in order. Each save replaces it."
                    },
                    "modelProvider": {
                      "nullable": true,
                      "description": "The provider of the model the agent used. `null` until a save includes `modelProvider`.",
                      "type": "string"
                    },
                    "modelId": {
                      "nullable": true,
                      "description": "The ID of the model the agent used. `null` until a save includes `modelId`.",
                      "type": "string"
                    },
                    "tokenUsage": {
                      "nullable": true,
                      "description": "The running total of token usage for the conversation. `null` until a save includes `tokenUsage`.",
                      "type": "object",
                      "properties": {
                        "inputTokens": {
                          "description": "The number of input tokens.",
                          "type": "number"
                        },
                        "outputTokens": {
                          "description": "The number of output tokens.",
                          "type": "number"
                        },
                        "totalTokens": {
                          "description": "The total number of tokens.",
                          "type": "number"
                        }
                      }
                    },
                    "coreMetrics": {
                      "nullable": true,
                      "description": "The latest classification result. `null` until you record one.",
                      "type": "object",
                      "properties": {
                        "successScore": {
                          "description": "How well the agent resolved the user's needs, from 1 to 10.",
                          "type": "number"
                        },
                        "sentiment": {
                          "description": "The overall sentiment of the conversation.",
                          "type": "string",
                          "enum": ["positive", "neutral", "negative"]
                        },
                        "contentGaps": {
                          "description": "Topics the agent couldn't answer because it lacked content.",
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "classifiedAt": {
                      "nullable": true,
                      "description": "When the latest classification result was recorded, as an ISO 8601 timestamp. The API sets it. `null` until you record a result.",
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$"
                    },
                    "classificationError": {
                      "nullable": true,
                      "description": "Why your classifier couldn't classify the conversation. `null` when no failure is recorded. Recording a result clears it.",
                      "type": "string"
                    },
                    "sharing": {
                      "nullable": true,
                      "description": "Your choice to share conversation telemetry with Sanity. `null` until a save includes `sharing`.",
                      "type": "object",
                      "properties": {
                        "metrics": {
                          "description": "Whether to share classification metrics with Sanity: scores, sentiment, content gap counts, message counts and sizes, tool names, and model and token usage. Message content is not included.",
                          "type": "boolean"
                        },
                        "conversations": {
                          "description": "Whether to share full conversation transcripts with Sanity. When `true`, the API also sets `metrics` to `true`.",
                          "type": "boolean"
                        },
                        "contact": {
                          "description": "How the Sanity team can reach you about your agent, such as an email address or a Discord handle.",
                          "type": "string",
                          "maxLength": 200
                        }
                      }
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the conversation was created, as an ISO 8601 timestamp."
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z))$",
                      "description": "When the conversation was last changed, as an ISO 8601 timestamp."
                    }
                  },
                  "required": [
                    "id",
                    "threadId",
                    "metadata",
                    "startedAt",
                    "messagesUpdatedAt",
                    "messages",
                    "modelProvider",
                    "modelId",
                    "tokenUsage",
                    "coreMetrics",
                    "classifiedAt",
                    "classificationError",
                    "sharing",
                    "createdAt",
                    "updatedAt"
                  ],
                  "description": "A recorded agent conversation: its transcript, metadata, token usage, and classification."
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "deleteConversation",
        "summary": "Delete a conversation",
        "tags": ["conversations"],
        "description": "Deletes the recorded conversation for one thread, including its messages and classification. Requires the same access as recording a conversation.\n\nSaving with the same `threadId` afterwards records a new conversation.",
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            },
            "in": "path",
            "name": "threadId",
            "required": true,
            "description": "Your ID for the conversation thread, unique within your organization. Up to 200 characters."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "apiVersion",
            "required": true,
            "description": "The API version: a date in the format `vYYYY-MM-DD`, for example `v2026-05-26`, or `vX` for the latest, unstable version."
          },
          {
            "schema": {
              "type": "string"
            },
            "in": "path",
            "name": "organizationId",
            "required": true,
            "description": "The ID of the organization."
          }
        ],
        "responses": {
          "204": {
            "description": "Default Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "nullable": true,
                  "enum": [null]
                }
              }
            }
          },
          "default": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorBody"
                }
              }
            }
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://api.sanity.io",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "knowledge-bases",
      "description": "Create, configure, and build knowledge bases."
    },
    {
      "name": "entries",
      "description": "Rebuild individual entries in a knowledge base."
    },
    {
      "name": "issues",
      "description": "Triage the issues that builds and refreshes find."
    },
    {
      "name": "instructions",
      "description": "Create standing instructions that steer every build."
    },
    {
      "name": "mcp",
      "description": "Connect agents to your knowledge bases through Model Context Protocol (MCP) endpoints."
    },
    {
      "name": "conversations",
      "description": "Record agent conversations and their classifications for Insights."
    },
    {
      "name": "jobs",
      "description": "Check the status of background jobs, such as builds, syncs, and refreshes."
    },
    {
      "name": "sources",
      "description": "Add and sync the websites, Sanity datasets and files a knowledge base reads documents from."
    },
    {
      "name": "documents",
      "description": "Read and remove the documents sources yield, which builds read and cite."
    }
  ]
}