---
title: "Auth keys: finish PKCE sign-in and mint a user key"
canonical: https://uncensoredllm.ai/docs/auth-keys
generated: 2026-11-23T06:12:09.045Z
source: https://uncensoredllm.ai/docs/auth-keys
base_url: https://api.uncensoredllm.ai/v1
---

# Sign in, mint a key.

Updated November 22, 2026.

Let a user give your app a key of their own without pasting a secret. `POST /v1/auth/keys` at `https://api.uncensoredllm.ai/v1` closes an OAuth 2.0 sign-in with PKCE (S256): the browser comes back to you with a one-time code, and this route trades the code plus your verifier for a new key owned by the user’s organization. It is public, so send no key on this call. Keys an administrator mints directly are covered on the [keys page](https://uncensoredllm.ai/docs/keys).

[Get a key](https://app.uncensoredllm.ai/console)

## Start the sign-in

Generate a verifier of 43 to 128 characters from the set A-Z, a-z, 0-9 and `-._~`, hash it with SHA-256, base64url-encode the hash as the challenge, and open:

```
https://app.uncensoredllm.ai/auth?callback_url=https://yourapp.example/callback&code_challenge=CHALLENGE&code_challenge_method=S256&key_label=My%20app&state=STATE
```

`key_label`, `limit` (a budget in USD) and `state` are optional. The callback must be https, or http on localhost, 127.0.0.1 or [::1]. After the user approves, the browser lands on the callback with `?code=`; the code is single use and expires ten minutes after approval.

## Exchange the code

| Field | Type | What it does |
| --- | --- | --- |
| `code` | string, required | The code from the callback URL. |
| `code_verifier` | string, required | The verifier whose S256 hash was the challenge. |
| `code_challenge_method` | string | S256, the only method. |
| `callback_url` | string | Optional; when sent it must equal the approved callback exactly. |

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

## Response

| Field | What it holds |
| --- | --- |
| `key` | The new key, returned this one time only. |
| `key_id` | Its id, for the keys API and the console. |
| `name` | The label the user approved. |
| `limit_usd` | The prepaid budget the user approved, or null for none. |

## Status codes

| Status | Code | When |
| --- | --- | --- |
| 200 | none | The new key. |
| 400 | `invalid_grant`, `invalid_request`, `invalid_code_challenge_method` | Bad, spent or expired code; verifier mismatch; wrong callback; malformed body; a method other than S256. |
| 403 | `key_unavailable` | New keys are switched off for this account. |
| 409 | `limit_reached` | The organization already holds 50 active keys; revoke unused ones first. |

## Auth keys: questions

### Why PKCE rather than a client secret?

Your app never holds a secret. The sign-in page sees only the hash of the verifier, and the verifier itself travels once, in the exchange, so a captured code is useless on its own. That is the right shape for public clients such as desktop apps and extensions.

### Can I read the key again later?

No. The secret comes back once in this response. Store it at once; if it is lost, run the user through sign-in again and a fresh key is minted.

### Why did I get 400 invalid_grant?

The code was wrong, already spent or older than ten minutes, the verifier did not hash to the challenge the sign-in opened with, or callback_url differed from the approved one. Codes are single use and expire after ten minutes, so start a new PKCE sign-in rather than retrying the same code.

## Read next

- [MCP servers](https://uncensoredllm.ai/docs/mcp-servers)
- [Log export](https://uncensoredllm.ai/docs/exports)
- [Invoices](https://uncensoredllm.ai/docs/invoices)
- [Billing details](https://uncensoredllm.ai/docs/billing-details)
- [Statement signing key](https://uncensoredllm.ai/docs/statements-public-key)
- [Keys](https://uncensoredllm.ai/docs/keys)
- [Requests and receipts](https://uncensoredllm.ai/docs/requests)
- [Balance and spend limits](https://uncensoredllm.ai/docs/budgets)
- [Batches](https://uncensoredllm.ai/docs/batches)
- [Files](https://uncensoredllm.ai/docs/files)
- [Count tokens](https://uncensoredllm.ai/docs/count-tokens)
- [App usage stats](https://uncensoredllm.ai/docs/stats-apps)
- [Webhook deliveries](https://uncensoredllm.ai/docs/webhooks-deliveries)
- [Docs: connect in two minutes](https://uncensoredllm.ai/docs)
