# POST /v1/agent-signup

> Let an AI agent get a key for a person, who approves it from an email.

Source: https://docs.invariant-ai.com/api/agent-signup

`POST https://api.invariant-ai.com/v1/agent-signup`

For agents running in a person's terminal, editor or chat. The agent starts a sign-up with the person's email; we
email them an approval link and the agent shows them a 6-digit match code. When they approve, the agent's poll
returns the key once. The agent-facing guide is [auth.md](https://api.invariant-ai.com/auth.md).

```bash
curl -s -X POST https://api.invariant-ai.com/v1/agent-signup \
  -H "Content-Type: application/json" \
  -d '{"email": "pat@example.com", "key_name": "Research bot", "client_name": "Claude Code"}'
```

Response 201:

```json
{
  "claim_token": "clm_…",
  "user_code": "042917",
  "verification_uri": "https://api.invariant-ai.com/approve?v=…",
  "expires_in": 600,
  "interval": 5
}
```

```bash
curl -s -X POST https://api.invariant-ai.com/v1/agent-signup/token \
  -H "Content-Type: application/json" \
  -d '{"claim_token": "clm_…"}'
```

## Start: body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `email` | string | Yes | The person who approves. Ask them; never guess. |
| `key_name` | string | No | Label for the key. |
| `client_name` | string | No | Your agent or tool, shown in the email and on the approval page. |

Keep `claim_token` secret. Show the person `user_code`, and tell them to open the email from Invariant, check the
code matches, and approve. `verification_uri` lets them approve with Google instead.

## Poll: `POST /v1/agent-signup/token`

Poll every `interval` seconds with `{"claim_token": "…"}`.

| Response | Meaning |
| --- | --- |
| `{"status": "pending"}` | Not answered yet |
| `{"status": "slow_down"}` | You polled too fast; add 5 seconds |
| `{"status": "expired"}` | 10 minutes passed. Start again |
| `{"status": "denied"}` | The person declined |
| `{"status": "approved", "api_key": "ief_…", "key_id", "key_name", "email", "dashboard_url"}` | The key, returned once |
| `400 invalid_request` | Unknown token, or the key was already collected |
| `429 rate_limited`, `reason: "agent_signups"` | Too many sign-ups from this network or open for this email |
