DocsAPIAuthentication

Authentication

Two credentials, one account. An API key authenticates the query endpoints. Your signed-in session authenticates the API Console and the endpoints behind it.

01Two credentials

CredentialAccepted byHow it is sent
API keyPOST /api/query and POST /api/query/streamAuthorization: Bearer ra-…, or X-Api-Key: ra-…
Session cookieThe API Console and /api/console/*The auth_token cookie, set when you sign in to ResearchAnything

Neither works in the other's place. An API key is not accepted on /api/console/*, so keys, usage and timelines cannot be managed with a key. The session cookie is not accepted on the query endpoints.

02API keys

Keys are created in the API Console at researchanything.ai/console/keys. Any signed-in ResearchAnything account can create them. See API keys for creating and revoking them.

A key acts as your account. Calls made with it use your plan's monthly research runs and are recorded against your account.

Format

A key is ra- followed by 32 URL-safe characters (24 random bytes). The full key is shown once, when you create it. ResearchAnything stores only its SHA-256 hash, plus the first 12 characters as a prefix so you can tell keys apart in the Console. A lost key cannot be recovered: create a new one and revoke the old one.

CautionCopy the key into your secrets manager before you close the dialog. It is not shown again.

Sending the key

Send the key as a Bearer token. The X-Api-Key header is also accepted. If the request has an Authorization: Bearer value, that is the key used; otherwise X-Api-Key is read.

cURL — Bearer
curl https://researchanything.ai/api/query \
  -H "Authorization: Bearer $ESSARION_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "What is the half-life of caffeine in adults?"}'
cURL — X-Api-Key
curl https://researchanything.ai/api/query \
  -H "X-Api-Key: $ESSARION_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "What is the half-life of caffeine in adults?"}'

Key status and failures

A key is active until you revoke it, and revoked after. Revoking takes effect on the next call, and a revoked key cannot be reactivated. Keys have no expiry date.

SituationHTTPError code
No key sent401missing_api_key
Unknown key, or one that does not start with ra-401invalid_api_key
Revoked key403key_inactive

On /api/query/stream the same failures arrive as an error event and a final event on an HTTP 200 stream. See Errors.

TipKeep keys server-side. The query endpoints accept calls from any origin, so a key placed in a web page, browser extension or mobile app works for anyone who extracts it. Call the API from your own backend instead.

03Session cookie

Signing in to ResearchAnything, with email and password or with your Essarion ID, sets an HTTP-only cookie named auth_token that holds a signed session token. It expires after a few days (seven by default); sign in again to get a new one. The API Console and every /api/console/* endpoint read this cookie.

Writes that carry the cookie (POST and DELETE) are refused with HTTP 403 and the code CROSS_SITE_REQUEST when a browser marks them as coming from another site.

Can’t find what you need?

Write to us and a person will answer.