# auth.md

How an automated client obtains a credential for the GateReady API.

GateReady is a guest-first event ticketing platform. Every read, and the whole
ticket-purchase path, works **without an account** — so an agent buying tickets
for someone registers nothing and holds no secret. An agent acting for an
account holder — an organizer, promoter, vendor or gate staffer — carries a
bearer token that only that person can issue.

| | |
| --- | --- |
| Audience | Autonomous agents and other non-browser clients acting for a human |
| API base | `https://app-web-gateready-test.azurewebsites.net/api` |
| OpenAPI description | https://app-web-gateready-test.azurewebsites.net/openapi/agent-v1.json |
| API catalog (RFC 9727) | https://app-web-gateready-test.azurewebsites.net/.well-known/api-catalog |
| Developer documentation | https://app-web-gateready-test.azurewebsites.net/developers |
| Terms of service | https://app-web-gateready-test.azurewebsites.net/terms |
| Contact | https://app-web-gateready-test.azurewebsites.net/contact |

## Methods

Two, and which one applies is decided by what the agent is doing rather than by
negotiation: buying tickets needs no account, and everything scoped to an
account needs that account's token.

### 1. Guest session — anonymous, no registration

The provisioning endpoint for an agent that is buying:

```http
POST https://app-web-gateready-test.azurewebsites.net/api/Auth/guest-session
Content-Type: application/json

{
  "firstName": "Ada",
  "lastName": "Lovelace",
  "email": "ada@example.com",
  "phoneNumber": "+254700000000"
}
```

```json
{
  "data": {
    "id": "0f9c1a3e-...",
    "sessionToken": "...",
    "expiresAt": "2026-01-01T12:10:00Z"
  },
  "success": true
}
```

Send `data.id` — a GUID — as a header on every subsequent request:

```http
X-Guest-Session-Id: 0f9c1a3e-...
```

- **What the credential is.** An opaque identifier for server-side state, not a
  bearer token and not a secret: it authorizes nothing on its own, it carries
  the cart, reservation and order across the checkout, and it is scoped to the
  contact details supplied when it was minted.
- **Lifetime.** Ten minutes by default, extended while the session is in use. An
  expired id is not renewable — mint a new session and start the checkout again.
- **Contact details are real.** Tickets and payment receipts are delivered to
  the address and number given here, so an agent must use the buyer's own and
  must have their consent to supply them.
- **What it reaches.** Browsing events and tiers, server-authoritative pricing,
  reserving seats, paying, and looking up the resulting order and tickets. It
  reaches nothing that belongs to an account.

### 2. Bearer token — an existing account

```http
POST https://app-web-gateready-test.azurewebsites.net/api/Auth/login
Content-Type: application/json

{ "email": "organizer@example.com", "password": "..." }
```

The response carries an access token and a refresh token; send the access token
as `Authorization: Bearer <access token>`. Access tokens are short-lived (30
minutes in production) and are exchanged through `POST /api/Auth/refresh`,
which rotates the 7-day refresh token on each use.
`POST /api/Auth/external/google` and `.../external/apple` accept a
provider ID token instead of a password, and an account with two-factor enabled
completes login at `POST /api/Auth/2fa/login`.

**An agent does not register an account of its own.**
`POST /api/Auth/register` creates an account for a *person*: it
verifies an email address, and the roles that make a token useful — organizer,
promoter, vendor, gate staff — are derived from profile state that an operator
approves, never from anything a caller asserts. An agent is therefore given a
token by the account holder and acts within that account's existing authority.
The holder revokes it by changing the password or through
`POST /api/Auth/sessions/{sessionId}/revoke`, either of which
invalidates every token already issued.

## Model Context Protocol

The same two credentials serve the MCP server. It is hosted by the API — the
host that answers this origin's `/api/*` path — and not by this
origin directly, so the endpoints below are relative to that host:

| Endpoint | Credential | Surface |
| --- | --- | --- |
| `/mcp` | `Authorization: Bearer <access token>` | The tools the caller's own roles allow |
| `/mcp/guest` | None | The anonymous checkout tools only |

The tool list is computed per request from the caller's token, and **write tools
are withheld** unless an operator has allowlisted them, because an MCP client
has no surface on which a human can approve an action. An agent that needs a
write it cannot see should ask the operator rather than retry.

## Not supported

Stated so a client stops looking:

- **No OAuth authorization server.** GateReady is not one. There is no
  `/.well-known/oauth-protected-resource`, no
  `/.well-known/oauth-authorization-server`, no authorization-code or
  client-credentials grant, and no token endpoint beyond the login and refresh
  routes above.
- **No dynamic client registration, and no agent registration endpoint.** There
  is no `POST /agent/auth`. The guest session above is the whole of anonymous
  provisioning.
- **No API keys or service accounts.** Every credential belongs to a person or
  to a single anonymous checkout.

## Fair use

Requests are rate limited per caller — per guest session, per account, and per
IP address. A throttled request answers `429` with code `RATE_LIMIT_EXCEEDED`
and a `Retry-After` header; honour it rather than retrying immediately. Totals
are recomputed server-side at purchase, so re-price through
`POST /api/Tickets/price-preview` before paying. Use of the API is
subject to the terms at https://app-web-gateready-test.azurewebsites.net/terms.
