Browse documentation
← API reference

Accounts & authentication

Start a person's login

POST /api/v1/auth/device

The OAuth 2.0 device authorization grant, as RFC 8628 describes it, which cscale auth login uses. With an email, the approval link goes there, and the person types the terminal's user code on its page. Five wrong codes refuse the login. The answer is the same whether or not an account uses the address: it comes before the server looks, and the email follows. Without an email, the person opens verification_uri, signs in, and types the user code. Then poll for the token every interval_s seconds. Needs no login; limited per client address. When email limits are enabled, an address gets at most 5 an hour and 10 a day, and each place that asks, and the server, send only so much email that nobody uses.

Parameters

Idempotency-Keyheader · optional · string

Makes a retry safe: a request with the same key and the same method, path, and body as an earlier one gets the earlier response instead of doing the work again. 1 to 255 visible ASCII characters; use a new key for each new request, such as a UUID. Keys are kept per caller for a day, and ignored for requests without credentials.

Minimum length: 1 · Maximum length: 255

Example request

curl --request POST 'https://commitscale.com/api/v1/auth/device' \
  --header 'Content-Type: application/json' \
  --data '{
  "client_name": "cscale",
  "email": "person@example.com"
}'

Example values illustrate the format. Use your own credentials and identifiers.

Request body

application/json

Starts a login for a terminal. With an email, the approval link goes there; without one, the person approves on the web app's device page.

client_nameoptional · string

The application name shown to the person approving the sign-in.

emailoptional · string

The person's sign-in email address.

Responses

200 The device code to poll with, and the code to show.

application/json

{
  "device_code": "device-polling-code",
  "expires_in_s": 900,
  "interval_s": 5,
  "message": "Open the verification link and enter your code.",
  "user_code": "BCDF-GHJK"
}

device_coderequired · string

Secret polling code returned when this device login started. Keep it private.

expires_in_srequired · integer (int64)

Seconds until this request expires. Start again after it expires.

Minimum: 0

interval_srequired · integer (int64)

Minimum seconds to wait between polls. Polling sooner returns slow_down.

Minimum: 0

messagerequired · string

A message for the person using this client.

user_coderequired · string

Short code shown in the terminal for the person to approve on the device page.

verification_urioptional · string

The page to approve on, for a login without an email.

RateLimit and RateLimit-Policy describe the request rate. Follow Retry-After when a response asks you to wait.

Problem responses

Errors use application/problem+json. Act on the stable code, and follow next when present. See the problem format.

check_key_scope403

A check-only key may call the test check, read its own usage and acceptance rule, contact support, and withdraw data sharing.

Use a person's sign-in for account management. More agent power needs the owner's passkey; this key cannot widen itself.

signup_closed403

Open sign-up is turned off on this server.

Ask for an invite, or sign in to an existing account.

feature_off403

The namespace plan does not include this feature.

Retrying on the same plan will not help. GET /api/v1/namespaces/{namespace}/plan, and the namespace's Plan page in Settings, show what its plan includes.

invalid_token401

The token is unknown, expired, or revoked, its agent was revoked, or an OAuth token was used outside its MCP resource.

Stop using it. Sign in again, or ask the owner to create a replacement agent key.

forbidden403

The caller may not do this: only people may, only owners may, or the agent was not given this repository or write access.

Stop. Retrying will not help. Ask the owner for the access, or leave the step to a person.

invalid_request400 / 413 / 415 / 422

The request is malformed or breaks a rule, such as a title that is too long, or a body that is not the expected JSON.

Fix the request as detail says. The same request fails the same way.

quota_exceeded422 / 429

With 429, the caller used its requests for the minute. With 422, a count limit was reached.

With 429, wait Retry-After seconds and retry. With 422, remove one first.

idempotency_key_reused409 / 422

The idempotency key was already used for a different request.

Use a new key for each new request, and the same key only for a retry of the same request.

idempotency_key_in_use409

The first request with this key is still running, including a queued model question, or it succeeded with a secret, such as a new token, which is never replayed.

When Retry-After is set, retry then with the same key. Otherwise the first request succeeded: do not repeat it.

internal500

The server failed, and logged why.

Retry after Retry-After seconds. A write is safe to retry with the same idempotency key.

unavailable503

With 502, a service the server needs did not answer, such as a sign-in provider. With 503, the server is busy, such as when a workspace is locked or host lookups are full, or a write with an idempotency key runs long: that write goes on, and its answer is kept for the key.

With 502, retry later, or sign in another way. With 503, retry after Retry-After seconds, using the same idempotency key for a write; a long-running write can then replay its answer.