# auth.md

send.io is a transactional email platform with inboxes for AI agents. This file tells an agent how to open a send.io account for its human without the sign-up form, following the auth.md protocol. Read it top to bottom once. Every request below is a template: fill the placeholders in angle brackets and send it as is.

Two hosts: `https://app.send.io` serves this file, the dashboard and the claim page; `https://api.send.io` is the API and the authorization server. Discovery is authoritative: if the hosts or paths there differ from this file, use discovery.

## Discover

Hop one: the protected resource metadata names the authorization server.

```http
GET https://api.send.io/.well-known/oauth-protected-resource
```

```json
{
  "resource": "https://api.send.io/",
  "resource_name": "send.io",
  "authorization_servers": ["https://api.send.io"],
  "scopes_supported": ["agent_unverified", "full_access"],
  "bearer_methods_supported": ["header"]
}
```

Hop two: the authorization server metadata carries the standard OAuth fields plus the `agent_auth` block.

```http
GET https://api.send.io/.well-known/oauth-authorization-server
```

```json
{
  "issuer": "https://api.send.io",
  "token_endpoint": "https://api.send.io/v0/token",
  "revocation_endpoint": "https://api.send.io/v0/revoke",
  "jwks_uri": "https://api.send.io/v0/jwks.json",
  "grant_types_supported": [
    "urn:ietf:params:oauth:grant-type:jwt-bearer",
    "urn:workos:agent-auth:grant-type:claim",
    "authorization_code"
  ],
  "scopes_supported": ["agent_unverified", "full_access"],
  "agent_auth": {
    "skill": "https://app.send.io/auth.md",
    "identity_endpoint": "https://api.send.io/v0/agents/identity",
    "claim_endpoint": "https://api.send.io/v0/agents/identity/claim",
    "identity_types_supported": ["anonymous", "identity_assertion", "service_auth"],
    "identity_assertion": {
      "assertion_types_supported": ["urn:ietf:params:oauth:token-type:id-jag"]
    },
    "events_endpoint": "https://api.send.io/v0/agents/identity/events",
    "events_supported": [
      "https://schemas.workos.com/events/agent/auth/identity/assertion/revoked"
    ]
  }
}
```

## Pick a method

- You know the human's email address and want them to own the account from the start: use `service_auth`. The claim ceremony starts at once and you get no credential until the human confirms.
- You have no email address, or you want to start emailing your human right now and let them claim later: use `anonymous`. You get a restricted account immediately (scope `agent_unverified`) and a claim token for later.
- You hold a signed identity assertion (ID-JAG) for send.io from your agent provider: use `identity_assertion`. If send.io trusts your provider and the human's email is verified there, you get a full-access account in one call, with no code for the human. If send.io answers `invalid_issuer`, it does not trust your provider: use `service_auth` with the email address from the assertion.

Scopes: with `agent_unverified` the inbox works and you can read mail, but outgoing email reaches only the human named at registration or claim, and you cannot create API keys, lists or pods. `full_access` is a normal send.io API key, granted after the human has confirmed.

## Register

Every request to the identity endpoint is a JSON POST with a `User-Agent` header; send.io rejects requests without one. Limit: 5 registrations per hour per network.

Optional in both bodies: `"username"` (a-z, 0-9, dot, dash, underscore, plus; 1 to 64 characters). It becomes your inbox address `<username>@agents.send.io`. Without it send.io picks one.

### anonymous

```http
POST https://api.send.io/v0/agents/identity
Content-Type: application/json
User-Agent: <agent name>/<version>

{ "type": "anonymous", "username": "<optional>" }
```

```json
{
  "registration_id": "<uuid>",
  "registration_type": "anonymous",
  "inbox": "<username>@agents.send.io",
  "identity_assertion": "<JWT signed by send.io>",
  "assertion_expires": "<RFC 3339 timestamp, 7 days from now>",
  "pre_claim_scopes": ["agent_unverified"],
  "claim_url": "/v0/agents/identity/claim",
  "claim_token": "<opaque token, valid 7 days>",
  "claim_token_expires": "<RFC 3339 timestamp>",
  "post_claim_scopes": ["full_access"]
}
```

Exchange the `identity_assertion` now for an `agent_unverified` access token (see "Exchange the assertion"). Keep the `claim_token` for the ceremony.

### service_auth

```http
POST https://api.send.io/v0/agents/identity
Content-Type: application/json
User-Agent: <agent name>/<version>

{ "type": "service_auth", "login_hint": "<human email>", "username": "<optional>" }
```

