Context API reference
Build knowledge bases from file uploads, website crawls, and Sanity datasets, then read, triage, and steer what they produce over HTTP.
Build knowledge bases from your content (file uploads, website crawls, and Sanity datasets), then read, triage, and steer what they produce.
Authentication
Send an organization API token with Context access, or a Sanity user token, in the Authorization: Bearer <token> header. Project API tokens aren't accepted.
Operations under a knowledge base check one of two levels of access:
- Read access: the
sanity.knowledge-base.readgrant. - Update access: any one of
sanity.knowledge-base.update,sanity.knowledge-base.entries.update,sanity.knowledge-base.issues.updateorsanity.knowledge-base.instructions.update.
Each operation says which level it needs, or names the grant it checks.
API versions
Every path starts with the API version, vYYYY-MM-DD. Use v2026-11-03. Earlier versions keep behavior that has since changed: before v2026-11-03, MCP endpoints accept their configuration as query parameters.
Errors
An error returns a JSON body with a stable code and a readable message. Branch on code. Operation descriptions don't repeat the errors below, which any operation can return where they apply:
401: no token (missingCredential), a malformedAuthorizationheader (invalidCredential), or a token without access to the organization (organizationAccessDenied).404with codeknowledgeBaseNotFound: the knowledge base doesn't exist, or the token can't access its organization. A knowledge base ID never confirms that it exists.403with codeknowledgeBaseAccessDenied: the token lacks the access the operation needs.fields.requiredlists the grants that would allow it.400with codevalidationError: the request doesn't match the schema.502with codeaccessCheckFailed: the token's access couldn't be checked. Try again.
A 503 response carries a Retry-After header.
Entries, issues, and instructions
A knowledge base keeps its entries, issues, and instructions as sanity.context.* documents in your organization's document store, alongside MCP endpoint configurations and recorded conversations. No operation lists or returns these documents: query them with GROQ through client.context.fetch in @sanity/client, and use these operations to change them. See Knowledge Bases.
Base API server URL
Production
https://api.sanity.ioknowledge-bases
Create, configure, and build knowledge bases.
List knowledge bases
/{apiVersion}/context/knowledge-basesReturns every knowledge base in the organization set by organizationId, including ones your token can't read or update. Drafts are left out unless you set includeDrafts to true. Results are cursor-paginated, newest first. Requires membership in the organization.
Path parameters
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Query parameters
- cursorstring
The
nextCursorvalue from the previous page. Omit it to get the first page. The maximum number of items to return.
The organization to list knowledge bases for.
- includeDraftsstring
Set to
trueto also list the organization's drafts, which havestateset todraft. Drafts count toward the plan's knowledge base limit, andcreatedBysays who started each one.
Responses
A page of knowledge bases.
The items on this page.
Show child attributes
items
An internal UUID for the knowledge base, still accepted wherever a
knowledgeBaseIdis expected. UsepublicIdinstead.The knowledge base's ID, such as
kb3do82whm. Store this one, and pass it asknowledgeBaseIdin paths and filters. Treat it as an opaque string.The ID of the organization that owns the knowledge base.
The knowledge base's title.
A short description of what the knowledge base covers.
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, useopenIssueCount. To check for a running build, useisBuilding.- activeJobIdrequired
The job ID of the most recent build, including builds Sanity Context started on its own.
nullif no build has started, or if the most recent build was cancelled or failed to start. Check its progress withGET .../jobs/{jobId}.Show child attributes
- string
- null
Whether a build is running now.
- buildStageStaterequired
Progress of the most recent build, by stage.
nulluntil a build reports progress. It can briefly belong to an earlier build, so use it only when itsjobIdmatchesactiveJobId.Show child attributes
The ID of the build job this progress belongs to.
Every stage this build runs, in the order it runs them, with each stage's progress.
Show child attributes
items
The stage's ID, such as
maporwrite. 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.The stage's share of the whole build, from 0 to 1. The weights of a build's stages sum to 1.
The stage's status.
pending: not started.running: in progress.done: finished.failed: the stage ended without finishing, because the build ended first or, for the conflict stages, because the check failed and the build went on without it.- unitsobject
The stage's progress counts. Absent when the stage hasn't reported counts.
Show child attributes
- null
- lastCheckedAtrequired
When a refresh last checked the knowledge base for changes, whether or not anything changed.
nulluntil the first refresh.Show child attributes
- string (date-time)
- null
- lastChangedAtrequired
When the content last changed: the time of the most recent successful build.
nullif the knowledge base has never built.Show child attributes
- string (date-time)
- null
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
falsebefore the first build.- pendingChangesrequired
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.nullin list responses and before the first build. Whether Sanity Context has improved how it builds knowledge bases since the last successful build. Rebuild to apply the improvements. Always
falsebefore the first build.- rebuildFaultrequired
Set when a rebuild Sanity Context started on its own, to bring entries up to date, failed. Rebuild to try again.
nullwhen there's no fault. Starting a build clears it, and so does a refresh that finds the entries up to date. The source changes waiting for
POST .../apply: sources added that the knowledge base doesn't use yet, which sync meanwhile, sources removed that it uses until then, andfilessources with a new file it doesn't use yet. Before the first build nothing waits, since the first build applies them.Whether the knowledge base has at least one website source.
The maximum number of website sources the knowledge base can have. Adding one more returns
409with codewebSourceRootLimitExceeded.Whether the knowledge base has at least one Sanity dataset source.
Whether the knowledge base has at least one uploaded file source.
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 byexcludedSourceChunks, and those of documents whose content another document repeats, which builds skip. Documents still being converted add theirs once converted.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.
- buildRestrictionrequired
Why a build request would be denied right now, or
nullif you can build. OnlyGET .../knowledge-bases/{knowledgeBaseId}checks it. List and create responses always returnnull. 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. OnlyGET .../knowledge-bases/{knowledgeBaseId}computes it, so list responses returnfalse.The number of open issues waiting for review. Always
0before the first build.The number of active instructions for the knowledge base.
- createdByrequired
Who created the knowledge base.
nullif unknown.Show child attributes
- idrequired
The Sanity user ID, or
sanity-systemwhen Sanity Context made the change.nullif unknown.Show child attributes
- string
- null
- displayNamerequired
The user's name when the action happened.
nullif unknown. For the current name, look up the user byid.Show child attributes
- string
- null
- null
When the knowledge base was created.
When the knowledge base was last updated.
- nextCursorrequired
The cursor for the next page. Pass it as
cursorto get more results.nullwhen there are no more pages.Show child attributes
- string
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Create a knowledge base
/{apiVersion}/context/knowledge-basesCreates 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. A token without the create grant gets 403 with code knowledgeBaseCreateAccessDenied. If the organization has reached its plan's knowledge base limit, drafts included, the request returns 403 with code planLimitReached. If your organization's Context document store can't be used, the request returns 503 with code contextStoreUnavailable and you can retry. Requires the sanity.knowledge-base.create grant.
Path parameters
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Header parameters
- Idempotency-Keystring
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.
Request body application/json
The ID of the organization to create the knowledge base in.
- titlestring
The knowledge base's title. Required unless
draftistrue. - descriptionstring
A short description of what the knowledge base covers. Required unless
draftistrue. - draftboolean
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
includeDraftstotrue. A draft counts toward your plan's knowledge base limit. To finish it, update it withdraftset tofalse.
Responses
A knowledge base and its current state.
An internal UUID for the knowledge base, still accepted wherever a
knowledgeBaseIdis expected. UsepublicIdinstead.The knowledge base's ID, such as
kb3do82whm. Store this one, and pass it asknowledgeBaseIdin paths and filters. Treat it as an opaque string.The ID of the organization that owns the knowledge base.
The knowledge base's title.
A short description of what the knowledge base covers.
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, useopenIssueCount. To check for a running build, useisBuilding.- activeJobIdrequired
The job ID of the most recent build, including builds Sanity Context started on its own.
nullif no build has started, or if the most recent build was cancelled or failed to start. Check its progress withGET .../jobs/{jobId}.Show child attributes
- string
- null
Whether a build is running now.
- buildStageStaterequired
Progress of the most recent build, by stage.
nulluntil a build reports progress. It can briefly belong to an earlier build, so use it only when itsjobIdmatchesactiveJobId.Show child attributes
The ID of the build job this progress belongs to.
Every stage this build runs, in the order it runs them, with each stage's progress.
Show child attributes
items
The stage's ID, such as
maporwrite. 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.The stage's share of the whole build, from 0 to 1. The weights of a build's stages sum to 1.
The stage's status.
pending: not started.running: in progress.done: finished.failed: the stage ended without finishing, because the build ended first or, for the conflict stages, because the check failed and the build went on without it.- unitsobject
The stage's progress counts. Absent when the stage hasn't reported counts.
Show child attributes
- null
- lastCheckedAtrequired
When a refresh last checked the knowledge base for changes, whether or not anything changed.
nulluntil the first refresh.Show child attributes
- string (date-time)
- null
- lastChangedAtrequired
When the content last changed: the time of the most recent successful build.
nullif the knowledge base has never built.Show child attributes
- string (date-time)
- null
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
falsebefore the first build.- pendingChangesrequired
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.nullin list responses and before the first build. Whether Sanity Context has improved how it builds knowledge bases since the last successful build. Rebuild to apply the improvements. Always
falsebefore the first build.- rebuildFaultrequired
Set when a rebuild Sanity Context started on its own, to bring entries up to date, failed. Rebuild to try again.
nullwhen there's no fault. Starting a build clears it, and so does a refresh that finds the entries up to date. The source changes waiting for
POST .../apply: sources added that the knowledge base doesn't use yet, which sync meanwhile, sources removed that it uses until then, andfilessources with a new file it doesn't use yet. Before the first build nothing waits, since the first build applies them.Whether the knowledge base has at least one website source.
The maximum number of website sources the knowledge base can have. Adding one more returns
409with codewebSourceRootLimitExceeded.Whether the knowledge base has at least one Sanity dataset source.
Whether the knowledge base has at least one uploaded file source.
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 byexcludedSourceChunks, and those of documents whose content another document repeats, which builds skip. Documents still being converted add theirs once converted.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.
- buildRestrictionrequired
Why a build request would be denied right now, or
nullif you can build. OnlyGET .../knowledge-bases/{knowledgeBaseId}checks it. List and create responses always returnnull. 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. OnlyGET .../knowledge-bases/{knowledgeBaseId}computes it, so list responses returnfalse.The number of open issues waiting for review. Always
0before the first build.The number of active instructions for the knowledge base.
- createdByrequired
Who created the knowledge base.
nullif unknown.Show child attributes
- idrequired
The Sanity user ID, or
sanity-systemwhen Sanity Context made the change.nullif unknown.Show child attributes
- string
- null
- displayNamerequired
The user's name when the action happened.
nullif unknown. For the current name, look up the user byid.Show child attributes
- string
- null
- null
When the knowledge base was created.
When the knowledge base was last updated.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Get a knowledge base
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}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. Any member of the knowledge base's organization can read it, even without read access to the knowledge base. To read the built entries, query sanity.context.entry documents with GROQ from your organization's document store. Requires membership in the knowledge base's organization.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
A knowledge base and its current state.
An internal UUID for the knowledge base, still accepted wherever a
knowledgeBaseIdis expected. UsepublicIdinstead.The knowledge base's ID, such as
kb3do82whm. Store this one, and pass it asknowledgeBaseIdin paths and filters. Treat it as an opaque string.The ID of the organization that owns the knowledge base.
The knowledge base's title.
A short description of what the knowledge base covers.
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, useopenIssueCount. To check for a running build, useisBuilding.- activeJobIdrequired
The job ID of the most recent build, including builds Sanity Context started on its own.
nullif no build has started, or if the most recent build was cancelled or failed to start. Check its progress withGET .../jobs/{jobId}.Show child attributes
- string
- null
Whether a build is running now.
- buildStageStaterequired
Progress of the most recent build, by stage.
nulluntil a build reports progress. It can briefly belong to an earlier build, so use it only when itsjobIdmatchesactiveJobId.Show child attributes
The ID of the build job this progress belongs to.
Every stage this build runs, in the order it runs them, with each stage's progress.
Show child attributes
items
The stage's ID, such as
maporwrite. 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.The stage's share of the whole build, from 0 to 1. The weights of a build's stages sum to 1.
The stage's status.
pending: not started.running: in progress.done: finished.failed: the stage ended without finishing, because the build ended first or, for the conflict stages, because the check failed and the build went on without it.- unitsobject
The stage's progress counts. Absent when the stage hasn't reported counts.
Show child attributes
- null
- lastCheckedAtrequired
When a refresh last checked the knowledge base for changes, whether or not anything changed.
nulluntil the first refresh.Show child attributes
- string (date-time)
- null
- lastChangedAtrequired
When the content last changed: the time of the most recent successful build.
nullif the knowledge base has never built.Show child attributes
- string (date-time)
- null
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
falsebefore the first build.- pendingChangesrequired
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.nullin list responses and before the first build. Whether Sanity Context has improved how it builds knowledge bases since the last successful build. Rebuild to apply the improvements. Always
falsebefore the first build.- rebuildFaultrequired
Set when a rebuild Sanity Context started on its own, to bring entries up to date, failed. Rebuild to try again.
nullwhen there's no fault. Starting a build clears it, and so does a refresh that finds the entries up to date. The source changes waiting for
POST .../apply: sources added that the knowledge base doesn't use yet, which sync meanwhile, sources removed that it uses until then, andfilessources with a new file it doesn't use yet. Before the first build nothing waits, since the first build applies them.Whether the knowledge base has at least one website source.
The maximum number of website sources the knowledge base can have. Adding one more returns
409with codewebSourceRootLimitExceeded.Whether the knowledge base has at least one Sanity dataset source.
Whether the knowledge base has at least one uploaded file source.
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 byexcludedSourceChunks, and those of documents whose content another document repeats, which builds skip. Documents still being converted add theirs once converted.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.
- buildRestrictionrequired
Why a build request would be denied right now, or
nullif you can build. OnlyGET .../knowledge-bases/{knowledgeBaseId}checks it. List and create responses always returnnull. 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. OnlyGET .../knowledge-bases/{knowledgeBaseId}computes it, so list responses returnfalse.The number of open issues waiting for review. Always
0before the first build.The number of active instructions for the knowledge base.
- createdByrequired
Who created the knowledge base.
nullif unknown.Show child attributes
- idrequired
The Sanity user ID, or
sanity-systemwhen Sanity Context made the change.nullif unknown.Show child attributes
- string
- null
- displayNamerequired
The user's name when the action happened.
nullif unknown. For the current name, look up the user byid.Show child attributes
- string
- null
- null
When the knowledge base was created.
When the knowledge base was last updated.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Update a knowledge base
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}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}. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
- titlestring
The knowledge base's new title.
- descriptionstring
The knowledge base's new description.
- draftboolean
Set to
falseto 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.
Responses
A knowledge base and its current state.
An internal UUID for the knowledge base, still accepted wherever a
knowledgeBaseIdis expected. UsepublicIdinstead.The knowledge base's ID, such as
kb3do82whm. Store this one, and pass it asknowledgeBaseIdin paths and filters. Treat it as an opaque string.The ID of the organization that owns the knowledge base.
The knowledge base's title.
A short description of what the knowledge base covers.
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, useopenIssueCount. To check for a running build, useisBuilding.- activeJobIdrequired
The job ID of the most recent build, including builds Sanity Context started on its own.
nullif no build has started, or if the most recent build was cancelled or failed to start. Check its progress withGET .../jobs/{jobId}.Show child attributes
- string
- null
Whether a build is running now.
- buildStageStaterequired
Progress of the most recent build, by stage.
nulluntil a build reports progress. It can briefly belong to an earlier build, so use it only when itsjobIdmatchesactiveJobId.Show child attributes
The ID of the build job this progress belongs to.
Every stage this build runs, in the order it runs them, with each stage's progress.
Show child attributes
items
The stage's ID, such as
maporwrite. 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.The stage's share of the whole build, from 0 to 1. The weights of a build's stages sum to 1.
The stage's status.
pending: not started.running: in progress.done: finished.failed: the stage ended without finishing, because the build ended first or, for the conflict stages, because the check failed and the build went on without it.- unitsobject
The stage's progress counts. Absent when the stage hasn't reported counts.
Show child attributes
- null
- lastCheckedAtrequired
When a refresh last checked the knowledge base for changes, whether or not anything changed.
nulluntil the first refresh.Show child attributes
- string (date-time)
- null
- lastChangedAtrequired
When the content last changed: the time of the most recent successful build.
nullif the knowledge base has never built.Show child attributes
- string (date-time)
- null
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
falsebefore the first build.- pendingChangesrequired
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.nullin list responses and before the first build. Whether Sanity Context has improved how it builds knowledge bases since the last successful build. Rebuild to apply the improvements. Always
falsebefore the first build.- rebuildFaultrequired
Set when a rebuild Sanity Context started on its own, to bring entries up to date, failed. Rebuild to try again.
nullwhen there's no fault. Starting a build clears it, and so does a refresh that finds the entries up to date. The source changes waiting for
POST .../apply: sources added that the knowledge base doesn't use yet, which sync meanwhile, sources removed that it uses until then, andfilessources with a new file it doesn't use yet. Before the first build nothing waits, since the first build applies them.Whether the knowledge base has at least one website source.
The maximum number of website sources the knowledge base can have. Adding one more returns
409with codewebSourceRootLimitExceeded.Whether the knowledge base has at least one Sanity dataset source.
Whether the knowledge base has at least one uploaded file source.
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 byexcludedSourceChunks, and those of documents whose content another document repeats, which builds skip. Documents still being converted add theirs once converted.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.
- buildRestrictionrequired
Why a build request would be denied right now, or
nullif you can build. OnlyGET .../knowledge-bases/{knowledgeBaseId}checks it. List and create responses always returnnull. 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. OnlyGET .../knowledge-bases/{knowledgeBaseId}computes it, so list responses returnfalse.The number of open issues waiting for review. Always
0before the first build.The number of active instructions for the knowledge base.
- createdByrequired
Who created the knowledge base.
nullif unknown.Show child attributes
- idrequired
The Sanity user ID, or
sanity-systemwhen Sanity Context made the change.nullif unknown.Show child attributes
- string
- null
- displayNamerequired
The user's name when the action happened.
nullif unknown. For the current name, look up the user byid.Show child attributes
- string
- null
- null
When the knowledge base was created.
When the knowledge base was last updated.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Delete a knowledge base
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}Deletes the knowledge base and everything it owns: its sources, revisions, stored source files, and its documents in your organization's document store. The knowledge base is gone when the response returns. Its documents and stored files are removed in the background shortly after, so a query can still return them for a short time. While a build, refresh, apply, or sync is running, the request returns 409 with code buildInFlight. Retry after that work finishes. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
The knowledge base was deleted.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Start a knowledge base build
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/buildQueues a build over the knowledge base's current sources and returns a job ID immediately. Follow its progress with GET .../jobs/{jobId}. 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. If the organization's other knowledge bases already use all the source chunks its plan allows, the request returns 403 with code planLimitReached. The knowledge base's buildRestriction shows this before you build. If background jobs are unavailable, the request returns 503 with code jobsUnavailable. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Header parameters
- Idempotency-Keystring
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
A queued job that you can poll for progress.
The queued job's ID. Check its progress with
GET .../jobs/{jobId}. Treat it as an opaque string. Its format can change.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Cancel a knowledge base build
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/build/cancelCancels the running build and resets the knowledge base so you can build it again. Returns cancelled: false when no build is running. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
The result of the cancel request.
Whether a running build was cancelled.
falsewhen no build was running.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
sources
Add and sync the websites, Sanity datasets and files a knowledge base reads documents from.
List sources
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sourcesLists 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 and sorted by source ID, not by when the sources were added. Requires read access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Query parameters
- cursorstring
The
nextCursorvalue from the previous page. Omit it to get the first page. The maximum number of items to return.
Responses
A page of sources.
The items on this page.
Show child attributes
items
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
webis a crawled website.The URL the crawl starts from.
Options that control how a website is crawled.
Show child attributes
- includePathsarray
Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.
Show child attributes
items
- string
- excludePathsarray
Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.
Show child attributes
items
- string
- maxDepthinteger
How many levels deep the crawl goes from the root URL.
- sitemapOnlyboolean
Whether to crawl only the pages listed in the site's sitemap.
- singlePageboolean
Whether to add only the page at the URL, without crawling the pages under it. The other options are kept but don't apply while this is
true. - ignoreQueryParametersboolean
Whether to treat URLs that differ only by query string as one page. New crawls set it to
trueunless you set it. Set it tofalsewhen the query string selects different content, such as pagination. - pageLimitinteger
The maximum number of pages to crawl, up to 5,000. Defaults to 5,000. The crawl can stop sooner when the knowledge base reaches its source limit.
- syncFrequencyrequired
How often the source syncs on its own:
weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullwhen it syncs only when asked to.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
sanity-datasetis a GROQ query over a Sanity dataset.The ID of the Sanity project the documents come from.
The dataset the documents come from.
The GROQ query that selects the documents.
- syncFrequencyrequired
How often the source syncs on its own:
weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullwhen it syncs only when asked to.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
filesis an uploaded file or archive of files.- filenamerequired
The name of the file last synced.
nullbefore the first upload.Show child attributes
- string
- null
- sizeBytesrequired
The size of the file last synced, in bytes.
nullbefore the first upload.Show child attributes
- integer
- null
- nextCursorrequired
The cursor for the next page. Pass it as
cursorto get more results.nullwhen there are no more pages.Show child attributes
- string
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Add a source
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sourcesAdds a source to a knowledge base. Set type to choose what it reads:
web: a website, crawled fromurlsanity-dataset: the documents a GROQ query selects in a Sanity datasetfiles: files you upload withPOST .../sources/{sourceId}/uploads, or text you send incontent
A 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. A files source added without content is deleted when 24 hours pass with no sync and no new upload. For a website, set dryRun to true to preview the crawl without adding the source. To have a website or dataset sync on its own, set syncFrequency afterwards with PATCH .../sources/{sourceId}.
On a knowledge base that was built, the source syncs but the knowledge base doesn't use its documents, with pending set to added, until you call POST .../apply or send apply set to true.
A knowledge base can have up to 25 websites. Adding a website that is already a source returns 409 with code webSourceRootConflict, and adding one past the limit returns 409 with code webSourceRootLimitExceeded. When the preview can't be made, dryRun returns 502 with code crawlPreviewUnavailable. When the organization's knowledge bases already hold as many source chunks as its plan allows, the request returns 403 with code planLimitReached, with the plan's limit and the current usage in fields, and adds nothing.
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. Without the role, the request returns 403 with code projectAdminRequired, and without the read access, 403 with code datasetReadAccessDenied. A query that isn't valid GROQ returns 422 with code invalidGroqFilter, and a query that selects no published documents returns 422 with code datasetSourceEmpty. A dataset that is already a source of the knowledge base with a different query returns 409 with code datasetAlreadyBound; with the same query, the request returns the existing source.
Supports the Idempotency-Key header. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Header parameters
- Idempotency-Keystring
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.
Request body application/json
The source type.
webcrawls a website.The page to add, or to start crawling from. It must be a public
httporhttpsURL.- crawlOptionsobject
Options for the crawl. Options you omit use the defaults.
Show child attributes
- includePathsarray
Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.
Show child attributes
items
- string
- excludePathsarray
Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.
Show child attributes
items
- string
- maxDepthinteger
How many levels deep the crawl goes from the root URL.
- sitemapOnlyboolean
Whether to crawl only the pages listed in the site's sitemap.
- singlePageboolean
Whether to add only the page at the URL, without crawling the pages under it. The other options are kept but don't apply while this is
true. - ignoreQueryParametersboolean
Whether to treat URLs that differ only by query string as one page. New crawls set it to
trueunless you set it. Set it tofalsewhen the query string selects different content, such as pagination. - pageLimitinteger
The maximum number of pages to crawl, up to 5,000. Defaults to 5,000. The crawl can stop sooner when the knowledge base reaches its source limit.
- dryRunboolean
Set to
trueto estimate what a crawl would fetch without adding the source. The response is then200with a preview of the pages the site has, grouped by path. The preview leaves out pages that the include and exclude patterns incrawlOptionsrule out. - applyboolean
Set to
trueto have the knowledge base use the source at once instead of waiting forPOST .../apply. A knowledge base that was never built uses a new source at once anyway, since its first build applies it.
The source type.
sanity-datasetreads documents from a Sanity dataset.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.
The dataset to read documents from.
A GROQ query that selects the documents, with an optional projection. Each sync runs it again.
- applyboolean
Set to
trueto have the knowledge base use the source at once instead of waiting forPOST .../apply. A knowledge base that was never built uses a new source at once anyway, since its first build applies it.
The source type.
filesholds an uploaded file, or text sent withcontent.The source's title.
- contentstring
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. - contentTypestring
The format of
content:text/markdown(the default) ortext/plain. Only withcontent. - applyboolean
Set to
trueto have the knowledge base use the source at once instead of waiting forPOST .../apply. A knowledge base that was never built uses a new source at once anyway, since its first build applies it.
Responses
The preview of a crawl, when dryRun is true.
How many pages the crawl would fetch, roughly. It includes the page at the URL unless the include and exclude patterns rule it out.
Roughly how many pages exist at and under the URL, before the include and exclude patterns. Equal to
totalPageswhen there are no patterns.Whether the site has more pages than the preview counted.
The largest groups of pages by path, largest first.
How many of the pages the map listed are outside
groups.The pages
totalPagescounts, as full URLs sorted by path. The page at the URL comes first when it is included. At most 500: with more, the first 250 and the last 250.Show child attributes
items
- string
The source that was added.
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
webis a crawled website.The URL the crawl starts from.
Options that control how a website is crawled.
Show child attributes
- includePathsarray
Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.
Show child attributes
items
- string
- excludePathsarray
Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.
Show child attributes
items
- string
- maxDepthinteger
How many levels deep the crawl goes from the root URL.
- sitemapOnlyboolean
Whether to crawl only the pages listed in the site's sitemap.
- singlePageboolean
Whether to add only the page at the URL, without crawling the pages under it. The other options are kept but don't apply while this is
true. - ignoreQueryParametersboolean
Whether to treat URLs that differ only by query string as one page. New crawls set it to
trueunless you set it. Set it tofalsewhen the query string selects different content, such as pagination. - pageLimitinteger
The maximum number of pages to crawl, up to 5,000. Defaults to 5,000. The crawl can stop sooner when the knowledge base reaches its source limit.
- syncFrequencyrequired
How often the source syncs on its own:
weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullwhen it syncs only when asked to.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
sanity-datasetis a GROQ query over a Sanity dataset.The ID of the Sanity project the documents come from.
The dataset the documents come from.
The GROQ query that selects the documents.
- syncFrequencyrequired
How often the source syncs on its own:
weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullwhen it syncs only when asked to.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
filesis an uploaded file or archive of files.- filenamerequired
The name of the file last synced.
nullbefore the first upload.Show child attributes
- string
- null
- sizeBytesrequired
The size of the file last synced, in bytes.
nullbefore the first upload.Show child attributes
- integer
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Get a source
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}Returns a source with its settings, document counts and latest sync. A source the knowledge base doesn't have returns 404 with code sourceNotFound. Requires read access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The source's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
The source.
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
webis a crawled website.The URL the crawl starts from.
Options that control how a website is crawled.
Show child attributes
- includePathsarray
Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.
Show child attributes
items
- string
- excludePathsarray
Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.
Show child attributes
items
- string
- maxDepthinteger
How many levels deep the crawl goes from the root URL.
- sitemapOnlyboolean
Whether to crawl only the pages listed in the site's sitemap.
- singlePageboolean
Whether to add only the page at the URL, without crawling the pages under it. The other options are kept but don't apply while this is
true. - ignoreQueryParametersboolean
Whether to treat URLs that differ only by query string as one page. New crawls set it to
trueunless you set it. Set it tofalsewhen the query string selects different content, such as pagination. - pageLimitinteger
The maximum number of pages to crawl, up to 5,000. Defaults to 5,000. The crawl can stop sooner when the knowledge base reaches its source limit.
- syncFrequencyrequired
How often the source syncs on its own:
weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullwhen it syncs only when asked to.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
sanity-datasetis a GROQ query over a Sanity dataset.The ID of the Sanity project the documents come from.
The dataset the documents come from.
The GROQ query that selects the documents.
- syncFrequencyrequired
How often the source syncs on its own:
weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullwhen it syncs only when asked to.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
filesis an uploaded file or archive of files.- filenamerequired
The name of the file last synced.
nullbefore the first upload.Show child attributes
- string
- null
- sizeBytesrequired
The size of the file last synced, in bytes.
nullbefore the first upload.Show child attributes
- integer
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Update a source
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}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 replace the stored ones, except that an omitted ignoreQueryParameters keeps its current value. They delete the documents whose path they leave out, and pages they let in are fetched by the next sync: start one with POST .../sources/{sourceId}/syncs to fetch them now. 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.
Crawl 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. A source the knowledge base doesn't have returns 404 with code sourceNotFound.
A new query 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. Without the role, the request returns 403 with code projectAdminRequired, and without the read access, 403 with code datasetReadAccessDenied. A query that isn't valid GROQ returns 422 with code invalidGroqFilter, and a query that selects no published documents returns 422 with code datasetSourceEmpty.
Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The source's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
- titlestring
The source's title.
- crawlOptionsobject
For a
websource, the crawl options, replacing the stored ones. An omittedignoreQueryParameterskeeps its current value. Documents whose path the new include and exclude paths leave out are deleted, and pages they newly let in are fetched by the next sync.Show child attributes
- includePathsarray
Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.
Show child attributes
items
- string
- excludePathsarray
Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.
Show child attributes
items
- string
- maxDepthinteger
How many levels deep the crawl goes from the root URL.
- sitemapOnlyboolean
Whether to crawl only the pages listed in the site's sitemap.
- singlePageboolean
Whether to add only the page at the URL, without crawling the pages under it. The other options are kept but don't apply while this is
true. - ignoreQueryParametersboolean
Whether to treat URLs that differ only by query string as one page. New crawls set it to
trueunless you set it. Set it tofalsewhen the query string selects different content, such as pagination. - pageLimitinteger
The maximum number of pages to crawl, up to 5,000. Defaults to 5,000. The crawl can stop sooner when the knowledge base reaches its source limit.
- querystring
For a
sanity-datasetsource, the GROQ query, replacing the stored one. A sync is queued, and removes the documents the query no longer returns. For a
weborsanity-datasetsource, how often it syncs on its own:weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullstops scheduled syncs, and you can still start a sync yourself. Setting a frequency requires a plan that includes scheduled syncs; without one, the request returns403with codefeatureNotInPlan.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
Responses
The source with the changes made.
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
webis a crawled website.The URL the crawl starts from.
Options that control how a website is crawled.
Show child attributes
- includePathsarray
Regular expressions for URL paths to crawl. When set, the crawl only includes pages whose path matches one of them.
Show child attributes
items
- string
- excludePathsarray
Regular expressions for URL paths to skip. Pages whose path matches one of them aren't crawled.
Show child attributes
items
- string
- maxDepthinteger
How many levels deep the crawl goes from the root URL.
- sitemapOnlyboolean
Whether to crawl only the pages listed in the site's sitemap.
- singlePageboolean
Whether to add only the page at the URL, without crawling the pages under it. The other options are kept but don't apply while this is
true. - ignoreQueryParametersboolean
Whether to treat URLs that differ only by query string as one page. New crawls set it to
trueunless you set it. Set it tofalsewhen the query string selects different content, such as pagination. - pageLimitinteger
The maximum number of pages to crawl, up to 5,000. Defaults to 5,000. The crawl can stop sooner when the knowledge base reaches its source limit.
- syncFrequencyrequired
How often the source syncs on its own:
weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullwhen it syncs only when asked to.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
sanity-datasetis a GROQ query over a Sanity dataset.The ID of the Sanity project the documents come from.
The dataset the documents come from.
The GROQ query that selects the documents.
- syncFrequencyrequired
How often the source syncs on its own:
weekly,monthlyorlive.live: a website is checked for changed pages every hour, and a dataset syncs soon after its documents change, plus a full sync once a day.nullwhen it syncs only when asked to.Show child attributes
- stringenum:
"weekly", "monthly", "live"
- null
The source's ID.
The ID (
kb…) of the knowledge base the source belongs to.The source's title.
The number of
activeandmissingdocuments.How many of those documents are converted to markdown, ready for builds.
How many of those documents have a file type that can't be converted.
How many of those documents failed to convert or were too large to.
The number of chunks in its documents' markdown, the unit usage is counted in.
- lastSyncedAtrequired
When a sync of the source last finished.
nullbefore the first one.Show child attributes
- string (date-time)
- null
- latestSyncrequired
The most recent sync, running or finished.
nullbefore the first one.Show child attributes
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- null
- pendingrequired
A change to the knowledge base's sources that waits for
POST .../apply.added: the source syncs, but the knowledge base doesn't use its documents until the change is applied.removed: the knowledge base uses its documents until the change is applied.replaced: a new file was uploaded to thisfilessource, and the knowledge base uses the current one until the change is applied.replacementFailed: the new file's sync failed, was cancelled or never started;POST .../applyrefuses until you sync the source again or discard the change, and the knowledge base keeps the current file.null: nothing waits.Show child attributes
- stringenum:
"added", "removed", "replaced", "replacementFailed"
- null
When the source was added.
When the source last changed.
The source type.
filesis an uploaded file or archive of files.- filenamerequired
The name of the file last synced.
nullbefore the first upload.Show child attributes
- string
- null
- sizeBytesrequired
The size of the file last synced, in bytes.
nullbefore the first upload.Show child attributes
- integer
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Delete a source
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}Removes a source and its documents from the knowledge base. On a knowledge base that was built, the knowledge base keeps using the source, with pending set to removed, until you call POST .../apply or send apply set to true. A source the knowledge base doesn't use yet is removed at once.
Removing a source the knowledge base uses starts a refresh that removes the citations of its documents from entries and deletes the entries left with none. The source stops syncing and is deleted once that refresh has run. A source the knowledge base doesn't have returns 404 with code sourceNotFound.
Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The source's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Query parameters
- applystring
Set to
trueto remove the source at once instead of waiting forPOST .../apply.
Responses
The source was removed, or marked to be removed.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
List a source's syncs
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncsLists the syncs of a source, newest first. Results are cursor-paginated. A source the knowledge base doesn't have returns 404 with code sourceNotFound. Requires read access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The source's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Query parameters
- cursorstring
The
nextCursorvalue from the previous page. Omit it to get the first page. The maximum number of items to return.
Responses
A page of syncs.
The items on this page.
Show child attributes
items
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
- nextCursorrequired
The cursor for the next page. Pass it as
cursorto get more results.nullwhen there are no more pages.Show child attributes
- string
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Sync a source
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncsStarts 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. The response has no job ID for it: follow it with the source's latestSync. Until the queued sync starts, latestSync still shows the previous one, so compare its createdAt with the time of your request.
For 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. 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 so does a request without uploadId on a files source that has no file yet, with fields.uploadId set to null. A file larger than 5 GB returns 413 with code uploadTooLarge. An uploadId on a source that isn't files returns 422 with code sourceTypeMismatch, and a source the knowledge base doesn't have returns 404 with code sourceNotFound.
When the knowledge base is built and already uses the source, the new file waits for POST .../apply: the sync reads and converts it, but the knowledge base keeps using the current file until then, and the source's pending is replaced. Set apply to true to use the new file at once. A new upload while one waits replaces the waiting one, and POST .../discard drops it.
Supports the Idempotency-Key header. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The source's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Header parameters
- Idempotency-Keystring
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.
Request body application/json
- uploadIdstring (uuid)
For a
filessource, theuploadIdof the file to sync, fromPOST .../sources/{sourceId}/uploads. Without it, afilessource reads its current file again. Not allowed for other types. - applyboolean
With
uploadId, set totrueto have the knowledge base use the new file at once instead of waiting forPOST .../apply. A knowledge base that was never built, or a source it doesn't use yet, uses the new file at once anyway.
Responses
The sync that was started or queued.
The ID of the source that will sync.
- jobIdrequired
For a
filessource, the ID of the sync's job. Check its progress withGET .../jobs/{jobId}; once it succeeds, itsresultnames the sync.nullfor a website or dataset, whose sync is queued on the source: follow it with the source'slatestSync.Show child attributes
- string
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Get a sync
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/syncs/{syncId}Returns one sync of a source with its status and counts. A source the knowledge base doesn't have returns 404 with code sourceNotFound, and a sync the source doesn't have returns 404 with code syncNotFound. Requires read access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The source's ID.
The sync's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
The sync.
The sync's ID.
The ID of the source the sync read.
fullreads the whole source and removes what it no longer finds.incrementalreads only what changed since the last sync.What started the sync.
schedule: the source'ssyncFrequency.manual: an API call or the dashboard, including the first sync of a website or dataset.upload: a file or text for afilessource.event: a change to the documents of asanity-datasetsource whosesyncFrequencyislive.pushis reserved and not set today.The sync's status.
running: still reading or converting.completed,failedandcancelledare final.The number of documents the sync read.
The number of documents the sync added or changed.
The number of documents the sync read that had not changed.
The number of documents the sync deleted.
The number of web pages the sync marked
missingbecause several crawls in a row didn't find them.- partialReasonrequired
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.nullwhen the sync read the whole source, or hasn't finished.Show child attributes
- stringenum:
"page-limit", "source-limit", "stalled", "time-limit"
- null
- errorrequired
Why the sync failed, written to show to users.
nullunlessstatusisfailed.Show child attributes
- string
- null
When the sync started.
- finishedAtrequired
When the sync finished.
nullwhile it isrunning.Show child attributes
- string (date-time)
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Upload a file to a source
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/sources/{sourceId}/uploadsReturns a signed URL for one file of a files source, valid for one hour. To add the file:
- Send the file as the body of a
PUTrequest touploadUrl. If you setcontentType, send the sameContent-Typeheader. Sending to the URL again replaces the file. - Call
POST .../sources/{sourceId}/syncswith theuploadId.
The file replaces the source's current file when it syncs. An upload no sync takes within 24 hours is deleted.
The file can be up to 5 GB. It can be a single document or a zip, tar or gzip archive of them. An archive can unpack to 200 times its size, at least 1 GB and at most 20 GB; a larger one fails its sync. A file over 1 GB, alone or in an archive, is listed as a document with conversion set to oversized, and isn't read. The format of each file is detected from its contents and its name. PDF, Word, Excel, PowerPoint, OpenDocument, EPUB, RTF, HTML and image files are converted to markdown up to 50 MB each. Markdown, text, code and data files such as JSON, CSV and YAML are read as they are. A file in any other format becomes a short markdown summary of its name, media type and size.
A source that isn't files returns 422 with code sourceTypeMismatch, and a source the knowledge base doesn't have returns 404 with code sourceNotFound. When the organization's knowledge bases already hold as many source chunks as its plan allows, the request returns 403 with code planLimitReached. Supports the Idempotency-Key header. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The source's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Header parameters
- Idempotency-Keystring
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.
Request body application/json
The file's name.
- contentTypestring
The media type of the file. When set, the
PUTrequest must send the sameContent-Typeheader.
Responses
Where to upload the file.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Sync every source
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/syncQueues 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, and new documents still waiting from earlier syncs, go into the knowledge base's entries as soon as they are ready instead of after the usual wait. Many new documents can take more than one update to go in. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
The syncs that were queued.
The IDs of the sources that will sync. Follow each with the source's
latestSync.filessources aren't included: they sync when you upload a file.Show child attributes
items
- string (uuid)
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Apply source changes
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/applyQueues a job that applies the sources added to or removed from a built knowledge base, and the new files uploaded to its files sources, and returns its job ID. Until then, an added source syncs but the knowledge base doesn't use its documents, a removed source stays in use, and a source with a new file keeps its current one. Each source shows what waits in pending, and the knowledge base counts it in pendingSources.
The job takes the added sources' documents into the knowledge base, and removes the citations of the removed sources' documents from entries, deleting the entries left with none. A new file replaces the current one, and the knowledge base updates the entries that cite it. Its result counts the sources it applied; with nothing waiting it changes nothing. An apply asked for while the knowledge base is building or updating starts when that work ends. Changes inside a source the knowledge base already uses, such as pages a sync finds edited, need no apply.
While an added source's sync runs, or while an added source that never synced waits for its first sync to start (a files source still waiting for its first file doesn't count), or while a new file's sync runs or is about to start, the request returns 409 with code sourcesSyncing and fields.sourceIds naming those sources, and applies nothing. Send it again once they finish. A new file whose sync failed, was cancelled or never started isn't applied and keeps waiting, with pending set to replacementFailed: upload it again, or discard the change with POST .../discard. A new file on a source whose removal also waits isn't applied: the removal is.
Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
A queued job that you can poll for progress.
The queued job's ID. Check its progress with
GET .../jobs/{jobId}. Treat it as an opaque string. Its format can change.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Discard source changes
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/discardDrops the source changes waiting for POST .../apply, at once. Added sources are removed from the knowledge base and deleted with their documents. Removed sources stay, and their pending goes back to null. A new file waiting on a source is dropped and the source keeps its current one. While the sync of a new file runs or is about to start, the request returns 409 with code sourcesSyncing and fields.sourceIds naming those sources, and discards nothing. Returns the counts of what was discarded; with nothing waiting it changes nothing. An apply already queued finds nothing left to apply. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
The source changes that waited for POST .../apply and were discarded: added sources now removed from the knowledge base, removals the knowledge base now keeps, and new files dropped.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
documents
Read and remove the documents sources yield, which builds read and cite.
List documents
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/documentsLists 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. Requires read access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Query parameters
- cursorstring
The
nextCursorvalue from the previous page. Omit it to get the first page. The maximum number of items to return.
- sourcestring (uuid)
Return only the documents of this source.
- statestring
Return only documents in this state. Without it,
deleteddocuments are left out. - idsstring
Comma-separated IDs of the documents to return, up to 200, in any state. IDs that match no document are left out. The results are still paginated, so set
limitto at least the number of IDs to get them in one page. Use it to look up the documents entry citations point at.
Responses
A page of documents.
The items on this page.
Show child attributes
items
The document's ID. Entry citations point at it.
The ID of the source the document comes from.
The type of the source the document comes from.
The document's identity in its source: the page URL, the dataset document
_id, or the file's path in the upload.The document's title, or its
externalIdwhen it has none.- urlrequired
Where the document lives on the web.
nullfor files and dataset documents.Show child attributes
- string
- null
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.- mimerequired
The media type of the document as read.
nullbefore its content was read.Show child attributes
- string
- null
- sizeBytesrequired
The size of the document as read, in bytes.
nullbefore its content was read.Show child attributes
- integer
- null
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, seeconversionError.- conversionErrorrequired
Why conversion failed.
nullunlessconversionisfailedoroversized.Show child attributes
- string
- null
- truncationrequired
Set when the document is longer than the most pages conversion reads from one file (5,000), so only its first
pagesReadpages are in the knowledge base. To include the rest, split the file into parts of at most 5,000 pages and upload those.nullwhen every page was converted.Show child attributes
How many pages were converted, from the first.
How many pages the document has.
- null
- excludedAtrequired
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.
nullwhile builds include it.Show child attributes
- string (date-time)
- null
- documentUpdatedAtrequired
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.nullwhen it doesn't say.Show child attributes
- string (date-time)
- null
When a sync last found the document in its source.
When the document was first read.
When the document last changed.
- nextCursorrequired
The cursor for the next page. Pass it as
cursorto get more results.nullwhen there are no more pages.Show child attributes
- string
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Get a document
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}Returns a document with its conversion status and the chunks of its markdown. Entry citations point at a document's chunks. A document the knowledge base doesn't have returns 404 with code documentNotFound. Requires read access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The document's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
A document with the chunks of its markdown.
The document's ID. Entry citations point at it.
The ID of the source the document comes from.
The type of the source the document comes from.
The document's identity in its source: the page URL, the dataset document
_id, or the file's path in the upload.The document's title, or its
externalIdwhen it has none.- urlrequired
Where the document lives on the web.
nullfor files and dataset documents.Show child attributes
- string
- null
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.- mimerequired
The media type of the document as read.
nullbefore its content was read.Show child attributes
- string
- null
- sizeBytesrequired
The size of the document as read, in bytes.
nullbefore its content was read.Show child attributes
- integer
- null
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, seeconversionError.- conversionErrorrequired
Why conversion failed.
nullunlessconversionisfailedoroversized.Show child attributes
- string
- null
- truncationrequired
Set when the document is longer than the most pages conversion reads from one file (5,000), so only its first
pagesReadpages are in the knowledge base. To include the rest, split the file into parts of at most 5,000 pages and upload those.nullwhen every page was converted.Show child attributes
How many pages were converted, from the first.
How many pages the document has.
- null
- excludedAtrequired
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.
nullwhile builds include it.Show child attributes
- string (date-time)
- null
- documentUpdatedAtrequired
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.nullwhen it doesn't say.Show child attributes
- string (date-time)
- null
When a sync last found the document in its source.
When the document was first read.
When the document last changed.
The chunks of the document's current markdown, in order. Empty until
conversionisconverted.Show child attributes
items
The chunk's ID. Entry citations point at it.
The headings above the chunk, outermost first. Empty before the first heading.
Show child attributes
items
- string
The chunk's first line in the markdown, from 1.
The chunk's last line in the markdown, inclusive.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Keep a missing document
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}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, and a document the knowledge base doesn't have returns 404 with code documentNotFound. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The document's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
Set to
activeto keep amissingpage in the knowledge base. The count of crawls that missed it starts again.
Responses
The document, now active.
The document's ID. Entry citations point at it.
The ID of the source the document comes from.
The type of the source the document comes from.
The document's identity in its source: the page URL, the dataset document
_id, or the file's path in the upload.The document's title, or its
externalIdwhen it has none.- urlrequired
Where the document lives on the web.
nullfor files and dataset documents.Show child attributes
- string
- null
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.- mimerequired
The media type of the document as read.
nullbefore its content was read.Show child attributes
- string
- null
- sizeBytesrequired
The size of the document as read, in bytes.
nullbefore its content was read.Show child attributes
- integer
- null
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, seeconversionError.- conversionErrorrequired
Why conversion failed.
nullunlessconversionisfailedoroversized.Show child attributes
- string
- null
- truncationrequired
Set when the document is longer than the most pages conversion reads from one file (5,000), so only its first
pagesReadpages are in the knowledge base. To include the rest, split the file into parts of at most 5,000 pages and upload those.nullwhen every page was converted.Show child attributes
How many pages were converted, from the first.
How many pages the document has.
- null
- excludedAtrequired
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.
nullwhile builds include it.Show child attributes
- string (date-time)
- null
- documentUpdatedAtrequired
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.nullwhen it doesn't say.Show child attributes
- string (date-time)
- null
When a sync last found the document in its source.
When the document was first read.
When the document last changed.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Delete a document
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}Deletes a document from its source. The document stays listed with state set to deleted, and deleting it again returns 204. 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. A document the knowledge base doesn't have returns 404 with code documentNotFound. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The document's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
The document was deleted.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Get a document's markdown
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/documents/{documentId}/contentReturns 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. Setting both chunk and lines, or either one with format=raw, returns 400 with code validationError. Until the document is converted, the request returns 409 with code documentNotConverted. A document the knowledge base doesn't have returns 404 with code documentNotFound, and a chunk the document doesn't have returns 404 with code chunkNotFound. Chunk IDs follow the document's headings, so a chunk a citation names can be gone once the document changes. With format=raw it returns the document as its source gave it, as a file download: the body has the document's media type, and the Content-Disposition header names the file. A web page downloads as a .md file and a dataset document as a .json file. When the document was too large to keep, format=raw returns 409 with code documentNotStored. Requires read access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The document's ID.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Query parameters
- formatstring
Response format.
json(default) returns the markdown with its line numbers.markdownandplainreturn the markdown alone, ready to pass to a model.rawreturns the document as its source gave it, before conversion: an uploaded file as it was uploaded, a web page as the markdown the crawl read from it, and a dataset document as JSON. - chunkstring (uuid)
Return only this chunk's lines. Citations name the chunk they quote.
- linesstring
Return only these lines, from 1 and inclusive:
10-20, or10for line 10 to the end. A range past the end returns up to the last line.
Responses
A document's markdown, or a range of its lines.
The document's ID.
- chunkIdrequired
The chunk the content was limited to.
nullwhen nochunkwas requested.Show child attributes
- string (uuid)
- null
The document's markdown, or the requested lines of it.
The number of lines in the whole markdown.
The lines returned, from 1 and inclusive. Shorter than requested when the range runs past the end. Both are
0when no lines are returned.
text/markdowntext/plainapplication/octet-streamThe request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
jobs
Check the status of background jobs, such as builds and syncs.
Get a job
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/jobs/{jobId}Returns the status of a background job: a build, an update, a sync, a restore or an apply. The endpoint that starts the work returns the job ID. Poll until status is succeeded, failed or cancelled. An ID that is not a job of this knowledge base returns 404 with code jobNotFound, and so does a job cancelled before it started, since it never ran. If background jobs are unavailable, the request returns 503 with code jobsUnavailable. Requires read access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The job ID returned by the endpoint that started the work.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
A background job, such as a build, an update, a sync, a restore or an apply, and its status. kind says which, and determines the shape of result.
The job's ID. Treat it as an opaque string. Its format can change.
The ID (
kb…) of the knowledge base the job belongs to.The job's status.
queued: waiting for earlier work on the knowledge base to finish, or for build capacity.running: in progress.succeeded: finished successfully.failed: stopped with an error.cancelled: stopped before it finished.succeeded,failedandcancelledare final.pendingis reserved and isn't returned today.- startedAtrequired
When the job started. Can be
nullwhilestatusisqueued.Show child attributes
- string (date-time)
- null
- completedAtrequired
When the job finished.
nullwhile the job is queued or running.Show child attributes
- string (date-time)
- null
A readable reason the job failed or was cancelled.
nullfor any other status.Show child attributes
- string
- null
- resultobject
The job's output. Only present when
statusissucceeded.Show child attributes
The revision the build produced.
How many entries the built outline has.
How many issues the build filed.
How many questions the build left open for you to answer.
The job's ID. Treat it as an opaque string. Its format can change.
The ID (
kb…) of the knowledge base the job belongs to.The job's status.
queued: waiting for earlier work on the knowledge base to finish, or for build capacity.running: in progress.succeeded: finished successfully.failed: stopped with an error.cancelled: stopped before it finished.succeeded,failedandcancelledare final.pendingis reserved and isn't returned today.- startedAtrequired
When the job started. Can be
nullwhilestatusisqueued.Show child attributes
- string (date-time)
- null
- completedAtrequired
When the job finished.
nullwhile the job is queued or running.Show child attributes
- string (date-time)
- null
A readable reason the job failed or was cancelled.
nullfor any other status.Show child attributes
- string
- null
- resultobject
The job's output. Only present when
statusissucceeded.Show child attributes
- revisionIdrequired
The revision the update produced.
nullwhen no entry changed.Show child attributes
- string
- null
How many entries were rewritten.
The job's ID. Treat it as an opaque string. Its format can change.
The ID (
kb…) of the knowledge base the job belongs to.The job's status.
queued: waiting for earlier work on the knowledge base to finish, or for build capacity.running: in progress.succeeded: finished successfully.failed: stopped with an error.cancelled: stopped before it finished.succeeded,failedandcancelledare final.pendingis reserved and isn't returned today.- startedAtrequired
When the job started. Can be
nullwhilestatusisqueued.Show child attributes
- string (date-time)
- null
- completedAtrequired
When the job finished.
nullwhile the job is queued or running.Show child attributes
- string (date-time)
- null
A readable reason the job failed or was cancelled.
nullfor any other status.Show child attributes
- string
- null
- resultobject
The job's output. Only present when
statusissucceeded.Show child attributes
The job's ID. Treat it as an opaque string. Its format can change.
The ID (
kb…) of the knowledge base the job belongs to.The job's status.
queued: waiting for earlier work on the knowledge base to finish, or for build capacity.running: in progress.succeeded: finished successfully.failed: stopped with an error.cancelled: stopped before it finished.succeeded,failedandcancelledare final.pendingis reserved and isn't returned today.- startedAtrequired
When the job started. Can be
nullwhilestatusisqueued.Show child attributes
- string (date-time)
- null
- completedAtrequired
When the job finished.
nullwhile the job is queued or running.Show child attributes
- string (date-time)
- null
A readable reason the job failed or was cancelled.
nullfor any other status.Show child attributes
- string
- null
- resultobject
The job's output. Only present when
statusissucceeded.Show child attributes
The job's ID. Treat it as an opaque string. Its format can change.
The ID (
kb…) of the knowledge base the job belongs to.The job's status.
queued: waiting for earlier work on the knowledge base to finish, or for build capacity.running: in progress.succeeded: finished successfully.failed: stopped with an error.cancelled: stopped before it finished.succeeded,failedandcancelledare final.pendingis reserved and isn't returned today.- startedAtrequired
When the job started. Can be
nullwhilestatusisqueued.Show child attributes
- string (date-time)
- null
- completedAtrequired
When the job finished.
nullwhile the job is queued or running.Show child attributes
- string (date-time)
- null
A readable reason the job failed or was cancelled.
nullfor any other status.Show child attributes
- string
- null
- resultobject
The job's output. Only present when
statusissucceeded.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
entries
Rebuild individual entries in a knowledge base. To read entries, query sanity.context.entry documents with GROQ.
Rebuild an entry from its sources
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/entries/{entryPath}/rebuildQueues a rewrite of the entry at entryPath from its cited sources and the active instructions, and returns a job ID immediately. Only this entry is rewritten. 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 when they are next rebuilt. Every rebuild of the same entry uses the same job ID, so a request made while one is waiting or running joins it. Returns 404 with code entryNotFound if the knowledge base has no entry at that path, and 422 with code entryDocumentInvalid if the entry document was edited into a shape the API cannot read. If background jobs are unavailable, the request returns 503 with code jobsUnavailable. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The entry's slash-delimited path, such as
pricing/plans/free, URL-encoded.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
The job that rebuilds the entry, and the other entries that share its sources.
ID of the job that rebuilds the entry. Poll it with
GET .../jobs/{jobId}.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.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
issues
Triage the issues that builds and refreshes find.
Accept and apply issues
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/issues/applyAccepts the issues in issueIds, then queues a job that applies them, rewrites the affected entries, and saves a new revision. Returns a job ID. Every apply in a knowledge base uses the same job ID. If an apply is already waiting to run, these issues join it. If one is already running, these issues are applied in a run that follows it, under the same ID. IDs of issues that no longer exist are skipped. Dismissed issues are skipped. If none of the IDs exist, the request still returns 202 and a job ID. 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. Returns 409 with code issueTransitionConflict, and accepts none of the issues, if another change to one of them happened at the same time. Returns 422 with code issueDocumentInvalid if one of the issue documents was edited into a shape the API cannot verify. Returns 503 with code jobsUnavailable if the job cannot be queued. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
The IDs of the issues to accept and apply.
Show child attributes
items
- string
Responses
A queued job that you can poll for progress.
The queued job's ID. Check its progress with
GET .../jobs/{jobId}. Treat it as an opaque string. Its format can change.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Dismiss an issue
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/dismissMarks the issue as rejected. If the issue already left triage, the request returns it unchanged. Returns 404 with code issueNotFound if the knowledge base has no issue with this ID. 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. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The issue's document ID, such as
issue.01JD4M6X8Q2V7N3K5R9T0WYZAB. Find it by querying the knowledge base'ssanity.context.issuedocuments with GROQ.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
An issue found in a knowledge base, and its triage status.
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.
The ID (
kb...) of the knowledge base the issue belongs to.- contentrequired
What an issue found. The shape depends on
kind.Show child attributes
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.Path of the entry the issue is about, or
*when it applies to the whole knowledge base.What the problem is, in one or two sentences.
What to do to fix the issue.
The issue type.
conflictmeans two or more positions disagree on the same fact, and you choose which one is correct.A key naming the disputed fact, such as
free_tier.request_limit. It never includes the disputed value, so every side shares it.- contextstring
One sentence that explains the question, when it needs one.
The conflicting positions, at least two. To resolve the conflict, pass the index of one side as
resolution, or'all'when every side is correct for its own case.Show child attributes
items
The position as a self-contained sentence. This is the option you choose from.
- valuestring
The disputed value on its own, such as
10,000/month, without the sentence. - entryPathsarray
Paths of the entries that state this position.
Show child attributes
items
- string
- documentIdsarray
IDs of the documents that directly back this position.
Show child attributes
items
- string
- wherestring
The documents that state this value, by the names you know them by.
- citationsarray
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.
Show child attributes
items
Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a
[^key]marker.ID of the document the quote comes from. Read it with
GET .../documents/{documentId}/content.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.
The document's name when the entry was written.
- urlstring
Where the document lives on the web. Absent for uploaded files and datasets.
The passage from the document that backs the claims, copied word for word.
Up to 32 characters of document text just before the quote, to tell repeats apart.
Up to 32 characters of document text just after the quote, to tell repeats apart.
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.Last line of the quote, inclusive.
- suggestedinteger
Index in
sidesof the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.
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.Path of the entry the issue is about, or
*when it applies to the whole knowledge base.What the problem is, in one or two sentences.
What to do to fix the issue.
The issue type.
update_requiredmeans an entry is out of date with its sources or contradicts an instruction, and needs a rewrite.- citedDocumentIdsarray
IDs of the documents that led to the issue.
Show child attributes
items
- string
- claimKeystring
A key naming the specific finding, when the check that found it sets one.
- involvedScopesarray
Paths of the entries the issue involves, when it spans more than one entry.
Show child attributes
items
- string
The triage status.
open: waiting for triage.accepted: accepted withPOST .../issues/apply, or a conflict resolved to one side or to all sides.rejected: dismissed. A rejected issue stays rejected. You can return an accepted conflict toopenwithPOST .../issues/{issueId}/reopen.- resolutionrequired
How the conflict was resolved: the index in
content.sidesof the side chosen, or'all'when every side was marked correct for its own case. For a conflict on a single entry, index0is the entry's current content.nulluntil a conflict is resolved, and alwaysnullfor other issue types.Show child attributes
- integer
- string
- null
- resolvedByrequired
Who triaged the issue, so you can review what your agents decided.
nullwhile the issue is open, or when the caller could not be identified. When the issue was first filed.
- resolvedAtrequired
When the issue left
open.nullwhile the issue is open.Show child attributes
- string (date-time)
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Resolve a conflict issue
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/resolveResolves a conflict issue. Set resolution to the index of a side in content.sides, or to 'all' when every side is correct for its own case. The response's issue.resolvedBy records the caller, taken from the token. The decision is saved as an instruction with origin set to conflict, tied to the conflict's documents, and later builds apply it. If none of those documents still exist, no instruction is saved. For a conflict on a single entry, index 0 is the entry's current content and keeps it. Any other side also queues a rewrite of that entry, and jobId tracks it. In every other case, including a conflict whose scopePath is *, jobId is null. After saving the instruction, Sanity Context checks the entries built from its documents against it in the background. That check counts toward the organization's model spend and can file update_required issues for entries that contradict the decision. A resolved conflict is not asked again until one of its documents changes. To change a decision, resolve the accepted conflict again. Other issue types, dismissed conflicts, and out-of-range indexes return 422 with code issueNotResolvable. Choosing a side that rewrites an entry that no longer exists returns 409 with code issueNotAutoApplicable. Returns 404 with code issueNotFound if the knowledge base has no issue with this ID, 422 with code issueDocumentInvalid if the issue document was edited into a shape the API cannot verify, and 409 with code issueTransitionConflict if another change to the issue happened at the same time. If the rewrite cannot be queued, the request returns 503 with code jobsUnavailable after the decision is saved. Retry the same request to queue the rewrite. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The issue's document ID, such as
issue.01JD4M6X8Q2V7N3K5R9T0WYZAB. Find it by querying the knowledge base'ssanity.context.issuedocuments with GROQ.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
- resolutionrequired
The index of the chosen side in the issue's
content.sides, or'all'when every side is correct for its own case.Show child attributes
- integer
- stringenum:
"all"
Responses
The resolved issue, plus the job that rewrites the entry, if any.
An issue found in a knowledge base, and its triage status.
Show child attributes
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.
The ID (
kb...) of the knowledge base the issue belongs to.- contentrequired
What an issue found. The shape depends on
kind.Show child attributes
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.Path of the entry the issue is about, or
*when it applies to the whole knowledge base.What the problem is, in one or two sentences.
What to do to fix the issue.
The issue type.
conflictmeans two or more positions disagree on the same fact, and you choose which one is correct.A key naming the disputed fact, such as
free_tier.request_limit. It never includes the disputed value, so every side shares it.- contextstring
One sentence that explains the question, when it needs one.
The conflicting positions, at least two. To resolve the conflict, pass the index of one side as
resolution, or'all'when every side is correct for its own case.Show child attributes
items
The position as a self-contained sentence. This is the option you choose from.
- valuestring
The disputed value on its own, such as
10,000/month, without the sentence. - entryPathsarray
Paths of the entries that state this position.
Show child attributes
items
- string
- documentIdsarray
IDs of the documents that directly back this position.
Show child attributes
items
- string
- wherestring
The documents that state this value, by the names you know them by.
- citationsarray
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.
Show child attributes
items
Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a
[^key]marker.ID of the document the quote comes from. Read it with
GET .../documents/{documentId}/content.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.
The document's name when the entry was written.
- urlstring
Where the document lives on the web. Absent for uploaded files and datasets.
The passage from the document that backs the claims, copied word for word.
Up to 32 characters of document text just before the quote, to tell repeats apart.
Up to 32 characters of document text just after the quote, to tell repeats apart.
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.Last line of the quote, inclusive.
- suggestedinteger
Index in
sidesof the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.
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.Path of the entry the issue is about, or
*when it applies to the whole knowledge base.What the problem is, in one or two sentences.
What to do to fix the issue.
The issue type.
update_requiredmeans an entry is out of date with its sources or contradicts an instruction, and needs a rewrite.- citedDocumentIdsarray
IDs of the documents that led to the issue.
Show child attributes
items
- string
- claimKeystring
A key naming the specific finding, when the check that found it sets one.
- involvedScopesarray
Paths of the entries the issue involves, when it spans more than one entry.
Show child attributes
items
- string
The triage status.
open: waiting for triage.accepted: accepted withPOST .../issues/apply, or a conflict resolved to one side or to all sides.rejected: dismissed. A rejected issue stays rejected. You can return an accepted conflict toopenwithPOST .../issues/{issueId}/reopen.- resolutionrequired
How the conflict was resolved: the index in
content.sidesof the side chosen, or'all'when every side was marked correct for its own case. For a conflict on a single entry, index0is the entry's current content.nulluntil a conflict is resolved, and alwaysnullfor other issue types.Show child attributes
- integer
- string
- null
- resolvedByrequired
Who triaged the issue, so you can review what your agents decided.
nullwhile the issue is open, or when the caller could not be identified. When the issue was first filed.
- resolvedAtrequired
When the issue left
open.nullwhile the issue is open.Show child attributes
- string (date-time)
- null
- jobIdrequired
ID of the job that rewrites the entry, which you can poll with
GET .../jobs/{jobId}.nullwhen nothing is rewritten: you resolved the conflict as'all', itsscopePathis*, or you chose index0of a single-entry conflict. The decision is saved as an instruction the next build applies.Show child attributes
- string
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Reopen an accepted conflict
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/issues/{issueId}/reopenReturns an accepted conflict issue to triage, clears its resolution, and deletes the instruction the resolution created. It also deletes the open issues filed for entries that contradict that instruction. Reopening does not undo an entry rewrite the resolution already queued. Reopening an open or dismissed conflict returns it unchanged. Other issue types return 422 with code issueNotResolvable. Returns 404 with code issueNotFound if the knowledge base has no issue with this ID, 422 with code issueDocumentInvalid if the issue document was edited into a shape the API cannot verify, and 409 with code issueTransitionConflict if another change to the issue happened at the same time. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The issue's document ID, such as
issue.01JD4M6X8Q2V7N3K5R9T0WYZAB. Find it by querying the knowledge base'ssanity.context.issuedocuments with GROQ.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Responses
An issue found in a knowledge base, and its triage status.
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.
The ID (
kb...) of the knowledge base the issue belongs to.- contentrequired
What an issue found. The shape depends on
kind.Show child attributes
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.Path of the entry the issue is about, or
*when it applies to the whole knowledge base.What the problem is, in one or two sentences.
What to do to fix the issue.
The issue type.
conflictmeans two or more positions disagree on the same fact, and you choose which one is correct.A key naming the disputed fact, such as
free_tier.request_limit. It never includes the disputed value, so every side shares it.- contextstring
One sentence that explains the question, when it needs one.
The conflicting positions, at least two. To resolve the conflict, pass the index of one side as
resolution, or'all'when every side is correct for its own case.Show child attributes
items
The position as a self-contained sentence. This is the option you choose from.
- valuestring
The disputed value on its own, such as
10,000/month, without the sentence. - entryPathsarray
Paths of the entries that state this position.
Show child attributes
items
- string
- documentIdsarray
IDs of the documents that directly back this position.
Show child attributes
items
- string
- wherestring
The documents that state this value, by the names you know them by.
- citationsarray
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.
Show child attributes
items
Stable ID of this citation: 10 lowercase letters and digits. An entry body points to it with a
[^key]marker.ID of the document the quote comes from. Read it with
GET .../documents/{documentId}/content.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.
The document's name when the entry was written.
- urlstring
Where the document lives on the web. Absent for uploaded files and datasets.
The passage from the document that backs the claims, copied word for word.
Up to 32 characters of document text just before the quote, to tell repeats apart.
Up to 32 characters of document text just after the quote, to tell repeats apart.
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.Last line of the quote, inclusive.
- suggestedinteger
Index in
sidesof the suggested side, when there is one. It is only a hint: nothing is chosen until you resolve the issue.
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.Path of the entry the issue is about, or
*when it applies to the whole knowledge base.What the problem is, in one or two sentences.
What to do to fix the issue.
The issue type.
update_requiredmeans an entry is out of date with its sources or contradicts an instruction, and needs a rewrite.- citedDocumentIdsarray
IDs of the documents that led to the issue.
Show child attributes
items
- string
- claimKeystring
A key naming the specific finding, when the check that found it sets one.
- involvedScopesarray
Paths of the entries the issue involves, when it spans more than one entry.
Show child attributes
items
- string
The triage status.
open: waiting for triage.accepted: accepted withPOST .../issues/apply, or a conflict resolved to one side or to all sides.rejected: dismissed. A rejected issue stays rejected. You can return an accepted conflict toopenwithPOST .../issues/{issueId}/reopen.- resolutionrequired
How the conflict was resolved: the index in
content.sidesof the side chosen, or'all'when every side was marked correct for its own case. For a conflict on a single entry, index0is the entry's current content.nulluntil a conflict is resolved, and alwaysnullfor other issue types.Show child attributes
- integer
- string
- null
- resolvedByrequired
Who triaged the issue, so you can review what your agents decided.
nullwhile the issue is open, or when the caller could not be identified. When the issue was first filed.
- resolvedAtrequired
When the issue left
open.nullwhile the issue is open.Show child attributes
- string (date-time)
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
instructions
Create standing instructions that steer every build.
Create an instruction
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructionsCreates 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. The background check counts toward the organization's model spend. Each request creates a new instruction, so retrying a request that may have succeeded can create a duplicate. Returns 422 with code instructionScopeVanished if none of the documents in scopeDocumentIds exist. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
The instruction in plain language. Builds follow it over what the sources say.
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
422with codeinstructionScopeVanished.Show child attributes
items
- string (uuid)
- rebuildPathsarray
Paths of entries to rebuild under the new instruction right away. The response returns the rebuild job ID in
rebuildJobId.Show child attributes
items
- string
- verifiedboolean
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 inrebuildPathsdoes not start.
Responses
The created instruction, and the rebuild it started.
The created instruction.
Show child attributes
The instruction's document ID.
The ID (
kb...) of the knowledge base the instruction belongs to.How the instruction was created.
human: someone wrote it.conflict: it records the side chosen, or that every side is correct, when a conflict issue was resolved. Both kinds work the same way in builds.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.The instruction in plain language. Builds follow it over what the sources say.
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.
Show child attributes
items
- string (uuid)
- archivedAtrequired
When a refresh archived the instruction.
nullwhile it is active.Show child attributes
- string (date-time)
- null
- archivedReasonrequired
Why the instruction was archived.
nullwhile it is active.Show child attributes
- string
- null
- sourceIssueIdrequired
ID of the conflict issue this instruction records.
nullwhenoriginishuman.Show child attributes
- string
- null
- createdByrequired
Who created the instruction.
nullfor instructions created by resolving a conflict, and when the creator is unknown.Show child attributes
- idrequired
The Sanity user ID, or
sanity-systemwhen Sanity Context made the change.nullif unknown.Show child attributes
- string
- null
- displayNamerequired
The user's name when the action happened.
nullif unknown. For the current name, look up the user byid.Show child attributes
- string
- null
- null
- updatedByrequired
Who last updated the instruction through the API.
nullwhen it was never updated, or when the person is unknown.Show child attributes
- idrequired
The Sanity user ID, or
sanity-systemwhen Sanity Context made the change.nullif unknown.Show child attributes
- string
- null
- displayNamerequired
The user's name when the action happened.
nullif unknown. For the current name, look up the user byid.Show child attributes
- string
- null
- null
When the instruction was created.
- updatedAtrequired
When the instruction last changed, including changes a refresh makes.
nullwhen the time is unknown.Show child attributes
- string (date-time)
- null
- rebuildJobIdrequired
ID of the job that rebuilds the entries in
rebuildPaths. Poll it withGET .../jobs/{jobId}.nullwhen you didn't passrebuildPathsor the rebuild could not start. The instruction is saved either way.Show child attributes
- string
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Check an instruction for contradictions
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructions/checkChecks 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. Although it saves nothing, as a POST it needs the same access as a write. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
The instruction in plain language, as you would pass it to create.
IDs of the documents the instruction will be tied to. The check covers every entry built from any of them.
Show child attributes
items
- string (uuid)
- excludeEntryIdstring
ID of an entry to leave out of the check, such as the entry the instruction was drafted from.
- candidatesOnlyboolean
Set to
trueto list the entries the check would cover incandidateswithout checking them. This makes no model calls. - pathsarray
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.
Show child attributes
items
- string
Responses
The result of checking an instruction. Nothing is saved.
How many entries were checked. Entries with no text, and entries whose check failed, are not counted and not reported.
0whencandidatesOnlyis set.The entries that contradict the instruction, ordered by path. Empty when
candidatesOnlyis set.- candidatesarray
The entries the check covers, ordered by path. Only present when
candidatesOnlyis set.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Draft an instruction from feedback
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructions/draftTurns 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. Returns 404 with code entryNotFound if entryId names no entry, and 422 with code instructionScopeVanished if neither scopeDocumentIds nor the entry gives any documents. Although it saves nothing, as a POST it needs the same access as a write. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
What should change, in your own words, such as "this is wrong" or "never say X".
- entryIdstring
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
404with codeentryNotFound. - excerptstring
The passage of the entry the feedback is about, so the draft addresses that claim.
- scopeDocumentIdsarray
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 returns422with codeinstructionScopeVanished.Show child attributes
items
- string (uuid)
Responses
A proposed instruction. Nothing is saved: pass it to POST .../instructions to create it.
The proposed instruction in plain language, written as a standing rule.
IDs of the documents the instruction should be tied to:
scopeDocumentIdsfrom the request, or the documents of the entry inentryId. Always at least one.Show child attributes
items
- string (uuid)
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Update an instruction
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructions/{instructionId}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. Updating deletes the open issues filed for entries that contradict the instruction. Sanity Context then checks the entries built from its documents against the updated instruction in the background. That check counts toward the organization's model spend and can file new update_required issues. Returns 404 with code instructionNotFound if the knowledge base has no instruction with this ID. Returns 422 with code instructionScopeVanished if none of the documents in scopeDocumentIds exist. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The instruction's document ID, such as
instruction.01JD5B2C7E9F3G6H8J0K4M1N5P. Find it by querying the knowledge base'ssanity.context.instructiondocuments with GROQ, or take it frominstruction.idin the create response.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Request body application/json
- statementstring
The new instruction text. Omit it to keep the current text.
- scopeDocumentIdsarray
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
422with codeinstructionScopeVanished.Show child attributes
items
- string (uuid)
Responses
A standing instruction that shapes how entries built from its documents are written.
The instruction's document ID.
The ID (
kb...) of the knowledge base the instruction belongs to.How the instruction was created.
human: someone wrote it.conflict: it records the side chosen, or that every side is correct, when a conflict issue was resolved. Both kinds work the same way in builds.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.The instruction in plain language. Builds follow it over what the sources say.
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.
Show child attributes
items
- string (uuid)
- archivedAtrequired
When a refresh archived the instruction.
nullwhile it is active.Show child attributes
- string (date-time)
- null
- archivedReasonrequired
Why the instruction was archived.
nullwhile it is active.Show child attributes
- string
- null
- sourceIssueIdrequired
ID of the conflict issue this instruction records.
nullwhenoriginishuman.Show child attributes
- string
- null
- createdByrequired
Who created the instruction.
nullfor instructions created by resolving a conflict, and when the creator is unknown.Show child attributes
- idrequired
The Sanity user ID, or
sanity-systemwhen Sanity Context made the change.nullif unknown.Show child attributes
- string
- null
- displayNamerequired
The user's name when the action happened.
nullif unknown. For the current name, look up the user byid.Show child attributes
- string
- null
- null
- updatedByrequired
Who last updated the instruction through the API.
nullwhen it was never updated, or when the person is unknown.Show child attributes
- idrequired
The Sanity user ID, or
sanity-systemwhen Sanity Context made the change.nullif unknown.Show child attributes
- string
- null
- displayNamerequired
The user's name when the action happened.
nullif unknown. For the current name, look up the user byid.Show child attributes
- string
- null
- null
When the instruction was created.
- updatedAtrequired
When the instruction last changed, including changes a refresh makes.
nullwhen the time is unknown.Show child attributes
- string (date-time)
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Delete an instruction
/{apiVersion}/context/knowledge-bases/{knowledgeBaseId}/instructions/{instructionId}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. Deleting also deletes the open issues filed for entries that contradict the instruction. Returns 404 with code instructionNotFound if the knowledge base has no instruction with this ID, including one you already deleted. Requires update access to the knowledge base.
Path parameters
The knowledge base's ID (
kb...), itspublicId. Its UUIDidis also accepted.The instruction's document ID, such as
instruction.01JD5B2C7E9F3G6H8J0K4M1N5P. Find it by querying the knowledge base'ssanity.context.instructiondocuments with GROQ, or take it frominstruction.idin the create response.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03
Query parameters
- rebuildstring
Set to
trueto 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 inrebuildJobId.
Responses
The rebuild the delete started, if any.
- rebuildJobIdrequired
ID of the job that rebuilds the entries built from the instruction's documents. Poll it with
GET .../jobs/{jobId}.nullwhen you didn't passrebuild=true, no entry is built from those documents, or the rebuild could not start. The instruction is deleted either way.Show child attributes
- string
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
mcp
Create and configure the Model Context Protocol (MCP) endpoints agents connect to, and check whether they are ready.
Create an MCP endpoint
/{apiVersion}/context/organizations/{organizationId}/mcpCreates 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.
Without the grant, the request returns 403 with code mcpEndpointManageAccessDenied. Without the dataset access, it returns 403 with code projectAdminRequired or datasetReadAccessDenied. A 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.
Path parameters
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03The ID of the organization.
Request body application/json
The endpoint's display title, up to 100 characters.
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-nameand names shaped like an endpoint ID are reserved.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.
Show child attributes
items
The source type.
datasetserves documents from a Sanity dataset, limited by the MCP endpoint'sgroqFilterwhen set.The dataset, as
<projectId>.<datasetName>.- workspacedefault:
nullThe studio workspace whose schema agents use, by name.
nulluses the studio's first workspace.Show child attributes
- string
- null
- perspectivedefault:
nullThe perspective agents query the dataset with:
published,drafts, orraw.nullusespublished.Show child attributes
- stringenum:
"published", "drafts", "raw"
- null
- semanticSearchdefault:
nullWhether agents can use semantic search on the dataset.
falseturns it off.trueornulluse it while the dataset has embeddings enabled and the organization has embeddings usage left.Show child attributes
- boolean
- null
- instructionsstring
Instructions for connecting agents, up to 10,000 characters.
- groqFilterstring
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.
Responses
An MCP endpoint: a URL that serves knowledge bases and at most one dataset to agents over the Model Context Protocol (MCP).
The endpoint's ID (
mcp…). Update and delete accept it or the endpoint's name.The ID of the organization that owns the endpoint.
The endpoint's display title.
The endpoint's name, used in its URL. It can't be changed.
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.
Show child attributes
items
The source type.
datasetserves documents from a Sanity dataset, limited by the MCP endpoint'sgroqFilterwhen set.The dataset, as
<projectId>.<datasetName>.The studio workspace whose schema agents use, by name.
nulluses the studio's first workspace.Show child attributes
- string
- null
The perspective agents query the dataset with:
published,drafts, orraw.nullusespublished.Show child attributes
- stringenum:
"published", "drafts", "raw"
- null
Whether agents can use semantic search on the dataset.
falseturns it off.trueornulluse it while the dataset has embeddings enabled and the organization has embeddings usage left.Show child attributes
- boolean
- null
- instructionsrequired
Instructions for connecting agents, or
nullif none are set.Show child attributes
- string
- null
- groqFilterrequired
The GROQ filter that limits the endpoint's dataset source, or
nullif none is set or the endpoint has no dataset.Show child attributes
- string
- null
The URL agents connect to.
When the endpoint was created, as an ISO 8601 timestamp.
When the endpoint was last edited, as an ISO 8601 timestamp. Agents using the endpoint don't change it.
- lastUsedAtrequired
When an agent last used the endpoint, as an ISO 8601 timestamp. It's recorded at most once every 10 minutes, so it can be up to 10 minutes behind.
nullif the endpoint hasn't been used since usage tracking started.Show child attributes
- string (date-time)
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Update an MCP endpoint
/{apiVersion}/context/organizations/{organizationId}/mcp/{mcpEndpoint}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 or the dataset source's perspective requires the same access for the endpoint's dataset. Sending the current values changes nothing.
Without the grant, the request returns 403 with code mcpEndpointManageAccessDenied. Without the dataset access, it returns 403 with code projectAdminRequired or datasetReadAccessDenied. An 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.
Path parameters
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.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03The ID of the organization.
Request body application/json
- titlestring
The endpoint's display title, up to 100 characters.
- sourcesarray
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.
Show child attributes
items
The source type.
datasetserves documents from a Sanity dataset, limited by the MCP endpoint'sgroqFilterwhen set.The dataset, as
<projectId>.<datasetName>.- workspacedefault:
nullThe studio workspace whose schema agents use, by name.
nulluses the studio's first workspace.Show child attributes
- string
- null
- perspectivedefault:
nullThe perspective agents query the dataset with:
published,drafts, orraw.nullusespublished.Show child attributes
- stringenum:
"published", "drafts", "raw"
- null
- semanticSearchdefault:
nullWhether agents can use semantic search on the dataset.
falseturns it off.trueornulluse it while the dataset has embeddings enabled and the organization has embeddings usage left.Show child attributes
- boolean
- null
Instructions for connecting agents, up to 10,000 characters.
nullremoves them.Show child attributes
- string
Instructions for connecting agents, up to 10,000 characters.
- null
A GROQ filter that limits the endpoint's dataset source.
nullremoves it.Show child attributes
- string
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.
- null
Responses
An MCP endpoint: a URL that serves knowledge bases and at most one dataset to agents over the Model Context Protocol (MCP).
The endpoint's ID (
mcp…). Update and delete accept it or the endpoint's name.The ID of the organization that owns the endpoint.
The endpoint's display title.
The endpoint's name, used in its URL. It can't be changed.
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.
Show child attributes
items
The source type.
datasetserves documents from a Sanity dataset, limited by the MCP endpoint'sgroqFilterwhen set.The dataset, as
<projectId>.<datasetName>.The studio workspace whose schema agents use, by name.
nulluses the studio's first workspace.Show child attributes
- string
- null
The perspective agents query the dataset with:
published,drafts, orraw.nullusespublished.Show child attributes
- stringenum:
"published", "drafts", "raw"
- null
Whether agents can use semantic search on the dataset.
falseturns it off.trueornulluse it while the dataset has embeddings enabled and the organization has embeddings usage left.Show child attributes
- boolean
- null
- instructionsrequired
Instructions for connecting agents, or
nullif none are set.Show child attributes
- string
- null
- groqFilterrequired
The GROQ filter that limits the endpoint's dataset source, or
nullif none is set or the endpoint has no dataset.Show child attributes
- string
- null
The URL agents connect to.
When the endpoint was created, as an ISO 8601 timestamp.
When the endpoint was last edited, as an ISO 8601 timestamp. Agents using the endpoint don't change it.
- lastUsedAtrequired
When an agent last used the endpoint, as an ISO 8601 timestamp. It's recorded at most once every 10 minutes, so it can be up to 10 minutes behind.
nullif the endpoint hasn't been used since usage tracking started.Show child attributes
- string (date-time)
- null
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Delete an MCP endpoint
/{apiVersion}/context/organizations/{organizationId}/mcp/{mcpEndpoint}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. Without it, the request returns 403 with code mcpEndpointManageAccessDenied. An unknown endpoint returns 404 with code mcpEndpointNotFound.
Path parameters
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.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03The ID of the organization.
Responses
No content.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Get an MCP endpoint's initial context
/{apiVersion}/context/organizations/{organizationId}/mcp/{mcpEndpoint}/initial-contextReturns 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 ##. A call counts as use of the endpoint in its lastUsedAt. Requires access to the organization and the sanity.knowledge-base.read grant on each knowledge base the endpoint serves. When the endpoint serves a dataset, it also requires the sanity.knowledge-base.read grant on all knowledge bases in the organization.
An unknown endpoint returns 404 with code mcpEndpointNotFound. Without the grant on all knowledge bases, an endpoint with a dataset returns 403 with code contextGrantRequired. Without read access to one of its knowledge bases, it returns 403 with code knowledgeBaseAccessDenied. An endpoint that can't be served returns 400 with code mcpEndpointNotServable: it has no sources, none of its knowledge bases exist, or its dataset has no deployed studio or lacks the configured workspace.
Path parameters
The MCP endpoint's name, set when the endpoint was created.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03The ID of the organization.
Query parameters
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.The perspective for GROQ queries:
published(default),previewDrafts,raw, or a release. Deprecated: refused from API versionv2026-11-03. Configure it on the MCP endpoint instead.Set to
trueorfalseto turn semantic search on or off. Omit it to use the dataset source setting. Deprecated: refused from API versionv2026-11-03. Configure it on the MCP endpoint instead.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.Serves only one side of the endpoint for this request:
knowledge_baseserves its knowledge bases andgroqserves 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 versionv2026-11-03. Configure it on the MCP endpoint instead.Comma-separated knowledge base public IDs (
kb...) that replace the endpoint's knowledge base sources for this request. Deprecated: refused from API versionv2026-11-03. Configure it on the MCP endpoint instead.- linkResolverstring
A JSON array that adds
_urlfields to query results. Each item hastypes(document types),baseUrl, and an optionalslugExpression, a GROQ expression that defaults toslug.current. Invalid JSON is ignored. 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.- heading_offsetstring
How many levels to shift markdown headings down, from
0to6. Defaults to1, so#becomes##. Numbers outside that range are clamped to it, decimals are rounded toward zero, and a value that isn't a number uses1.
Responses
The endpoint's initial context: Markdown, sent as plain text.
- string
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Check an MCP endpoint
/{apiVersion}/context/organizations/{organizationId}/mcp/{mcpEndpoint}/statusChecks 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. Requires access to the organization. Read access to the endpoint's knowledge bases isn't required: the access check reports what you can't read. When the endpoint serves a dataset, it requires the sanity.knowledge-base.read grant on all knowledge bases in the organization.
An unknown endpoint returns 404 with code mcpEndpointNotFound. Without the grant on all knowledge bases, an endpoint with a dataset returns 403 with code contextGrantRequired instead of running the checks.
Path parameters
The MCP endpoint's name, set when the endpoint was created.
The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03The ID of the organization.
Query parameters
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.The perspective for GROQ queries:
published(default),previewDrafts,raw, or a release. Deprecated: refused from API versionv2026-11-03. Configure it on the MCP endpoint instead.Set to
trueorfalseto turn semantic search on or off. Omit it to use the dataset source setting. Deprecated: refused from API versionv2026-11-03. Configure it on the MCP endpoint instead.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.Serves only one side of the endpoint for this request:
knowledge_baseserves its knowledge bases andgroqserves 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 versionv2026-11-03. Configure it on the MCP endpoint instead.Comma-separated knowledge base public IDs (
kb...) that replace the endpoint's knowledge base sources for this request. Deprecated: refused from API versionv2026-11-03. Configure it on the MCP endpoint instead.- linkResolverstring
A JSON array that adds
_urlfields to query results. Each item hastypes(document types),baseUrl, and an optionalslugExpression, a GROQ expression that defaults toslug.current. Invalid JSON is ignored. 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.
Responses
Whether the MCP endpoint is ready for agents, and the result of each check.
Whether every check that applies to the connection passed, except
semanticSearchandaccess. Whentrue, the endpoint is ready for an agent whose credentials can read what it serves.Deprecated: use
ready, which always has the same value.One result per check. A check is
nullwhen it doesn't apply to the connection.Show child attributes
- studiorequired
Whether a deployed studio serves the endpoint's dataset. Its schema tells the agent which document types exist.
nullwhen the connection doesn't query a dataset.Show child attributes
The check passed.
The name of the studio workspace the connection uses.
The workspace's title.
Whether the workspace was picked automatically because none was set. It is
falsewhen the dataset source'sworkspacechose it, or aworkspacequery parameter on versions beforev2026-11-03.The deployed studio's workspaces for the endpoint's dataset.
- null
- semanticSearchrequired
Whether semantic search works on the endpoint's dataset.
nullwhen the connection doesn't query a dataset, or when semantic search is on but the dataset doesn't have embeddings enabled. It never affectsready: without it, the agent searches with GROQ only.Show child attributes
The check passed.
- statusrequired
The dataset's embeddings index status, if known.
Show child attributes
- string
- null
- withinUsageLimitrequired
Whether the project is within its embeddings usage limit, or
nullif it couldn't be checked.Show child attributes
- boolean
- null
Whether agents connecting now can use semantic search. On versions before
v2026-11-03,?embeddings=trueforces the tool on for agents even when this isfalse.- inactiveReasonrequired
Why semantic search isn't active:
turnedOffwhen the dataset source has it off,datasetEmbeddingsNotReadywhile the dataset's embeddings are still being prepared, andusageLimitReachedwhen the organization has no embeddings usage left.nullwhen it is active.Show child attributes
- stringenum:
"turnedOff", "datasetEmbeddingsNotReady", "usageLimitReached"
- null
- null
- schemarequired
Whether the studio's schema has document types the agent can query.
nullwhen the connection doesn't query a dataset.Show child attributes
The check passed.
The number of document types the agent can query, after the endpoint's GROQ filter.
The perspective agents query the dataset with, such as
publishedordrafts.
- null
- knowledgeBasesrequired
Whether every knowledge base the connection serves exists and has been built.
nullwhen the connection doesn't serve knowledge bases.Show child attributes
The check failed.
The IDs of the knowledge bases that exist.
Show child attributes
items
- string
The IDs of knowledge bases that don't exist in the organization.
Show child attributes
items
- string
The IDs of knowledge bases that haven't been built yet. Build them before connecting an agent.
Show child attributes
items
- string
Why the check failed, written to show to users.
- null
- accessrequired
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.nullwhen the connection serves no knowledge bases that exist.Show child attributes
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
conversations
Record agent conversations and their classifications for Insights.
Record a conversation
/{apiVersion}/context/organizations/{organizationId}/conversations/{threadId}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 one of the sanity.knowledge-base.update, sanity.knowledge-base.entries.update, sanity.knowledge-base.issues.update, or sanity.knowledge-base.instructions.update grants on all knowledge bases in the organization, which the Context Editor role and higher have. Without it, the request returns 403 with code insightsWriteAccessDenied.
Each 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.
To 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.
The last write for a thread wins, so retries are safe. sharing records whether you share telemetry with Sanity: metrics only, or full transcripts.
The request body can be at most 1 MiB. A larger body returns 413 with code payloadTooLarge.
Path parameters
Your ID for the conversation thread, unique within your organization. Up to 200 characters.
insightsis reserved and returns400.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03The ID of the organization.
Request body application/json
The full transcript so far, in order. It replaces the stored messages.
Show child attributes
items
Who sent the message.
useris the person talking to the agent,assistantis the agent,systemis a system prompt, andtoolis a tool call or tool result.- contentdefault:
nullThe message text.
nullwhen the message has no text, such as a tool call.Show child attributes
- string
- null
- toolNamedefault:
nullThe name of the tool for a
toolmessage.nullon other messages.Show child attributes
- string
- null
- toolTypedefault:
nullThe kind of
toolmessage.callis the agent calling the tool, andresultis what the tool returned.nullon other messages.Show child attributes
- stringenum:
"call", "result"
- null
- errordefault:
nullWhy 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.
nullwhen the step succeeded.Show child attributes
- string
- null
- modelProviderstring
The provider of the model the agent used. When absent, the stored value stays unchanged.
- modelIdstring
The ID of the model the agent used. When absent, the stored value stays unchanged.
- tokenUsageobject
Token usage for one generation call. The API adds it to the conversation total, but only when this save changes the messages.
Show child attributes
- inputTokensnumber
The number of input tokens.
- outputTokensnumber
The number of output tokens.
- totalTokensnumber
The total number of tokens.
- metadataobject
Up to 20 tags that describe the conversation. Well-known keys are
mcpEndpoints(names of the MCP endpoints the conversation used),app, andenvironment. Add any other keys you need. Replaces the stored metadata. When absent, the stored value stays unchanged. - sharingobject
Your choice to share conversation telemetry with Sanity. Replaces the stored setting. When absent, the stored value stays unchanged.
Show child attributes
- metricsboolean
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.
- conversationsboolean
Whether to share full conversation transcripts with Sanity. When
true, the API also setsmetricstotrue. - contactstring
How the Sanity team can reach you about your agent, such as an email address or a Discord handle.
Responses
A recorded agent conversation: its transcript, metadata, token usage, and classification.
The conversation ID, unique within the organization. It matches the
_idof the conversation document in your document store.Your identifier for the conversation thread, unique within the organization. Saving with the same
threadIdupdates the same conversation.- metadatarequired
Tags that describe the conversation, such as
mcpEndpoints,app, andenvironment. Filter on them in GROQ queries.nulluntil a save includesmetadata.Show child attributes
- object
Up to 20 tags that describe the conversation. Each value is a string or an array of strings. Well-known keys are
mcpEndpoints(names of the MCP endpoints the conversation used),app, andenvironment. A stringmcpEndpointsvalue is stored as a one-item array. Add any other keys you need and filter on them in GROQ queries.
- null
When the API received the first save for this thread, as an ISO 8601 timestamp.
When the conversation was last saved, as an ISO 8601 timestamp.
The conversation transcript, in order. Each save replaces it.
Show child attributes
items
Who sent the message.
useris the person talking to the agent,assistantis the agent,systemis a system prompt, andtoolis a tool call or tool result.The message text.
nullwhen the message has no text, such as a tool call.Show child attributes
- string
- null
The name of the tool for a
toolmessage.nullon other messages.Show child attributes
- string
- null
The kind of
toolmessage.callis the agent calling the tool, andresultis what the tool returned.nullon other messages.Show child attributes
- stringenum:
"call", "result"
- null
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.
nullwhen the step succeeded.Show child attributes
- string
- null
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.
nullfor messages recorded before timestamps existed.Show child attributes
- string (date-time)
- null
- modelProviderrequired
The provider of the model the agent used.
nulluntil a save includesmodelProvider.Show child attributes
- string
- null
- modelIdrequired
The ID of the model the agent used.
nulluntil a save includesmodelId.Show child attributes
- string
- null
- tokenUsagerequired
The running total of token usage for the conversation.
nulluntil a save includestokenUsage.Show child attributes
- inputTokensnumber
The number of input tokens.
- outputTokensnumber
The number of output tokens.
- totalTokensnumber
The total number of tokens.
- null
- coreMetricsrequired
The latest classification result.
nulluntil you record one.Show child attributes
- successScorenumber
How well the agent resolved the user's needs, from 1 to 10.
- sentimentstring
The overall sentiment of the conversation.
- contentGapsarray
Topics the agent couldn't answer because it lacked content.
Show child attributes
items
- string
- null
- classifiedAtrequired
When the latest classification result was recorded, as an ISO 8601 timestamp. The API sets it.
nulluntil you record a result.Show child attributes
- string (date-time)
- null
- classificationErrorrequired
Why your classifier couldn't classify the conversation.
nullwhen no failure is recorded. Recording a result clears it.Show child attributes
- string
- null
- sharingrequired
Your choice to share conversation telemetry with Sanity.
nulluntil a save includessharing.Show child attributes
- metricsboolean
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.
- conversationsboolean
Whether to share full conversation transcripts with Sanity. When
true, the API also setsmetricstotrue. - contactstring
How the Sanity team can reach you about your agent, such as an email address or a Discord handle.
- null
When the conversation was created, as an ISO 8601 timestamp.
When the conversation was last changed, as an ISO 8601 timestamp.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Record a conversation classification
/{apiVersion}/context/organizations/{organizationId}/conversations/{threadId}Records the classification your own model produced for one thread. Send exactly one of these fields:
coreMetrics: the classification result. The API setsclassifiedAtand clears any recorded failure.classificationError: why classification failed. Any earlier result stays unchanged.
Requires the same access as recording a conversation. The last write wins, so a new classification replaces the previous one. A thread with no recorded conversation returns 404 with code conversationNotFound.
Path parameters
Your ID for the conversation thread, unique within your organization. Up to 200 characters.
insightsis reserved and returns400.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03The ID of the organization.
Request body application/json
- coreMetricsobject
The classification result. The API sets
classifiedAtand clears any recordedclassificationError.Show child attributes
How well the agent resolved the user's needs, as an integer from 1 to 10.
The overall sentiment of the conversation.
Topics the agent couldn't answer because it lacked content.
Show child attributes
items
- string
- classificationErrorstring
Why your classifier couldn't classify the conversation. Any earlier classification result stays unchanged.
Responses
A recorded agent conversation: its transcript, metadata, token usage, and classification.
The conversation ID, unique within the organization. It matches the
_idof the conversation document in your document store.Your identifier for the conversation thread, unique within the organization. Saving with the same
threadIdupdates the same conversation.- metadatarequired
Tags that describe the conversation, such as
mcpEndpoints,app, andenvironment. Filter on them in GROQ queries.nulluntil a save includesmetadata.Show child attributes
- object
Up to 20 tags that describe the conversation. Each value is a string or an array of strings. Well-known keys are
mcpEndpoints(names of the MCP endpoints the conversation used),app, andenvironment. A stringmcpEndpointsvalue is stored as a one-item array. Add any other keys you need and filter on them in GROQ queries.
- null
When the API received the first save for this thread, as an ISO 8601 timestamp.
When the conversation was last saved, as an ISO 8601 timestamp.
The conversation transcript, in order. Each save replaces it.
Show child attributes
items
Who sent the message.
useris the person talking to the agent,assistantis the agent,systemis a system prompt, andtoolis a tool call or tool result.The message text.
nullwhen the message has no text, such as a tool call.Show child attributes
- string
- null
The name of the tool for a
toolmessage.nullon other messages.Show child attributes
- string
- null
The kind of
toolmessage.callis the agent calling the tool, andresultis what the tool returned.nullon other messages.Show child attributes
- stringenum:
"call", "result"
- null
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.
nullwhen the step succeeded.Show child attributes
- string
- null
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.
nullfor messages recorded before timestamps existed.Show child attributes
- string (date-time)
- null
- modelProviderrequired
The provider of the model the agent used.
nulluntil a save includesmodelProvider.Show child attributes
- string
- null
- modelIdrequired
The ID of the model the agent used.
nulluntil a save includesmodelId.Show child attributes
- string
- null
- tokenUsagerequired
The running total of token usage for the conversation.
nulluntil a save includestokenUsage.Show child attributes
- inputTokensnumber
The number of input tokens.
- outputTokensnumber
The number of output tokens.
- totalTokensnumber
The total number of tokens.
- null
- coreMetricsrequired
The latest classification result.
nulluntil you record one.Show child attributes
- successScorenumber
How well the agent resolved the user's needs, from 1 to 10.
- sentimentstring
The overall sentiment of the conversation.
- contentGapsarray
Topics the agent couldn't answer because it lacked content.
Show child attributes
items
- string
- null
- classifiedAtrequired
When the latest classification result was recorded, as an ISO 8601 timestamp. The API sets it.
nulluntil you record a result.Show child attributes
- string (date-time)
- null
- classificationErrorrequired
Why your classifier couldn't classify the conversation.
nullwhen no failure is recorded. Recording a result clears it.Show child attributes
- string
- null
- sharingrequired
Your choice to share conversation telemetry with Sanity.
nulluntil a save includessharing.Show child attributes
- metricsboolean
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.
- conversationsboolean
Whether to share full conversation transcripts with Sanity. When
true, the API also setsmetricstotrue. - contactstring
How the Sanity team can reach you about your agent, such as an email address or a Discord handle.
- null
When the conversation was created, as an ISO 8601 timestamp.
When the conversation was last changed, as an ISO 8601 timestamp.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject
Delete a conversation
/{apiVersion}/context/organizations/{organizationId}/conversations/{threadId}Deletes the recorded conversation for one thread, including its messages and classification. Requires the same access as recording a conversation.
Saving with the same threadId afterwards records a new conversation. A thread with no recorded conversation returns 404 with code conversationNotFound, including one you already deleted.
Path parameters
Your ID for the conversation thread, unique within your organization. Up to 200 characters.
insightsis reserved and returns400.The API version: a date in the format
vYYYY-MM-DD, orvXfor the latest, unstable version. Usev2026-11-03: earlier versions keep behavior that has since changed.Example:v2026-11-03The ID of the organization.
Responses
No content.
The request has no token (missingCredential), a malformed Authorization header (invalidCredential), or a token without access to the organization (organizationAccessDenied). Routes that take a knowledge base ID return 404 instead of organizationAccessDenied.
- fieldsobject