Assistant APIOverview

Assistant API

Base URL, authentication, stream events and error codes of the Assistant API, which answers questions from your documentation.

Overview

The Assistant API answers questions from your documentation, with the same answers and access rules as your docs site. To create keys and connect tools such as Intercom, Zendesk or Slack, see the Assistant API guide.

Requests and responses are JSON. Field names, event names and error codes don't change between releases.

Base URL

https://api.documentation.ai/api/v1/assistant
EndpointWhat it does
POST /answersAsk a question
POST /feedbackRate an answer
POST /reader-credentialsCreate a reader credential for one visitor of a page
GET /keyCheck a key
DELETE /conversations/{conversation_id}Delete a conversation

Authentication

Send a key in the Authorization header: Authorization: Bearer <key>. Keys are created in Settings > Assistant API. REST API keys don't work here.

KeyStarts withUsed fromReads
Secret keyasst_sk_Servers and tools. Refused when the request comes from a web page.What the key allows
Publishable keyasst_pk_Pages on the key's allowed originsPublic pages only
Reader credentialasst_rc_The page it was created forWhat the key allows, narrowed to one reader
curl https://api.documentation.ai/api/v1/assistant/answers \
  -H "Authorization: Bearer asst_sk_..." \
  -H "Content-Type: application/json" \
  -d '{"message": "How do I reset my password?"}'

Stream events

With "stream": true in POST /answers, the response is text/event-stream. A comment line arrives at once, and another every 10 seconds while the answer is written.

EventData
answer.delta{ "text": "..." }: the next part of the answer, in Markdown as it is written
answer.completedThe answer object, the same as in normal mode. Use its answer as the final text.
errorAn error object, if the answer fails after the stream starts

Refusals that happen before the answer starts, such as an invalid key, come back as normal JSON errors with their status code.

Errors

Errors return the status code below and a flat body, as does a wrong path or method:

{ "error": "rate_limited", "message": "This key allows 60 requests a minute. Retry after 12 seconds.", "retry_after_seconds": 12 }

retry_after_seconds and the Retry-After header are set when retrying later can succeed. Once the key is accepted, refusals carry the X-RateLimit-* headers too.

StatuserrorWhat to do
400invalid_requestFix the field named in message.
413request_too_largeKeep requests under 64 KB.
401key_missingSend Authorization: Bearer <key>.
401key_invalidCheck the key was copied in full, and that it is an Assistant API key.
401key_expiredCreate a new key.
401key_revokedCreate a new key.
401reader_credential_invalidHave your server create a new reader credential.
403browser_not_allowedUse the secret key from a server only. Rotate it if it was in a page.
403origin_requiredCall with the publishable key or a reader credential from a page on an allowed origin.
403origin_not_allowedAdd the origin to the key, exactly as the browser sends it.
403plan_not_includedUpgrade to Standard or higher.
402credits_exhaustedAdd credits or turn on overage.
429monthly_quota_exceededWait for the quota to reset on the 1st (UTC).
403assistant_disabledTurn the AI assistant on for the documentation.
404site_not_publishedPublish the documentation.
403key_access_insufficientEvery page now needs sign-in. In the key's Edit dialog, choose All pages, including protected ones and save.
403reader_sign_in_requiredAsk for a signed-in reader: every page needs sign-in.
429rate_limitedRetry after retry_after_seconds.
429too_many_concurrent_requestsRetry when one of the key's 20 running requests finishes.
409request_in_progressThe same request was still being answered when your time limit ran out. Retry for its answer.
404answer_not_foundRate only answers given to this key in the last 30 days.
404not_foundCheck the method and path, such as POST /api/v1/assistant/answers.
503site_settings_unavailableRetry shortly. No answer is given without your access settings.
503temporarily_unavailableRetry shortly.
500internal_errorRetry shortly, and contact support if it persists.

Rate limits

Every request with a valid key counts towards the key's limit of 60 requests a minute, and its response, a refusal included, carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers. The other limits, such as messages per conversation and request size, are listed in the guide's Limits.