Authentication

Which credential each endpoint accepts, and which header carries it.

dev · https://api.dev.oprag.ai

Four credentials

CredentialHeaderUsed fromWith no Origin headerWith one
Integration keyX-Oprag-KeyServerAllowed. Server-to-server callers (curl, your backend) send no Origin.The Origin must be on the project's allowlist. An empty allowlist rejects every browser Origin.
Embed keyX-Oprag-KeyBrowser403. Embed keys require a browser Origin header — there is no server-side fallback.The Origin must be on the project's allowlist. An empty allowlist rejects all.
Share tokenX-Oprag-Share-TokenEitherAllowed. Share links are opened directly and carry their own signed token.Not origin-restricted; the token itself is the credential.
Cognito JWTAuthorization: Bearer <JWT>BrowserAllowed. Dashboard routes are authorised by the token, not the Origin.CORS is handled by API Gateway; the project allowlist does not apply.

Header precedence

  • X-Oprag-Key is read first when present.
  • Otherwise the key is taken from Authorization: Bearer <key>.
  • Sending both is not an error — the dedicated header wins.
Shell
# Preferred
curl 'https://api.dev.oprag.ai/v1/chat' -H 'X-Oprag-Key: sk_live_...'

# Equivalent
curl 'https://api.dev.oprag.ai/v1/chat' -H 'Authorization: Bearer sk_live_...'

Public chat takes three of them

POST /v1/chat accepts an integration key, an embed key, or a share token — not integration keys alone. Which one you send determines the origin rules that apply, which is the part worth getting right.

Shell
# Server-to-server: integration key, no Origin needed.
curl -X POST 'https://api.dev.oprag.ai/v1/chat' \
  -H 'X-Oprag-Key: sk_live_...' \
  -H 'Content-Type: application/json' \
  -d '{"question":"What is your refund policy?"}'

# Browser: embed key, and the Origin must be allowlisted.
curl -X POST 'https://api.dev.oprag.ai/v1/chat' \
  -H 'X-Oprag-Key: embed_live_...' \
  -H 'Origin: https://your-site.example' \
  -H 'Content-Type: application/json' \
  -d '{"question":"What is your refund policy?"}'

# Shared conversation link: a signed share token.
curl -X POST 'https://api.dev.oprag.ai/v1/chat' \
  -H 'X-Oprag-Share-Token: <token>' \
  -H 'Content-Type: application/json' \
  -d '{"question":"What is your refund policy?"}'

Dashboard endpoints

Everything under the dashboard API takes a Cognito JWT as Authorization: Bearer <JWT>, and enforces a role on top. Sign-in itself is OAuth & sign-in.

Ready to ship?

Get started free