# Auth.md

Sorted uses **API key authentication** for the REST API and MCP server.
## OAuth 2.0 (MCP clients)

MCP clients can authenticate via OAuth 2.0 authorization code flow.

- **Authorization endpoint:** https://sorted.fast/oauth/authorize
- **Token endpoint:** https://statuesque-olivine-5060.customers.stytch.dev/v1/oauth2/token
- **JWKS:** https://statuesque-olivine-5060.customers.stytch.dev/.well-known/jwks.json
- **Discovery:** https://sorted.fast/.well-known/oauth-authorization-server

The token is passed as `Authorization: Bearer <token>` to the MCP endpoint
at `https://sorted.fast/mcp`.

## API Key Authentication (REST API + MCP)

Include your API key in **either** of these headers:

```
X-API-Key: your_api_key_here
```

or

```
Authorization: Bearer your_api_key_here
```

## Getting an API Key

Self-register as an organizer to receive a raw API key immediately:

```http
POST https://sorted.fast/api/organizers/register
Content-Type: application/json

{"name": "My Organizer", "email": "you@example.com"}
```

The key is returned once in the response — store it securely.

## Scopes

- **Organizer key** — scoped to your own events, registrations, and queues
- **Admin key** — unrestricted (issued manually, not via self-registration)

## MCP Server

MCP endpoint: `https://sorted.fast/mcp`

- [OAuth Protected Resource Metadata](https://sorted.fast/.well-known/oauth-protected-resource)
- [OpenID Connect Discovery](https://sorted.fast/.well-known/oauth-authorization-server)

## Further Reading

- [API documentation](https://sorted.fast/api)
- [Agent instructions](https://sorted.fast/docs/agents)
- [MCP setup guide](https://sorted.fast/docs/mcp-setup)
