Browse API

API credentials

Authorize a human-approved device and protect the resulting bearer token.

Use a bearer token for authenticated /api/v0 requests. A browser session cookie does not authorize these routes. Create a token through a human-approved device flow; do not ask an agent to approve its own login or copy another machine's CLI configuration. For an ordinary terminal, rp login handles this flow and stores its token locally. The API flow below is for clients that must integrate directly.

Human-approved device authorization

  1. POST /api/v0/auth/cli/device/initiate with Content-Type: application/json and body {"client_name":"my integration"} (the name is optional). A successful JSON response contains device_secret, user_code, verification_uri, expires_in (seconds) and interval (seconds). This request is rate-limited (429 with {"error":"rate_limited"}).
  2. Show the separate verification URI and user code to a human. The person signs in on the browser page, enters the code and approves or denies. Never put the device secret in that URL or reveal it to the browser operator.
  3. POST /api/v0/auth/cli/device/poll with {"device_secret":"<device-secret>"} at no faster than interval. JSON status can be authorization_pending (with interval), slow_down (with an increased interval), approved, access_denied, expired_token, cancelled, already_exchanged or invalid_device_secret (401). A pending or slow-down response is HTTP 200, not an error response. Stop polling on a terminal status.
  4. After approved, POST /api/v0/auth/cli/device/exchange with the same JSON body. On success the one-time exchange returns {"token":"<bearer-token>","account":{"username":"...","email":"..."}}. A failed exchange returns 400 with JSON error (invalid_device_secret, expired_token, access_denied or invalid_grant). Do not retry a successful exchange: it is consumed.

POST /api/v0/auth/cli/device/cancel accepts the device secret and responds {"cancelled":true} even if the request is unknown or has already ended. The authorization expires after ten minutes; approval requires a real human browser session. These four endpoints form an authorization protocol, not a way to bypass human approval.

Use and expiry

Send Authorization: Bearer <token> over HTTPS. Do not put the token in a URL, commit it, paste it in task messages, or show it in logs. A token authenticates an account; individual operations still check project membership and permissions. DELETE /api/v0/account/token revokes the presenting token and responds {"ok":true} on success. An invalid token returns 401 Unauthorized; a matching expired token returns 401 JSON with error: "token_expired" and, when known, reason: "idle". Clients should also tolerate the historical "absolute" reason from older servers.

Each deliberate authenticated operation, including a read or explicit CLI command, renews the account token for 30 × 24 hours. There is no absolute age cap. Background polling, SSE, heartbeats, automatic reconnects and automatic refreshes do not renew it. Integrations must send Repopack-Activity: passive on background requests; streams and dedicated polling endpoints are treated as passive independently. This header can only suppress renewal; it grants no authorization. A manual read or refresh is an action, not background traffic.

Already expired or revoked credentials are not revived by the policy transition or a late request. Existing still-valid credentials receive the longer inactivity window without resetting their recorded activity time. After expiry, ask the human to approve a new rp login; never replay an expired credential or automatically reauthenticate. Read a project to verify scope before acting.

Browser sessions use the separate browser login flow and expire after 7 × 24 hours without a qualifying action. A qualifying browser action renews both the server deadline and cookie; leaving a tab open does not. There is no absolute browser-session age cap. Logout, suspension and revocation remain effective. Browser cookies still do not authorize API routes.

Local chat connections

rp agent start uses a separate browser-approved, expiring box connection, not the general CLI login credential documented here. Its private pairing/discovery/chat/source protocol is not a public integration API. Do not reuse that credential for general automation. Within the managed runner it authenticates the paired account on ordinary API routes; project permissions, task state and guarded confirmations still apply to review, revise, merge and deployment actions. Chat session focus does not confer extra authority. Use the local agent guide for setup, revocation and recovery.