Create a reader credential
From your server, with the secret key: a short-lived credential for one visitor of a page on one of the key's allowed origins. The page sends it as its bearer token instead of the publishable key, and gets answers from what the key reads, narrowed to that visitor.
A credential works only from the origin it was created for, never reads more than its key, and cannot create more credentials.
curl -X POST "https://api.documentation.ai/api/v1/assistant/reader-credentials" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-d '{
"origin": "https://app.acme.com",
"signed_in": true
}'
import requests
import json
url = "https://api.documentation.ai/api/v1/assistant/reader-credentials"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
}
data = {
"origin": "https://app.acme.com",
"signed_in": true
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch("https://api.documentation.ai/api/v1/assistant/reader-credentials", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
},
body: JSON.stringify({
"origin": "https://app.acme.com",
"signed_in": true
})
});
const data = await response.json();
console.log(data);
package main
import (
"fmt"
"net/http"
"bytes"
"encoding/json"
)
func main() {
data := []byte(`{
"origin": "https://app.acme.com",
"signed_in": true
}`)
req, err := http.NewRequest("POST", "https://api.documentation.ai/api/v1/assistant/reader-credentials", bytes.NewBuffer(data))
if err != nil {
panic(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println("Response Status:", resp.Status)
}
require 'net/http'
require 'json'
uri = URI('https://api.documentation.ai/api/v1/assistant/reader-credentials')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.body = '{
"origin": "https://app.acme.com",
"signed_in": true
}'
response = http.request(request)
puts response.body
{
"credential": "asst_rc_3k9TqX2mVbN7wLp4ZcR8sYd1FhJ6uGe0aKoIiMnB5vQ",
"origin": "https://app.acme.com",
"expires_at": "2026-11-06T09:45:00.000Z",
"expires_in_seconds": 900
}
{
"error": "invalid_request",
"message": "message must not be empty."
}
{
"error": "key_invalid",
"message": "This key is not valid. Check it was copied in full."
}
{
"error": "plan_not_included",
"message": "The Assistant API needs a Standard plan or higher."
}
{
"error": "request_too_large",
"message": "Requests are limited to 64 KB."
}
{
"error": "rate_limited",
"message": "This key allows 60 requests a minute. Retry after 12 seconds.",
"retry_after_seconds": 12
}
{
"error": "internal_error",
"message": "Something went wrong on our side. Retry shortly."
}
{
"error": "temporarily_unavailable",
"message": "The assistant could not answer right now. Retry shortly.",
"retry_after_seconds": 5
}
/reader-credentials
Target server for requests. Edit to use your own host.
An Assistant API key from Settings > Assistant API: the secret key (asst_sk_...) from servers and tools, or the publishable key (asst_pk_...) or a reader credential (asst_rc_...) from pages on the key's allowed origins. See Authentication.
asst_sk_...) from servers and tools, or the publishable key (asst_pk_...) or a reader credential (asst_rc_...) from pages on the key's allowed origins. See Authentication.The media type of the request body
One of the key's allowed origins, exactly as the browser sends it.
Whether the visitor is signed in to your product. false limits the credential to public pages.
The visitor's roles. Only roles the key also has are kept, each time the credential is used.
From 60 to 3,600. Defaults to 900 (15 minutes).
Request Preview
Response
Response will appear here after sending the request
Authentication
Bearer token. An Assistant API key from Settings > Assistant API: the secret key (asst_sk_...) from servers and tools, or the publishable key (asst_pk_...) or a reader credential (asst_rc_...) from pages on the key's allowed origins. See Authentication.
Body
One of the key's allowed origins, exactly as the browser sends it.
https://app.acme.comWhether the visitor is signed in to your product. false limits the credential to public pages.
The visitor's roles. Only roles the key also has are kept, each time the credential is used.
From 60 to 3,600. Defaults to 900 (15 minutes).
Responses
The credential, starting with asst_rc_. Pass it to the page, which sends it as its bearer token.
The only origin the credential works from.
When it stops working, in ISO 8601 UTC.
Its lifetime in seconds.