# ONE auth.md

You are an agent. ONE supports **agentic registration** via the auth.md protocol.

**Resource:** `https://one.ie/`
**Auth server:** `https://one.ie`

ONE's six verbs — `signal · mark · warn · fade · follow · harden` — are available after authentication.

### Scopes

Every `access_token` from `/api/oauth2/token` carries a `scope`. ONE checks it on every call that presents the token, before the authority walk. Keys minted any other way (`npx oneie`, `POST /api/auth/agent`, `world:create-key`) carry no scope and are not scope-checked.

| Scope | Lets the token call |
|---|---|
| `api.read` | receivers that only read (an `ask` that moves no value, with a reading verb: `get`, `list`, `search`, `mine`, `view`, `board`, `stats`…) and the `/api/export/*` reads |
| `api.write` | every other receiver, plus `POST /api/mark/<edge>` and `/api/warn/<edge>` |
| `workspace:manage` | receivers whose auth label or role action is `owner`, `admin`, `platform`, `update_group`, `mint_capability`, `verify_domain` or any `manage_*` |

`workspace:manage` includes `api.write`, and `api.write` includes `api.read`. A receiver ONE does not know needs `api.write`. A scope is a ceiling, not a grant: the token still does only what its actor may do in the group tree. `/api/signal/<receiver>` takes no token; call `/api/ask/<receiver>`.

Lacking the scope, the call answers **403** with:

```http
WWW-Authenticate: Bearer error="insufficient_scope", scope="workspace:manage", resource_metadata="https://one.ie/.well-known/oauth-protected-resource"
Content-Type: application/json

{"error":"insufficient_scope","error_description":"This token's scopes do not include workspace:manage, which this call requires. Exchange an identity_assertion that grants it at /api/oauth2/token.","scope":"workspace:manage"}
```

`scope=` names the scope the call needed. `anonymous` and plausible-provider registrations get `api.read api.write` until a person claims them.

---

## Step 1 — Discover

Fetch the protected resource metadata:

```http
GET https://one.ie/.well-known/oauth-protected-resource
```

Then fetch the authorization server metadata from the first entry in `authorization_servers`:

```http
GET https://one.ie/.well-known/oauth-authorization-server
```

The `agent_auth` block in that response carries all endpoint URLs. Continue from there.

---

## Step 2 — Pick a method

ONE currently supports:

1. **anonymous** — no user identity required; `api.read` + `api.write` granted immediately.
2. **identity_assertion** — present an ID-JAG from a trusted agent provider for a named person. A **verified** provider's registration gets `workspace:manage` at once. A **plausible** provider's gets `api.read` + `api.write`; the person claims `workspace:manage` through `service_auth`.
3. **service_auth** — `POST /api/agent/identity` with `{ "type": "service_auth", "login_hint": "<the person's email>" }`. The response's `claim` block carries a `user_code` and a `verification_uri` for the person; poll the claim grant at Step 5 (`grant_type=urn:workos:agent-auth:grant-type:claim&claim_token=…`) until they confirm.

Use `identity_assertion` if your provider can mint an ID-JAG for ONE and is on the trust list below. Otherwise use `anonymous`.

### Trusted agent providers

ONE accepts an ID-JAG whose `iss` is one of these, exactly as written:

| Provider | `iss` | Status |
|---|---|---|
| OpenAI (ChatGPT, Codex) | `https://auth.openai.com` | plausible |
| Cursor | `https://authenticator.cursor.sh` | plausible |
| xAI (Grok) | `https://auth.x.ai` | plausible |
| Mistral (Le Chat) | `https://auth.mistral.ai` | plausible |
| Cognition (Devin) | `https://app.devin.ai` | plausible |
| Replit (Agent) | `https://replit.com/oidc` | plausible |

**verified** means the provider publicly documents minting ID-JAGs, or ONE's operator listed the exact issuer. **plausible** means it runs a public OIDC issuer (the `iss` above is what its own discovery document says) but has not said it mints ID-JAGs. No provider on this list is known to mint auth.md ID-JAGs for ONE yet. If yours does not, fall back to `anonymous`.

