Authentication

API key structure, HTTP Authorization headers, key rotation patterns, and revocation across Toknix edge nodes.

All requests to the Toknix API require authentication using your secret API key. Unauthenticated requests or calls with expired credentials return an HTTP 401 Unauthorized response.

Authorization Headers

Depending on which wire format you are calling, provide your key in the standard header:

Wire ProtocolHeader NameFormat Example
OpenAI CompatibleAuthorizationAuthorization: Bearer tk_live_...
Anthropic Compatiblex-api-keyx-api-key: tk_live_...
Universal FallbackAuthorizationAuthorization: Bearer tk_live_...

Universal Bearer Support

Toknix accepts Authorization: Bearer tk_live_... across all endpoints, including POST /v1/messages. If your client supports Bearer tokens, you can use it uniformly.

API Key Format

Toknix keys are cryptographically random strings prefixed to facilitate automated secret scanning in repositories:

bash
tk_live_7b19a32c0f4981d6e82c5a0b731f92e4860d1e39a5c847e2b10f8491c287a934
  • Prefix: tk_live_
  • Entropy: 32 bytes (64 hex characters) generated via secure Web Crypto pseudo-random number generator (CSPRNG).
  • Storage: Stored securely as SHA-256 hashes on Toknix databases; raw keys are only revealed once upon creation.

Key Rotation

You can provision additional API keys or subkeys from your dashboard at any time. When rotating credentials:

  1. Generate a new API key in the Toknix console.
  2. Update your production secrets or environment variables with the new tk_live_... string.
  3. Verify your traffic operates normally on the new key.
  4. Delete the retired key from your dashboard.

Revocation

When an API key is deleted or revoked, the revocation propagates to all edge nodes within milliseconds. Any subsequent request using the revoked key will immediately receive:

json
{
  "error": {
    "message": "Invalid API key provided. The key has been revoked or does not exist.",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key"
  }
}