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.
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
| Method | Path | Auth |
|---|---|---|
| POST | /v1/auth/keys | public; this is the last step of app sign-in (OAuth 2.0 with PKCE, S256) |
Request
| Field | Type | Notes |
|---|---|---|
| code | string | required; the code the callback received |
| code_verifier | string | required; 43 to 128 characters from letters, digits and -._~, whose S256 hash was the code_challenge |
| code_challenge_method | string | "S256" |
| callback_url | string | optional; must match the approved one exactly |
Response
| Field | Notes |
|---|---|
| key | the new key, sk-uplink-live-..., returned once |
| key_id | stable id for the key |
| name | the approved key_label |
| limit_usd | budget 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
| Status | Code | When |
|---|---|---|
| 400 | invalid_grant | code invalid, expired, used, or verifier mismatch |
| 400 | invalid_request / invalid_code_challenge_method | malformed exchange or unsupported challenge method |
| 403 | key_unavailable | new keys are off for this account |
| 409 | limit_reached | 50 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.