---
title: "Authentication"
description: "Every way to authenticate with ONE — a person's key, a passkey and the backup doors, sessions, API keys, terminal login, agent sign-up and the auth.md flow — with every endpoint, header and refusal."
type: reference
audience: both
verified: 2026-11-24
canonical: https://one.ie/docs/auth
---
Every request to ONE carries one of three things: a browser session, a Bearer key, or
nothing. This page lists every way to get the first two, what each endpoint takes and
returns, and what each refusal means. What a caller may do once it is known is a
separate question: [Authority and access](/docs/authority). The overview for people is
[one.ie/auth](https://one.ie/auth).

## The doors at a glance

| Door | Who | Proves | Gives | Session door |
|---|---|---|---|---|
| Your key | a person | a signature from a sign-in key worked out from their key | a session | `key` |
| Passkey | a person | WebAuthn, user-verified on their device | a session | `passkey` |
| Google, GitHub | a person | the provider's account | a session | `recovery` |
| Email link | a person | the inbox, for 5 minutes | a session | `recovery` |
| Email and password | a person who set one | the password | a session | `recovery` |
| Terminal login | a person, in a terminal | a fresh passkey assertion at `/device` | a person's API key | — |
| `POST /api/auth/agent` | an agent | nothing | an agent API key | — |
| auth.md | an agent, optionally for a person | an assertion, a claim code, or a provider's ID-JAG | a 1-hour access token | — |

Every session records the door it was minted by: `key`, `passkey` or `recovery`. A
session with no door, including every session minted before the column existed, reads
`recovery`. `KEY_DOOR_MODE` is `warn` today: an irreversible step taken from a
`recovery` session is logged and allowed. Refusing it is a reviewed code change, never a
setting (`src/lib/auth-plugins/session-door.ts`).

## People: your key

The primary door. The browser signs a challenge with a `purpose:auth` child of the
person's key, bound once to the funded account. The sign-in key holds no money, so a
phished sign-in signature cannot spend. An address that was never bound (an outside
wallet that holds no master) is still accepted and signs in as itself.

```bash
# 1. A challenge for the address that will sign
curl -s 'https://one.ie/api/auth/sui-wallet/nonce?addr=0x<address>'
# → { "nonce": "<payload>.<hmac>", "message": "Sign in to ONE as 0x…\nNonce: …\nExpires: …", "exp": 1764000000000 }

# 2. Sign `message` as a Sui personal message, then:
curl -s https://one.ie/api/auth/sui-wallet/verify \
  -H 'content-type: application/json' \
  -d '{"address":"0x<address>","signature":"<base64 signature>","nonce":"<nonce>"}'
# → a session cookie (door: key)
```

The nonce is HMAC-signed, lives 5 minutes, and is spent in D1 (`auth_nonce_used`) before
a session is issued, so each one works once. Binding a sign-in key:
`POST /api/auth/sui-wallet/bind-auth-key`; linking and unlinking a further key:
`/sui-wallet/link-key`, `/sui-wallet/unlink-key`.

## People: passkey

Touch ID, Face ID or Windows Hello, over WebAuthn. The same assertion can unseal the
person's key on that device (the PRF extension). Passkey challenges are stateless and
HMAC-signed; they are not single-use.

| Endpoint | Does |
|---|---|
| `POST /api/auth/passkey-webauthn/authenticate/options` | options for a sign-in |
| `POST /api/auth/passkey-webauthn/authenticate` | verifies the assertion, mints a session (door `passkey`) |
| `POST /api/auth/passkey-webauthn/register/options` · `/register` | adds a passkey to a signed-in account |
| `POST /api/auth/passkey-webauthn/register-anonymous/options` · `/register-anonymous` | a new account whose first credential is a passkey |

The relying party is `one.ie` on ONE's own origins (`https://one.ie`,
`https://app.one.ie`, `https://pay.one.ie`). A verified custom domain gets its own host
as the RP ID, so a passkey made there does not answer one.ie.

