Auth keys API: PKCE code exchange for a new key

The public last step of app sign-in: trade an approved authorization code plus its PKCE verifier for a new API key, returned once.

Checked 2026-11-22

·API reference·Models

Finish app sign-in by trading an approved code and its PKCE verifier for a key with POST /v1/auth/keys at https://api.uplinkswitch.com/v1.

Flow

Send the user to https://app.uplinkswitch.ai/auth?callback_url=...&code_challenge=...&code_challenge_method=S256 (optional: key_label, limit in USD, state). After they approve, the browser returns to your callback carrying a code. Callbacks must use HTTPS, except HTTP on localhost, 127.0.0.1 or [::1]. Validate returned state against your sign-in attempt. This route trades that code plus the verifier whose S256 hash was the code_challenge for a key.

Route

MethodPathAuth
POST/v1/auth/keyspublic; this is the last step of app sign-in (OAuth 2.0 with PKCE, S256)

Request

FieldTypeNotes
codestringrequired; the code the callback received
code_verifierstringrequired; 43 to 128 characters from letters, digits and -._~, whose S256 hash was the code_challenge
code_challenge_methodstring"S256"
callback_urlstringoptional; must match the approved one exactly

Response

FieldNotes
keythe new key, sk-uplink-live-..., returned once
key_idstable id for the key
namethe approved key_label
limit_usdbudget in dollars, or null

Example

bash
curl https://api.uplinkswitch.com/v1/auth/keys \
  -H "Content-Type: application/json" \
  -d '{"code":"CODE_FROM_CALLBACK","code_verifier":"VERIFIER","code_challenge_method":"S256"}'

Errors

StatusCodeWhen
400invalid_grantcode invalid, expired, used, or verifier mismatch
400invalid_request / invalid_code_challenge_methodmalformed exchange or unsupported challenge method
403key_unavailablenew keys are off for this account
409limit_reached50 active keys already

Questions and answers

It is the exchange step of sign-in, so there is no key yet. The approved code and matching verifier are the proof.

Approval starts a ten-minute expiry window. Each code permits one attempt; even a verifier mismatch consumes it. Expired, spent or mismatched codes produce 400 invalid_grant.

No. The key is returned once in this response. Store it then, or start the flow again for a new one.

The auth URL's limit allocates the key's prepaid budget in USD; it comes back as limit_usd, or null when none was set.

The account already has 50 active keys. Remove one before exchanging another code. ## Sources Live OpenAPI, checked 2026-11-22.
Join on Telegram
Help