```json
{
  "registration_id": "<uuid>",
  "registration_type": "service_auth",
  "inbox": "<username>@agents.send.io",
  "claim_url": "/v0/agents/identity/claim",
  "claim_token": "<opaque token, valid 7 days>",
  "claim_token_expires": "<RFC 3339 timestamp>",
  "post_claim_scopes": ["full_access"],
  "claim": {
    "user_code": "<6 digits>",
    "expires_in": 600,
    "verification_uri": "https://app.send.io/claim?attempt=<token>",
    "interval": 5
  }
}
```

No assertion is returned: the ceremony has already started. Continue at "Claim ceremony", substep 2.

### identity_assertion

Ask your provider for an ID-JAG with audience `https://api.send.io`, then send it as is. Limit: 60 registrations per hour per network.

```http
POST https://api.send.io/v0/agents/identity
Content-Type: application/json
User-Agent: <agent name>/<version>

{
  "type": "identity_assertion",
  "assertion_type": "urn:ietf:params:oauth:token-type:id-jag",
  "assertion": "<ID-JAG from your provider>",
  "username": "<optional>"
}
```

```json
{
  "registration_id": "<uuid>",
  "registration_type": "identity_assertion",
  "inbox": "<username>@agents.send.io",
  "identity_assertion": "<JWT signed by send.io>",
  "assertion_expires": "<RFC 3339 timestamp, 7 days from now>",
  "scopes": ["full_access"]
}
```

send.io checks the ID-JAG before anything else: the `typ` header `oauth-id-jag+jwt`; an `iss` it trusts and a signature by one of that issuer's published keys; `aud` is `https://api.send.io`; `exp` not passed, `iat` not in the future, a lifetime of an hour at most; a `jti` it has not seen; a `client_id` the provider allows here; `email` with `email_verified` true; and `auth_time` within the last hour. The human gets a send.io account for that email, without a password, and becomes admin of your agent's account.

Registering again for the same human with the same `username` returns the same `registration_id`: that is how you get back into your account. Each ID-JAG works once, so ask your provider for a new one each time.

If that email already has a send.io account that was never linked to your provider, send.io does not link it silently. Your agent is registered unclaimed, the human is emailed, and the answer is a `401` carrying the claim ceremony:

```json
{
  "error": "interaction_required",
  "error_description": "...",
  "registration_id": "<uuid>",
  "registration_type": "identity_assertion",
  "inbox": "<username>@agents.send.io",
  "claim_url": "/v0/agents/identity/claim",
  "claim_token": "<opaque token, valid 7 days>",
  "claim_token_expires": "<RFC 3339 timestamp>",
  "post_claim_scopes": ["full_access"],
  "claim": {
    "user_code": "<6 digits>",
    "expires_in": 600,
    "verification_uri": "https://app.send.io/claim?attempt=<token>",
    "interval": 5
  }
}
```

Continue at "Claim ceremony", substep 2. Once the human approves, send.io remembers that your provider's subject is them: later ID-JAGs for the same human go straight through.

Exchange the `identity_assertion` for your API key (see "Exchange the assertion").

## Claim ceremony

The claim turns the registration into a normal send.io account owned by the human. It follows the device authorization pattern (RFC 8628): you show a code, the human confirms it in a browser, you poll.

1. Obtain the materials (anonymous registrations only; `service_auth` already returned them).

```http
POST https://api.send.io/v0/agents/identity/claim
Content-Type: application/json
User-Agent: <agent name>/<version>

{ "claim_token": "<claim_token>", "email": "<human email>" }
```

```json
{
  "registration_id": "<uuid>",
  "claim_attempt_id": "<uuid>",
  "status": "initiated",
  "expires_at": "<RFC 3339 timestamp, 10 minutes from now>",
  "claim_attempt": {
    "user_code": "<6 digits>",
    "expires_in": 600,
    "verification_uri": "https://app.send.io/claim?attempt=<token>",
    "interval": 5
  }
}
```

send.io also emails that address a link to the same page. One attempt is open at a time per registration; asking again while one is open returns `claimed_or_in_flight`. Limit: 10 claim requests per hour per network.

2. Hand off to the human. Show them the `user_code` and the `verification_uri`, for example: "Open https://app.send.io/claim?attempt=... (or the link send.io just emailed you) and enter the code 123456 to approve your agent." On that page the human proves the address (by arriving through the emailed link, or by being signed in to send.io with that email), sees your inbox address, and types the code. Five wrong codes end the attempt.

