invalid_credential means OpenType received a bearer credential and rejected it. Read this page if calls that used to work now fail with a 401, or if a new key is refused.
What happened
Routes: every protected route under/v1/, including runs, keys, usage, quota and billing.
OpenType reads the value after Bearer. A value starting with otsk_ is checked as an API key; anything else is checked as a console session. The credential was refused for one of these reasons:
A revoked key gets
invalid_credential, not key_revoked. key_revoked is returned only when you try to rotate a revoked key.
The response does not say which reason applied, and it does not carry a WWW-Authenticate header.
How to fix
Check the key, in this order:- Shape. The secret is 69 characters:
otsk_plus 64 lowercase hex. A trailing newline, surrounding quotes, or a truncated copy breaks it. Trim the value when you load it. - The right value. A key id (
key_...) or asecret_prefix(otsk_plus 8 characters) is not a secret. The full secret was shown once, when the key was created or rotated. - State. Find the key on the API keys page or with
GET /v1/keys, and match itssecret_prefixagainst the first 13 characters of your secret. If itsstateisrevoked, create a new key. - Rotation. If the key was rotated, only the newest secret works. Update every service that still holds the old one.
- Environment. Check that the service loads the key you expect, for example after a deploy or a change in your secret store.
Example
runs_read. A key without it gets scope_denied, which still proves the key itself is valid.
Related
- Authentication - API keys, console sessions and the bearer header.
- Key rotation - replace a key without downtime.
- API key security - storing and handling secrets.
- Problem codes - every code, its status, and whether a retry can help.