Skip to main content
POST

Authorizations

Authorization
string
header
required

Bearer token used by every /v1/* endpoint. Two kinds of key work here:

  • Long-lived partner key (cxh_pk_live_*) — issued by CollectiveX Health (contact partners@collectivex.health). Keep it server-side only — never expose it in client bundles or mobile app code. This rule is absolute and does not change for any endpoint.
  • Short-lived session key — minted server-side via POST /v1/session-tokens from a long-lived key. Safe to hand to a native mobile client only — not a browser or other JavaScript context, see "API keys" in the description above. It's scoped to /v1/query and /v1/chat only, expires in at most 60 minutes, and can't mint further session keys. POST /v1/session-tokens itself only ever accepts the long-lived key.

Body

application/json

Request body for POST /v1/session-tokens. Uses additionalProperties: false (mirrors Zod .strict() on the server). Both fields are optional — an empty body (or no body at all) mints a 15-minute key capped at 200 requests.

ttl_seconds
integer
default:900

How long the minted key stays valid, in seconds. Must be 60–3600 (1 minute to 1 hour) — values outside the range are REJECTED with 400 invalid_request, not clamped. A "short-lived" credential that can outlive an hour isn't one. Defaults to 900 (15 minutes).

Required range: 60 <= x <= 3600
max_requests
integer
default:200

Total request allowance for the minted key, independent of the rate-limit window (maps to the Unkey key's remaining-uses credits). Defaults to 200 — session keys are never uncapped. Once exhausted, the key returns 403 forbidden even if it hasn't expired yet; mint a new token. Note the allowance counts every authenticated request made with the key, INCLUDING ones rejected with 4xx (e.g. 429s from a retry loop). A mobile session that needs more than 10,000 calls in under an hour is a scraping pattern, not a chat session — contact partners@collectivex.health if your use case genuinely needs a higher cap.

Required range: 1 <= x <= 10000

Response

Created. The plaintext session key is returned exactly once — it is never retrievable again, and CollectiveX Health never logs or persists it server-side. Store it only for as long as it takes to hand it to the client. The response carries Cache-Control: no-store (RFC 6749 §5.1 discipline for a bearer-secret response); anything you put in front of your mint call must honour it.

request_id
string<uuid>
required

UUID for this request. Include when contacting support.

key
string
required

The plaintext short-lived key, shown exactly once. It is never retrievable again, and CollectiveX Health never logs or stores it server-side — if you lose it, mint a new one. Treat it as an opaque bearer token: its exact format is not part of the API contract and may differ from the long-lived key's cxh_pk_live_* format.

key_id
string
required

The minted key's Unkey key id (not a secret — safe to log). Distinct from key; use this, not the plaintext key, for support correlation.

expires_at
string<date-time>
required

ISO 8601 timestamp when the key stops working. Calls made with it after this time return 401 unauthorized.

expires_in_seconds
integer
required

Seconds until expires_at, computed at response time from the same instant expires_at describes (so the two fields never disagree). Equal to the applied ttl_seconds give or take the mint round-trip. expires_at is authoritative and is enforced against Unkey's server clock.

scope
enum<string>[]
required

Fixed allowlist of endpoints this key may call — always ["query", "chat"] today. Server-assigned; the mint request cannot choose or widen it.

Available options:
query,
chat
max_requests
integer
required

The request allowance actually applied — the request value, or the 200-request default. Always present; session keys are never uncapped.