# AgentsReady authentication

Anonymous scans and all MCP tools remain free without signing in. Authentication selects the account's scan limits: Free 20, Personal 40, Growth 60, Agency 100 fresh scans/hour. Cached results do not use the allowance.

## API keys and human sign-in

Open https://agentsready.dev/dashboard/keys. Enter an email and open the single-use magic link (15-minute lifetime). Create a named API key. Copy it once. Keys expire after one year and can be revoked on that page. Only SHA-256 hashes are stored. Send Authorization: Bearer <key> to /api/check, /api/scan or /mcp. Keys cannot access account or billing controls.

## Onboard with your agent

POST https://agentsready.dev/api/agent-connect with JSON {"name":"My coding agent"}. Receive connectUrl, userCode, deviceCode, expiresIn (600 seconds) and interval (5 seconds). Keep deviceCode private. Give the person connectUrl and userCode. They sign in and explicitly approve or deny the request. Starting a request never creates an account. Signing in creates the human's account, but never grants access to the agent by itself.

POST https://agentsready.dev/api/agent-connect/poll with {"deviceCode":"<private polling secret>"} every five seconds. Pending: {"status":"pending"}. Approved: {"status":"approved","apiKey":"<save once>","keyId":"<id>","expiresAt":"<date>"}. The key is delivered once. Denial is 403, expiration 410, repeat delivery 409 and rapid polling 429. If delivery is lost, start again and revoke the unused key. Details: https://agentsready.dev/docs/agent-connect.

## OAuth discovery

API resource: https://agentsready.dev. MCP resource: https://agentsready.dev/mcp.
Protected resources (RFC 9728): https://agentsready.dev/.well-known/oauth-protected-resource and https://agentsready.dev/.well-known/oauth-protected-resource/mcp.
Authorization server (RFC 8414): https://agentsready.dev/.well-known/oauth-authorization-server. Issuer: https://agentsready.dev.

## Register a public client

POST https://agentsready.dev/api/oauth/register (RFC 7591) with application/json:

```json
{"client_name":"My app","redirect_uris":["https://app.example.com/callback"],"token_endpoint_auth_method":"none","grant_types":["authorization_code"],"response_types":["code"]}
```

The response contains client_id and client_id_issued_at. No client secret is issued. Registrations expire after one year. HTTPS redirect URIs are required, except HTTP loopback IPs (127.0.0.1 and [::1]). URI matching is exact, including port and query. Fragments and embedded credentials are rejected.

Alternatively use a Client ID Metadata Document: client_id is a public HTTPS URL with a path, without query or fragment. That URL must return application/json with client_id exactly equal to the URL, client_name, redirect_uris and token_endpoint_auth_method: none. The same grant/response rules apply. Documents are limited to 16 KB; redirects and private network destinations are rejected. Metadata is fetched when authorization starts. Client names are self-reported and shown with the client ID and redirect URI on consent.

## Authorize with PKCE S256

Generate a random code_verifier (43–128 URL-safe characters), then code_challenge = BASE64URL(SHA256(code_verifier)), without padding. Generate and retain a random state; verify it when the redirect returns.

Open https://agentsready.dev/api/oauth/authorize with response_type=code, client_id, redirect_uri, code_challenge, code_challenge_method=S256, scope=scan, state and resource. Set resource to https://agentsready.dev for the API or https://agentsready.dev/mcp for MCP. The default resource is MCP. The person signs in by magic link and approves. Consent expires in ten minutes. Denial redirects with error=access_denied and the original state. Invalid requests are rejected locally, never redirected to an unvalidated URI.

Approval redirects with code and state. Codes expire after 120 seconds and can be used once. POST https://agentsready.dev/api/oauth/token using application/x-www-form-urlencoded: grant_type=authorization_code, code, client_id, redirect_uri, code_verifier, and optionally the same resource. A failed exchange consumes the code; restart authorization. Success returns access_token, token_type: Bearer, expires_in: 3600 and scope: scan. Only a token hash is stored. Tokens are bound to their resource. No refresh tokens or confidential clients are supported.

## Revoke

POST https://agentsready.dev/api/oauth/revoke using application/x-www-form-urlencoded with token and client_id. Revocation is idempotent and returns 200 even for an unknown token. Use the dashboard to revoke API keys.

## Errors and limits

Missing credentials keep anonymous access. Invalid or expired tokens return 401. A different resource returns 403. Scan limits apply to the account across keys, tokens and transports. JSON HTTP errors use RFC 9457 problem+json with code, detail, type and request_id (also X-Request-Id). OAuth token errors also include error and error_description. 429 includes Retry-After. Streamed scans and MCP tool calls retain their existing protocol errors. See https://agentsready.dev/docs/errors.