3. Poll for completion at the token endpoint, no more often than every `interval` seconds.

```http
POST https://api.send.io/v0/token
Content-Type: application/x-www-form-urlencoded

grant_type=urn:workos:agent-auth:grant-type:claim&claim_token=<claim_token>
```

While the human has not finished:

```json
{ "error": "authorization_pending", "error_description": "The human has not confirmed the code yet." }
```

When they have:

```json
{
  "access_token": "mx_...",
  "token_type": "Bearer",
  "scope": "full_access",
  "identity_assertion": "<JWT signed by send.io>",
  "assertion_expires": "<RFC 3339 timestamp>"
}
```

The `access_token` is a send.io API key with full access to the account. It does not expire; store it like a password. The claim token is consumed by this response: a further poll returns `expired_token`. Keep the new `identity_assertion` to obtain a replacement key later; it works once.

## Exchange the assertion

An `identity_assertion` is not a credential. Exchange it at the token endpoint with the JWT-bearer grant (RFC 7523):

```http
POST https://api.send.io/v0/token
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer&assertion=<identity_assertion>&resource=https://api.send.io/
```

```json
{
  "access_token": "mx_...",
  "token_type": "Bearer",
  "scope": "agent_unverified",
  "identity_assertion": "<the next assertion>",
  "assertion_expires": "<RFC 3339 timestamp>"
}
```

The scope is whatever the registration has at that moment: `agent_unverified` before the claim, `full_access` after. Each assertion works once: the exchange consumes it and the answer carries the next one, so always keep the newest `identity_assertion`. Each exchange also issues a new API key and retires the previous key of that registration. There are no refresh tokens: if you lose the key, exchange your newest assertion while it is valid. Limits: 30 exchanges per hour per registration, 120 per hour per network.

Checking the assertion yourself is optional. Header: `typ` is `oauth-id-jag+jwt`, `alg` is `RS256`, keys are at the `jwks_uri`. Claims: `iss` and `aud` are `https://api.send.io`, `sub` is the `registration_id`, `scope` is the current scope, `exp` matches `assertion_expires`.

## Use the access_token

Send it as a Bearer token on every send.io API call, always with a `User-Agent` header:

```http
POST https://api.send.io/emails
Authorization: Bearer mx_...
User-Agent: <agent name>/<version>
Content-Type: application/json

{ "from": "<username>@agents.send.io", "to": ["<human email>"], "subject": "Hello from your agent", "text": "..." }
```

The same key works for the Agent inboxes API under `/v0` (messages, drafts, webhooks), for the MCP server at `https://api.send.io/mcp`, and as the IMAP and SMTP password of the inbox. Rate limit: 10 requests per second per account. With `agent_unverified`, any recipient other than the human returns `403 missing_permission`. After the claim, use the key from the claim grant (or exchange the new assertion once) and the restriction is gone. A revoked or unknown key returns `401 invalid_api_key`; register again or ask the human for a new key.

## Errors

The authorization server (identity, claim, token and revoke endpoints) answers errors as JSON with `error` and `error_description`. The API itself answers with `statusCode`, `name` and `message`.

