Authentication
How requests are authenticated: the key, what it can do, and how to keep it safe.
How authentication works#
Send your key as a bearer token: Authorization: Bearer pw_live_…. A key belongs to one project, and that project's policy applies to every request made with it.
curl https://api.panward.ai/v1/receipts/rcpt_01JC7Q4N9W3XK2H8ZP5T6V7B8M \ -H "Authorization: Bearer $PANWARD_API_KEY"
import os import requests r = requests.get( "https://api.panward.ai/v1/receipts/rcpt_01JC7Q4N9W3XK2H8ZP5T6V7B8M", headers={"Authorization": f"Bearer {os.environ['PANWARD_API_KEY']}"}, ) print(r.status_code)
const response = await fetch("https://api.panward.ai/v1/receipts/rcpt_01JC7Q4N9W3XK2H8ZP5T6V7B8M", { headers: { Authorization: `Bearer ${process.env.PANWARD_API_KEY}` }, }); console.log(response.status);
Keys are created and managed in the console, under API keys. Owners and Admins manage every key of the organization; Developers manage the keys of their own projects.
Keys and the project#
A key looks like pw_live_, a 22-character id, an underscore and a 43-character secret. The console shows the first 12 characters as the key's prefix. Panward stores a hash of the key, not the key, so a lost key cannot be recovered: create a new one. The secret is shown once, when you create or rotate a key. There are no pw_test_ keys at launch.
Scopes#
A key carries scopes. A key without the scope an operation needs gets 403 permission_denied. Give a service the least it needs: an inference service inference, a reporting job usage.read, a verifier receipts.read. The table is generated from the API contract.
| Scope | Allows |
|---|---|
inference | POST /v1/chat/completions, POST /v1/completions, POST /v1/embeddings, POST /v1/rerank, POST /v1/audio/transcriptions, POST /v1/images/generations |
models.read | GET /v1/models, GET /v1/models/{vendor}/{name}, GET /v1/models/{id} |
receipts.read | GET /v1/receipts/{id}, GET /v1/receipts |
usage.read | GET /v1/usage |
Restrictions on a key#
- Allowed models. A list of model ids. Any other model returns
403 model_not_enabled. - IP allowlist. Address ranges the key may be used from. A caller outside them gets
403 ip_not_allowed. - Limits. Requests per minute, tokens per minute, maximum input tokens and a monthly spend limit. The lowest limit that applies, among the key, the project and the organization, wins. See Limits.
- Expiry. An expired key returns
401 invalid_api_key.
Rotate and revoke#
Rotate key issues a new secret and keeps the old one valid for an overlap you choose, from zero to 168 hours (7 days). Deploy the new secret, then let the overlap end. Revoke key takes effect in every region within 30 seconds at the latest.
If a key leaks, revoke it first, then look at the requests made with it and at the audit log. A key that a public secret-scanning programme reports to Panward is revoked at once and the organization's Owners and the key's creator are notified.
Authentication errors#
| Status and type | When | What to do |
|---|---|---|
401 authentication_required | No Authorization header. | Send the bearer key. |
401 invalid_api_key | The key is unknown, revoked or expired. | Create a new key or rotate it. |
403 permission_denied | The key lacks the scope the operation needs. | Add the scope or use another key. |
403 ip_not_allowed | The caller's address is outside the key's or the policy's allowlist. | Add the range or call from an allowed address. |
403 organization_suspended | The organization is suspended. | Contact support. |
{
"error": {
"type": "invalid_api_key",
"message": "The API key is invalid, revoked or expired.",
"param": null,
"request_id": "req_01JC7Q4N8G5T2R9X1M3K6P7W4D",
"doc_url": "https://panward.ai/docs/errors#invalid_api_key"
}
}Every error type is on the Errors page.
Calls that need no key#
GET /v1/attestation and GET /v1/health need no key, and neither do the open endpoints under https://panward.ai/api/public. The attestation takes a nonce of your choosing, 64 hexadecimal characters.
curl "https://api.panward.ai/v1/attestation?nonce=5f3c9a1e7b2d4c6f8a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f"