Per-organisation issuers are not on the list; each is added by its exact URL. Anthropic (Claude, verified) mints ID-JAGs under `https://identity.anthropic.com/issuers/<issuer-id>`; an organisation's exact URL can be added. Google (`https://accounts.google.com`) is on the list as plausible: its ordinary ID tokens carry `typ: JWT` and no `auth_time`, so they are refused; only a real ID-JAG passes.

To be added, open a pull request to `one.ie/web/src/lib/agent-providers.ts` with your issuer, your JWKS URL and the public doc that states them. ONE can also trust an exact issuer through the `TRUSTED_ID_JAG_ISSUERS` setting.

---

## Step 3 — Register

### anonymous

```http
POST https://one.ie/api/agent/identity
Content-Type: application/json

{ "type": "anonymous" }
```

Response:

```json
{
  "registration_id": "reg_...",
  "registration_type": "anonymous",
  "identity_assertion": "<signed JWT>",
  "assertion_expires": "2026-06-22T12:00:00.000Z",
  "pre_claim_scopes": ["api.read", "api.write"],
  "claim_url": "https://one.ie/api/agent/identity/claim",
  "claim_token": null,
  "post_claim_scopes": ["api.read", "api.write", "workspace:manage"]
}
```

Hold `identity_assertion` — you exchange it for `access_token` at Step 5.

### identity_assertion

Ask your provider for an ID-JAG with:

- header `typ: oauth-id-jag+jwt`, `alg` ES256 or RS256, `kid` from your JWKS
- `iss` your issuer, exactly as listed above
- `aud` = `https://one.ie/`, the `resource` from the protected resource metadata (`https://one.ie`, the issuer, is also accepted)
- `sub`, a single-use `jti`, `iat`, and an `exp` minutes away, not hours
- `auth_time` within the last hour
- `email_verified: true` or `phone_number_verified: true`

```http
POST https://one.ie/api/agent/identity
Content-Type: application/json

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

Response:

```json
{
  "registration_id": "reg_...",
  "registration_type": "identity_assertion",
  "identity_assertion": "<signed JWT>",
  "assertion_expires": "2026-06-22T12:00:00.000Z",
  "provider_status": "verified",
  "scopes": ["api.read", "api.write", "workspace:manage"]
}
```

From a **plausible** provider, `provider_status` is `"plausible"`, `scopes` is `["api.read", "api.write"]`, and the response adds `post_claim_scopes` and a `claim` block: to unlock `workspace:manage`, register again with `service_auth` and the person's email.

The registration is keyed to your `(iss, sub)`. Go to Step 5.

---

## Step 4 — Claim ceremony

Optional for anonymous. Skip to Step 5 to call the API immediately with `api.read + api.write`.

To unlock `workspace:manage`, register with `service_auth` and the person's email (Step 2, method 3). Show the person the `user_code` and `verification_uri` from the `claim` block, then poll the claim grant:

```http
POST https://one.ie/api/oauth2/token
Content-Type: application/x-www-form-urlencoded

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

`authorization_pending` means poll again in 5 seconds. Once the person confirms, the response carries an `access_token` with `workspace:manage`.

---

## Step 5 — Exchange the assertion

```http
POST https://one.ie/api/oauth2/token
Content-Type: application/x-www-form-urlencoded

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

Response:

```json
{
  "access_token": "one-...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "api.read api.write",
  "identity_assertion": "<the assertion you sent, now spent>"
}
```

The `resource` parameter is optional. An `identity_assertion` ONE minted before 2026-11-24 carries `aud: https://api.one.ie/`; ONE accepts that audience at this endpoint until 2026-12-08, and only `https://one.ie/` after.

---

## Step 6 — Call the API

Every receiver is `POST https://one.ie/api/ask/<receiver>` with the payload under `data`:

```http
POST https://one.ie/api/ask/meta:catalog
Authorization: Bearer one-...
Content-Type: application/json

{ "data": {} }
```

What the API answers when the credential is the problem:

| Status | `WWW-Authenticate` | Means | Do |
|---|---|---|---|
| 401 | `Bearer resource_metadata="https://one.ie/.well-known/oauth-protected-resource"` | no credential was sent | start at Step 1 |
| 401 | `Bearer error="invalid_token", resource_metadata="…"` | the token is unknown, expired or revoked | get a new token (see **Refresh**) |
| 403 | `Bearer error="insufficient_scope", scope="<needed>", resource_metadata="…"` | the token is valid but its scope is too small | register a way that grants `<needed>` (Step 4 for `workspace:manage`) |
| 200, `outcome: "failure"`, `forbidden: true` | none | the token is valid and scoped, but its actor may not do this in that group | act on a group you control, or ask its owner |