## People: the backup doors

| Door | Endpoint | Rules |
|---|---|---|
| Google | `/api/auth/sign-in/social` → `/api/auth/callback/google` | Better Auth social provider |
| GitHub | `/api/auth/sign-in/social` → `/api/auth/callback/github` | Better Auth social provider |
| Email link | `POST /api/auth/sign-in/magic-link` | the link lives 5 minutes; on a verified custom domain it opens there, and one.ie refuses it |
| Email and password | `POST /api/auth/sign-in/email` | sign-up by password is disabled; a password is set only by a session on a proven inbox (`POST /api/auth/set-password`); 8 to 128 characters; PBKDF2-SHA-256, 100,000 iterations |

Better Auth links a sign-in to an existing account by email when it comes from a trusted
provider: `sui-wallet`, `google`, `github` or `magic-link`. Changing an account's email needs the
old inbox to approve first.

Recovery is paper. The 24 words are the key; ONE holds only a sealed copy it cannot open
and cannot recover a lost key. [one.ie/recover](https://one.ie/recover) lists three ways
back, two of which reach no ONE server.

## Sessions

| Fact | Value |
|---|---|
| Lifetime | 365 days, renewed once a day while used |
| Cookie cache | 1 hour without a database read; a change to staff reaches a browser within it |
| Scope | the `.one.ie` domain and its subdomains |
| Custom domain | the session carries the host it was minted on and is refused elsewhere; the browser holds a `__Host-` cookie never sent to one.ie |
| Rate limit | Better Auth's limiter, configured at 100 requests per 60 seconds |
| As a Bearer | Better Auth's `bearer` plugin: the session token works as `Authorization: Bearer <token>` |

```bash
curl -s https://one.ie/api/auth/sessions -H 'cookie: <session cookie>'          # list
curl -s -X DELETE https://one.ie/api/auth/sessions/<id> -H 'cookie: <session cookie>'   # end one
curl -s https://one.ie/api/auth/sessions -H 'cookie: <session cookie>' \
  -H 'content-type: application/json' -d '{"action":"revoke-all"}'               # end the rest
curl -s -X POST https://one.ie/api/auth/sign-out -H 'cookie: <session cookie>'   # this one
```

The middleware reads a session from four sources, in order: the Better Auth cookie or
Bearer; `DEV_SLUG` on localhost only; the act-as cookie; and the `__Host-` cross-domain
cookie on a verified custom domain.

## Act-as

A signed cookie (`session-act-as`) that renders pages as another account. Every act-as
session is read-only: any write except `POST /api/act-as/end` answers
`403 { "error": "act_as_read_only" }`. It expires, and `end` revokes it at once.

| Who may start it | Longest |
|---|---|
| platform staff | 8 hours |
| an owner of a group the person belongs to | 4 hours |
| the holder of a `manage_clients` delegation over the person's parent organisation | 2 hours |

`?as=visitor` and the other See-as lenses only narrow a page render; they never add an
identity, and every `/api` call still runs as the real person.

## Teams and domains

Authentication says who; the group tree says what they may do. ONE walks up from the
group to its parents and takes the first answer. Rungs are `owner` (3), `admin` (2),
`member` (1) and `viewer` (0), and every decision is one of three answers: yes, `403`
(no), or `503` (could not read, retry). The full model:
[Authority and access](/docs/authority).

An owner invites by link (`/join?token=…`, from `POST /api/invites/create`). The person
signs in through any door and `POST /api/invites/accept` writes the membership.

A custom domain is trusted only once its `domains` row is verified. Then it has its own
passkey RP ID, its own email links, a host-bound session and a `__Host-` cookie.
Approving a terminal login happens only on ONE's own origins.

## API keys

Every API key is a world key: `one-…` (older keys `osk_…`), stored as a SHA-256 hash,
shown once, resolved to one actor. A key does exactly what its actor may do. When a
browser session and a key arrive together at `/api/ask`, the session wins.

```bash
curl -s https://one.ie/api/ask/meta:catalog \
  -H 'authorization: Bearer one-…' \
  -H 'content-type: application/json' \
  -d '{"data":{}}'
```

| Key | Minted by | Expires |
|---|---|---|
| A person's key | `npx oneie login`, or Profile › API keys | as minted |
| An agent's home key | `npx oneie init` | 90 days by default, at most 365 |
| A self-registered agent key | `POST /api/auth/agent` | never; revoke it |
| Any actor's key | `world:create-key` (`expiresIn` seconds) | as set |
| A staff-minted person key | `world:mint-owner-key`, platform staff only | as minted |
| An auth.md access token | `POST /api/oauth2/token` | 1 hour |

List with `world:list-keys`, revoke with `world:revoke-key`. A key held by an agent,
with no browser session, is refused five labels whatever its role: `manage_workspace`,
`manage_clients`, `manage_members`, `manage_groups`, `manage_actors`. Kinds, the purse
rule and grants: [Authority](/docs/authority#what-a-bearer-key-attests).

## Terminal login

`npx oneie login` is an RFC 8628 device flow. The terminal never handles a secret it did
not ask for, and the browser never sees the key.

| Step | Endpoint | Notes |
|---|---|---|
| request | `POST /api/auth/mcp/device/code` `{client_id, scope}` | anonymous; 10 pending per IP; returns `device_code`, `user_code` (`XXXX-XXXX`), `verification_uri`, `expires_in: 600`, `interval: 5` |
| verify | `GET /device?user_code=…` | signed in; shows the requester's IP, place and client before Approve |
| approve | `POST /api/auth/mcp/device/approve` | the session plus a fresh user-verified passkey assertion over a single-use challenge (120 seconds); the code typed in full; without the assertion, `401 fresh_auth_required` |
| poll | `POST /api/auth/mcp/device/token` `{device_code, client_id}` | `authorization_pending` · `slow_down` · `expired_token` · `access_denied`; on success the key is returned once |

The CLI stores the key in `~/.config/oneie/key` (mode 0600). `ONEIE_API_KEY` in the
environment works too, and is what the SDK (`SubstrateClient.fromApiKey`) and the MCP
server read. All three read a 401 or 403 challenge and name the refusal.

## Agents: sign up in one call

```bash
curl -s https://one.ie/api/auth/agent -H 'content-type: application/json' -d '{}'
# → { "uid": "swift-scout", "apiKey": "one-…", "wallet": null, "group": "group:swift-scout",
#     "workspace": "swift-scout", "next": "…" }
```

Open by design: no credential, 10 a minute per IP (the counter fails closed). The key
does not expire and reaches only the agent's own group. The same door is the receiver
`auth:agent`. An agent registers a receiving address by signature:
`wallet:challenge` issues a fresh single-use challenge, and `wallet:create` stores the
address once the signature checks.

## Agents: auth.md

For an agent that brings a person, or wants a standard OAuth token, ONE implements
[auth.md](/auth.md). The resource is `https://one.ie/`; the issuer is `https://one.ie`.

```
agent                                  ONE
  |  GET /.well-known/oauth-protected-resource
  |------------------------------------> resource https://one.ie/
  |  POST /api/agent/identity
  |------------------------------------> identity_assertion, 24 h
  |       service_auth: a person types a 6-digit code
  |       at one.ie/auth/claim
  |  POST /api/oauth2/token   (once per assertion)
  |------------------------------------> access_token one-..., 1 h
  |  POST /api/ask/<receiver>   Bearer one-...
  |------------------------------------> the answer, a 401 or a 403
```

**Discover.** `GET /.well-known/oauth-protected-resource` names the resource, the
authorization server and `scopes_supported`. `GET /.well-known/oauth-authorization-server`
carries `token_endpoint`, `revocation_endpoint`, `grant_types_supported` and the
`agent_auth` block (`identity_endpoint`, `claim_endpoint`, `events_endpoint`).

**Register.** `POST /api/agent/identity` with one of three types:

```bash
curl -s https://one.ie/api/agent/identity -H 'content-type: application/json' \
  -d '{"type":"anonymous"}'

curl -s https://one.ie/api/agent/identity -H 'content-type: application/json' \
  -d '{"type":"service_auth","login_hint":"person@example.com"}'
# → claim: { user_code: "123456", verification_uri: "https://one.ie/auth/claim?cat=cla_…", expires_in: 86400, interval: 5 }

curl -s https://one.ie/api/agent/identity -H 'content-type: application/json' \
  -d '{"type":"identity_assertion","assertion_type":"urn:ietf:params:oauth:token-type:id-jag","assertion":"<ID-JAG>"}'
```

| Type | Scopes | Notes |
|---|---|---|
| `anonymous` | `api.read api.write` | no person; each registration is a new actor `reg_<hex>` |
| `service_auth` | all three, once claimed | the person signs in to ONE and types the 6-digit `user_code` at `verification_uri`; the window is 24 hours. The claim grant mints the token for the person's own slug: the agent acts as that person, with their authority, inside the token's scopes |
| `identity_assertion` | by the issuer's status | ID-JAG: `typ: oauth-id-jag+jwt`, ES256 or RS256, `aud` `https://one.ie/`, single-use `jti`, `auth_time` within the last hour, a verified email or phone. The actor is `<iss>:<sub>`; ONE does not keep the email |

**Exchange, once.**

```bash
curl -s https://one.ie/api/oauth2/token \
  -d grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer \
  -d assertion=<identity_assertion> \
  -d resource=https://one.ie/
# → { "access_token": "one-…", "token_type": "Bearer", "expires_in": 3600, "scope": "api.read api.write" }

curl -s https://one.ie/api/oauth2/token \
  -d grant_type=urn:workos:agent-auth:grant-type:claim \
  -d claim_token=<claim_token>
# → authorization_pending until the person confirms; poll every 5 seconds
```

ONE records each assertion's `jti`; the second exchange is `invalid_grant` ("assertion
already used"). An assertion ONE minted before 2026-11-24 carries `aud:
https://api.one.ie/`; the token endpoint accepts that audience until 2026-12-08 00:00 UTC
and only `https://one.ie/` after. When the hour is up: an `identity_assertion` agent mints a fresh ID-JAG
and registers again; a claimed `service_auth` registration presents the claim grant
again until its 24-hour window closes; an `anonymous` agent registers again.

An `anonymous` or `identity_assertion` actor joins a workspace only by adoption: the agent asks for a link (`/api/agent/own-link`) and a signed-in person accepts it at `/auth/adopt`. The person's `/u/<slug>/identity` lists the agents acting as them; each agent's `/u/<slug>/agents/<id>/identity` shows how it signed in, and `Revoked by <provider>` once a provider ends the delegation.

**Revoke.** `POST /api/oauth2/revoke` with `token=<access_token>&token_type_hint=access_token`
(RFC 7009) always answers 200.

## Scopes

| Scope | Lets the token call |
|---|---|
| `api.read` | receivers that only read: an `ask` that moves no value, whose verb starts `get`, `list`, `search`, `find`, `mine`, `view`, `board`, `stats`, `count` and the like (`src/lib/receiver-scope.ts`) |
| `api.write` | every other receiver, plus `/api/mark` and `/api/warn`; includes `api.read` |
| `workspace:manage` | receivers whose auth label or role action is `owner`, `admin`, `platform`, `update_group`, `mint_capability`, `verify_domain` or `manage_*`; includes `api.write` |

Only an access token from `/api/oauth2/token` carries a scope (`world_keys.scopes`). ONE
checks it after the key resolves and before any authority check, on every door that
takes a token: `/api/ask` (a call signed by a chip key meets the scope of the token it
was listed under), every route behind `requireAuth` (`/api/mark` and `/api/warn` among
them), the `/api/export/*`, `/api/paths` and `/api/learning` reads (`api.read`),
`/api/agents/float` (`api.read` to read, `api.write` to unlock), `/api/agent/own-link`
and `/api/sui/sponsor` (`api.write`), and the device flow's `grant_type: adopt`
(`workspace:manage`). `/api/signal` takes no token; it is the platform's service door.
Keys minted any other way carry no scope and are unrestricted; a stored scope that does
not parse holds nothing. A scope is a ceiling, never a grant: the token still does only
what its actor may in the group tree. A short scope answers:

```http
HTTP/1.1 403
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"}
```

## Trusted agent providers

The issuers `identity_assertion` accepts are `AGENT_PROVIDERS` in
`src/lib/agent-providers.ts`, the same list [one.ie/auth](https://one.ie/auth) renders.

| Provider | `iss` | Status |
|---|---|---|
| Anthropic (Claude) | `https://identity.anthropic.com/issuers/{issuer-id}` | verified, one issuer per organisation, added by exact URL |
| 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 |
| Google (Gemini) | `https://accounts.google.com` | plausible |

A **verified** issuer, or one an operator names in `TRUSTED_ID_JAG_ISSUERS`, registers
with all three scopes. A **plausible** one registers with `api.read api.write`, and the
person claims `workspace:manage` through `service_auth`. `AGENT_PROVIDERS_MODE`
(`all`, `verified`, `off`) narrows the built-in list without a release.

A trusted provider revokes a delegation by posting an RFC 8417 Security Event Token to
`POST /api/agent/event/notify` (`Content-Type: application/secevent+jwt`). ONE ends that
registration and every token minted from it, and answers 202.

## Refusals

| Status | Name | Where | Means | Do |
|---|---|---|---|---|
| 401 | `unauthorized` + `WWW-Authenticate: Bearer resource_metadata="https://one.ie/.well-known/oauth-protected-resource"` | `/api/ask` | no credential | send a Bearer, or start at auth.md |
| 401 | `invalid_token` + `Bearer error="invalid_token", resource_metadata="…"` | `/api/ask` | a Bearer that matches no live key, session or token | mint a key, or exchange a fresh assertion |
| 403 | `insufficient_scope` + `Bearer error="insufficient_scope", scope="<needed>", …` | every door that takes a token ([Scopes](#scopes)) | an auth.md token whose scope is too small | register a way that grants it; a person claims `workspace:manage` |
| 200 | `outcome: "failure"`, `forbidden: true` | `/api/ask` | the caller is known and may not do this; a signed-out page on one.ie also gets this | act on a group you control |
| 503 | `authority_undetermined` | `requireAuth` routes | the group tree could not be read | retry; never a no |
| 400 | `invalid_grant` | `/api/oauth2/token` | expired, or already exchanged | register again |
| 400 | `authorization_pending` | claim grant | the person has not typed the code yet | poll in 5 seconds |
| 401 | `login_required` | `/api/agent/identity` | the ID-JAG's `auth_time` is missing or over an hour old | re-authenticate at the provider |
| 400 | `invalid_issuer` | `/api/agent/identity` | the `iss` is not trusted | use `anonymous` or `service_auth` |
| 401 | `fresh_auth_required` | `/api/auth/mcp/device/approve` | no fresh passkey assertion | approve again with the passkey |
| 403 | `act_as_read_only` | any write while acting as someone | act-as is read-only | end it first |

Every other code: [Errors](/docs/errors).

## Known limits

- `KEY_DOOR_MODE` is `warn`: a `recovery` session's irreversible steps are logged, not
  refused.
- A self-registered agent key never expires; the only kill is `world:revoke-key`.
- `anonymous` auth.md registration proves nothing about who is calling.
- No provider on the trusted list is known to mint auth.md ID-JAGs for ONE yet, except
  an Anthropic organisation whose exact issuer is added.
- Google is trusted as plausible: a Google service-account ID token (any audience, `typ: JWT`,
  no `auth_time`) is refused by the `typ` and `auth_time` checks; only a real ID-JAG passes.