Docs / API reference

App sign-in keys API

Updated 2026-11-22. Published by PentestLLM.

A tool your analysts install can get its own key without anyone pasting one: the user approves a label and a budget in the browser, and the tool exchanges the returned code at https://api.pentestllm.ai/v1 for a key owned by their organization.

Route

RouteStatuses
POST /v1/auth/keys200, 400, 403, 409

The last step of OAuth 2.0 with PKCE. It takes no key itself and answers any origin; the key it mints is an ordinary one, scoped by the label and budget the user accepted.

The flow

StepWhat happens
1Open https://app.pentestllm.ai/auth in the browser with callback_url, code_challenge and code_challenge_method=S256; key_label, limit (USD) and state are optional.
2The user signs in and approves the label and budget shown.
3The browser lands on your callback with ?code= appended.
4Your app posts the code and its verifier to this route and stores the key it gets back.

Body

FieldTypeNotes
codestring, requiredThe code from the callback URL.
code_verifierstring, required43 to 128 characters of A-Z, a-z, 0-9 and -._~ whose S256 hash was the code_challenge.
code_challenge_methodstringS256.
callback_urlstringOptional; when sent it must be the approved callback exactly.

Answer

FieldMeaning
keyThe new key, shown this once. Store it now.
key_idIts id, for the keys API and the console.
nameThe key_label the user approved.
limit_usdIts prepaid budget in dollars, or null for none.

Errors

StatusCodeWhen
400invalid_grantThe code is invalid, expired or already used, the verifier does not match, or callback_url is not the approved one. invalid_request and invalid_code_challenge_method share the status.
403key_unavailableNew keys are switched off for that account.
409limit_reachedThe organization already holds 50 active keys.

Example

shell
1curl https://api.pentestllm.ai/v1/auth/keys \
2 -H "Content-Type: application/json" \
3 -d '{"code": "<code from the callback>", "code_verifier": "<your verifier>", "code_challenge_method": "S256"}'

Questions

Why a verifier instead of a client secret?

A desktop tool or a CI step cannot keep a secret. With PKCE only the S256 hash travels up front and the verifier stays on the machine, so a code picked off a redirect is worthless without it.

Which callbacks are allowed?

An https URL, or plain http on localhost, 127.0.0.1 or [::1] for a tool that listens on the machine itself. The approved URL is pinned, and a different callback_url at exchange time fails with invalid_grant.

How long do I have, and can I retry?

Ten minutes from approval, and one attempt: the first exchange spends the code whether or not the verifier matched. A retry needs a fresh approval.

Join on TelegramHelp