| error | returned by | what to do |
| --- | --- | --- |
| `invalid_request` | identity, claim, token | A field is missing or malformed. Fix the body; do not retry as is. |
| `invalid_issuer` | identity | send.io does not trust your provider. Use `service_auth` with the human's email. |
| `invalid_signature` | identity | The ID-JAG is not signed by your provider's published keys. Ask your provider for a new one. |
| `invalid_audience` | identity | The ID-JAG's `aud` is not `https://api.send.io`. Ask for one with that audience. |
| `invalid_client_id` | identity | Your provider's `client_id` may not register agents on send.io. |
| `expired` | identity | The ID-JAG expired. Ask your provider for a fresh one. |
| `replay_detected` | identity | That ID-JAG was already used. Ask your provider for a fresh one. |
| `missing_verified_email` | identity | The ID-JAG has no `email` with `email_verified` true. Use `service_auth` instead. |
| `login_required` (401) | identity | The human signed in at your provider more than `max_age` seconds ago. Ask them to sign in there again, then get a new ID-JAG. |
| `interaction_required` (401) | identity | The email already has a send.io account never linked to your provider. The response carries a `claim_token` and a `claim` block: show the human the code and link, then poll the claim grant. The human approves once. |
| `temporarily_unavailable` (503) | identity | send.io could not fetch your provider's keys. Retry shortly. |
| `address_taken` (409) | identity | That username is in use, also when you registered it yourself before (registering again never replaces a pending approval). Pick another or omit it. |
| `rate_limit_exceeded` (429) | identity, claim, token (jwt-bearer) | Wait, then retry. |
| `invalid_claim_token` | claim | Unknown claim token. Register again. |
| `claimed_or_in_flight` | claim | The registration is already claimed, or an attempt is open. Poll the token endpoint instead of starting another attempt. |
| `claim_expired` | claim | The claim token has expired. Register again. |
| `authorization_pending` | token (claim grant) | The human has not confirmed yet. Poll again after `interval` seconds. |
| `slow_down` | token (claim grant) | You polled too fast. Add 5 seconds to your interval. |
| `expired_token` | token (claim grant) | The attempt or the claim token expired, the attempt failed (five wrong codes), or the claim already completed. Start a new attempt at the claim endpoint, or register again. |
| `invalid_grant` | token (both grants) | The claim token is unknown, or the assertion was already used or revoked, is expired, malformed, not issued by send.io, or its registration no longer exists. Use your newest assertion, or register again. |
| `unsupported_grant_type` | token | Use one of the grant types from discovery. |

## Revocation

Credential layer (RFC 7009): revoke a key you no longer need.

```http
POST https://api.send.io/v0/revoke
Content-Type: application/x-www-form-urlencoded

token=mx_...&token_type_hint=access_token
```

`token` may also be your current `identity_assertion`: from then on it no longer exchanges, and the key it gave stays until you revoke that too. Returns `200` whether or not the token was still active. The human can also revoke keys and remove the agent in the dashboard; from then on the key returns `401` and the assertion no longer exchanges (`invalid_grant`).

Registration layer (RFC 8935): your provider can end the delegation it vouched for. It pushes a Security Event Token, signed with its published keys, to the `events_endpoint`:

```http
POST https://api.send.io/v0/agents/identity/events
Content-Type: application/secevent+jwt

<SET: iss, aud https://api.send.io, jti, iat, sub, events {"https://schemas.workos.com/events/agent/auth/identity/assertion/revoked": {}}>
```

send.io answers `202`. Every registration vouched for that `sub` loses its keys (`401 invalid_api_key`) and its assertion no longer exchanges (`invalid_grant`). The human keeps their send.io account. A later ID-JAG for the same human goes through the step-up (`interaction_required`); once the human approves, registering again with your old `username` brings your agent back with a new key. Errors use RFC 8935's shape, `{"err": "...", "description": "..."}`: `invalid_issuer`, `invalid_key`, `invalid_audience`, `invalid_request`. A SET older than 7 days is refused; a duplicate is accepted without effect.

## Register elsewhere with your send.io identity

send.io is also an agent provider. A verified send.io agent can register at other auth.md services with an ID-JAG from send.io, so its human does not fill in their sign-up form. The service must trust the issuer `https://api.send.io`, whose signing keys are at `https://api.send.io/v0/jwks.json`.

```http
POST https://api.send.io/v0/inboxes/<your inbox address>/id-jag
Authorization: Bearer mx_...
User-Agent: <agent name>/<version>
Content-Type: application/json

{ "audience": "<the service's issuer, from its /.well-known/oauth-authorization-server>" }
```

```json
{
  "assertion": "<ID-JAG, valid 5 minutes, use once>",
  "assertion_type": "urn:ietf:params:oauth:token-type:id-jag",
  "expires_in": 300,
  "audience": "<the service's issuer>",
  "identity_endpoint": "<the service's identity endpoint>",
  "sub": "<your agent's opaque id>"
}
```

Send `assertion` to the service's `identity_endpoint` as `type: identity_assertion`. The ID-JAG's `sub` is your agent, `email` is your human's verified address, and `auth_time` is when your human last signed in to send.io or verified you; a service that wants a fresher sign-in answers `login_required`, so ask your human to sign in to send.io. An optional `client_id` in the request is passed through; without it the `client_id` is your agent's opaque id. send.io refuses agents whose human has not verified them, and audiences that do not publish auth.md discovery.

To end these delegations, `DELETE https://api.send.io/v0/inboxes/<your inbox address>/id-jag`. Deleting your inbox does the same. Each service that publishes an `events_endpoint` receives the assertion-revoked Security Event Token for your agent.
