Authentication

Every request to the Quantized API (except the health check) requires a Bearer token in the Authorization header.

Authorization: Bearer <token>

Quantized supports two token types: API keys and JWT tokens.

API keys

API keys are the simplest way to authenticate. They are issued by your institution and look like:

sk-quantized-AbCdEfGhIjKlMnOpQrStUvWxYz...

Each API key is linked to a license, which tracks your credit balance and usage.

Usage

curl https://api.quantized.us/v1/license \
  -H "Authorization: Bearer sk-quantized-YOUR-KEY"

Key lifecycle

  • API keys can be deactivated without deleting the license or its balance
  • New keys can be issued for the same license
  • Keys can have an expiration date (exp), after which they stop working

JWT tokens

For programmatic or dynamic access, Quantized supports EdDSA-signed JWT tokens. This is useful when your institution needs to issue short-lived credentials without pre-registering each key.

How it works

  1. Your institution generates a JWT signed with their Ed25519 private key
  2. Quantized verifies the signature against the institution’s registered public key
  3. On first use, Quantized automatically creates a license and ephemeral API key from the JWT claims
  4. Subsequent requests with the same JWT reuse the existing license

JWT claims

Claim Required Description
institution_id Yes Institution UUID or alias
license_type_id Yes License type UUID or alias
context_id No Context identifier for the license (e.g., course ID, account ID)
license_id No Existing license UUID to reuse
user_id No User identifier. At least one of license_id or user_id is required
exp No Expiration timestamp (Unix epoch)
salt No Arbitrary salt stored with the ephemeral key

JWT header

{
  "alg": "EdDSA",
  "typ": "JWT",
  "kid": "optional-key-id"
}

The kid field is optional. If provided, Quantized matches it against the institution’s registered public keys.

Error responses

A credential problem returns 401 with one of four codes:

Status code Condition
401 missing_api_key No Authorization header
401 invalid_api_key The header doesn’t use the Bearer scheme, or the key or JWT is unknown, doesn’t verify, or has been deactivated
401 api_key_expired The key has passed its exp, or the JWT’s exp claim is in the past
401 license_inactive The key is valid, but its license or license type has been deactivated
402 budget_exhausted Valid credentials, but the license is out of budget. See Billing
{
  "error": {
    "message": "Invalid API key",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key",
    "request_id": "4bf92f3577b34da6a3ce929d0e0e4736"
  }
}

Branch on code, not on message. A missing key is only reported after the body is
validated, so a request with no key and an invalid body gets 400 invalid_request
first. See the Error reference for
each body.

Headers summary

Header Required Description
Authorization Yes Bearer <api-key-or-jwt>
X-Quantized-Provider No Force a specific provider (see Providers)
Content-Type Yes (POST) application/json