Skip to content

SOP: Get an API Key โ€‹

Fresh ๐ŸŒฑ

There are two ways to obtain an AgentMail API key: an agent can sign itself up programmatically, or a human can generate one from the Console.

Option A โ€” Agent self sign-up (no dashboard) โ€‹

Use this for first-time, programmatic onboarding. The human email must not already be registered with AgentMail.

1. Sign up

bash
curl -X POST https://api.agentmail.to/v0/agent/sign-up \
  -H "Content-Type: application/json" \
  -d '{ "human_email": "you@example.com", "username": "my-agent" }'
# returns { api_key, inbox_id, organization_id }

The sign-up endpoint is idempotent: calling it again with the same email rotates the API key and resends the OTP if expired.

2. Verify the OTP

An OTP is emailed to the human address. Verify it to unlock full permissions.

bash
export AGENTMAIL_API_KEY="am_..."   # from the sign-up response

curl -X POST https://api.agentmail.to/v0/agent/verify \
  -H "Authorization: Bearer $AGENTMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "otp_code": "123456" }'

Option B โ€” Console key (human) โ€‹

If sign-up fails (for example, the email is already registered), generate a key from the Console at https://console.agentmail.to and set it as AGENTMAIL_API_KEY in your environment.

Verify it works โ€‹

bash
curl https://api.agentmail.to/v0/auth/me \
  -H "Authorization: Bearer $AGENTMAIL_API_KEY"