Skip to content

Authentication & keys

Every /v1/* endpoint requires an API key sent as a bearer token:

Terminal window
curl -X POST https://api.aptrouter.com/v1/search \
-H "authorization: Bearer sk_live_…" \
-H "content-type: application/json" \
-d '{"query":"quantum error correction surface codes"}'

Only GET /health is unauthenticated.

Keys are issued per customer and managed from the aptrouter.com dashboard:

  • Minting. Create a key from the dashboard. The sk_live_… secret is shown once, right after you create it — only its hash is stored server-side, so copy it then. Lost a secret? Rotate via support.
  • Usage. The dashboard shows your active key (by hash prefix), your current prepaid credit balance, and requests/credits used to date, plus a button to top up. You can also check usage programmatically with GET /v1/usage — it’s free to call.
  • Secrecy. Treat keys like passwords: environment variables or a secret manager only, never source control, never client-side code.

Billing is prepaid — no subscription, no plans, no free tier. POST /v1/search debits 1 credit ($0.005, i.e. $5 per 1,000 searches) from your balance; internal errors and timeouts are automatically refunded. When your balance hits zero the API returns 402top up in the dashboard to resume.

Terminal window
curl https://api.aptrouter.com/v1/usage \
-H "authorization: Bearer $APTROUTER_API_KEY"
# → { "period": "2026-06", "requests": 4213, "credits": 4213, "balance": 5787 }

Successful (200) search responses carry headers so an agent framework can budget without parsing the body:

HeaderMeaning
X-Token-BudgetEstimated token count of the response body (~4 chars/token)
X-Credit-BalancePrepaid credits remaining after this call

A 429 (rate-limit) response instead carries RateLimit-Limit (your requests-per-minute cap) and Retry-After (seconds to wait before retrying).

StatusMeaning
400Empty query, or query longer than 2048 characters
401Missing, invalid, or revoked API key
402Prepaid balance exhausted — zero credits (X-Credit-Balance: 0). Top up to resume
429Per-key burst rate limit or too many concurrent requests — honour Retry-After
500Internal error — the charged credit is automatically refunded
504Search exceeded the per-request timeout — credit refunded

Full response schemas are in the API reference.