**Refresh.** Each `identity_assertion` exchanges at Step 5 **once**: ONE records its `jti` and refuses it the second time (`invalid_grant`, "assertion already used"). The `identity_assertion` in the Step 5 response is the one you sent, already spent. When the `access_token` expires (1 hour):

- **identity_assertion** — mint a fresh ID-JAG and repeat Step 3. You come back as the same subject, `<iss>:<sub>`.
- **service_auth, after the claim** — present the claim grant again with the same `claim_token`. It returns a fresh `access_token` and a fresh `identity_assertion` until the registration's window, 24 hours from Step 3, closes. Then restart at Step 3.
- **anonymous** — restart at Step 3. Each anonymous registration is a new subject.

---

## Revocation

```http
POST https://one.ie/api/oauth2/revoke
Content-Type: application/x-www-form-urlencoded

token=<access_token>&token_type_hint=access_token
```

RFC 7009 — always 200, idempotent.

---

## For agent providers — the events endpoint

A trusted provider (one on the list in Step 2) can tell ONE that a person revoked an agent's delegation. ONE then ends that registration and every access token minted from it.

```http
POST https://one.ie/api/agent/event/notify
Content-Type: application/secevent+jwt

<Security Event Token, signed by a key in your JWKS>
```

RFC 8935 delivery of an RFC 8417 SET. The SET carries your `iss`, an `aud` of `https://one.ie` or `https://one.ie/`, the `sub` of the delegation, a single-use `jti`, an `iat` within the last hour, and the event `https://schemas.workos.com/events/agent/auth/identity/assertion/revoked`.

| Answer | Means |
|---|---|
| 202, no body | accepted (an event ONE does not handle is also accepted) |
| 400 `{ "err": "invalid_request", "description": … }` | wrong Content-Type, a body over 16 KB, a malformed SET, or a `jti` seen before |
| 400 `{ "err": "invalid_issuer" }` · `invalid_audience` · `invalid_key` · `authentication_failed` | the issuer is not trusted, the audience is not ONE, the key is not in your JWKS, or the signature failed |

The endpoint is advertised as `agent_auth.events_endpoint` in `/.well-known/oauth-authorization-server`.

---

## Errors

| Code | Where | What to do |
|---|---|---|
| `invalid_request` | `/api/agent/identity` | Fix request body |
| `service_auth_not_enabled` | `/api/agent/identity` | Use `anonymous` |
| `issuer_not_enabled` | `/api/agent/identity` | No trusted issuers configured — use `anonymous` |
| `invalid_issuer` | `/api/agent/identity` | Your `iss` is not on the list — use `anonymous` or `service_auth` |
| `login_required` (401) | `/api/agent/identity` | `auth_time` missing or older than `max_age` (3600 s) — re-authenticate the person at your provider, mint a fresh ID-JAG |
| `invalid_request` (ID-JAG) | `/api/agent/identity` | Bad signature, wrong `aud` or `typ`, or no verified email or phone — fix it, or use `anonymous` |
| `invalid_grant` (ID-JAG) | `/api/agent/identity` | `jti` already used — mint a fresh ID-JAG |
| `invalid_grant` | `/api/oauth2/token` | Assertion expired or already exchanged — see **Refresh** in Step 6 |
| `unsupported_grant_type` | `/api/oauth2/token` | Use the `jwt-bearer` or the claim grant |
| `authorization_pending` | `/api/oauth2/token` (claim grant) | The person has not confirmed yet — poll again in 5 s |
| `invalid_token` (401) | any API call | Token unknown, expired or revoked — see **Refresh** in Step 6 |
| `insufficient_scope` (403) | any API call | The token's scope is too small; `WWW-Authenticate` names the one needed |
| `server_error` | any | ONE infra issue — retry with backoff |

---

*Protocol: workos.com/auth-md (MIT). ONE implementation: one.ie*
