# Service API

The endpoints a service gets from the Python SDK (`sdks/python/src/allowedby/sdk.py`, `AllowedBy.mount` and `AllowedBy.wsgi`), next to its own routes. The SDKs in other languages serve the discovery endpoints identically; see the contract for what each implements.

| Endpoint |  |
|---|---|
| `GET /.well-known/allowedby` | What the service is and offers: vocabulary, templates, keys, the signed organisation profile, the disclosure key. |
| `GET /openapi.json` | OpenAPI 3.1 of the route map, with the capability and level of each operation. |
| `GET /.well-known/api-catalog` | RFC 9727 catalogue of the API descriptions. |
| `GET /.well-known/allowedby/tenants/{tenant}` | A tenant's authority policy and the keys that sign it. |
| `POST /allowedby/callback` | The node delivers an approval's state and encrypted personal data, with a signed proof (AMH-1 §5). |
| `POST /allowedby/link` | Link the person's identity to their account, with a one-time `code` (ABY-3 §6). |
| `GET /allowedby/admin` | The admin console (HTML). |
| `GET /allowedby/admin/api` | The console's data. Admin token. |
| `POST /allowedby/admin/api/routes` | Change a route's `level`, `class`, `authn` or `mandate` (`index` of the route). Admin token. |
| `POST /allowedby/admin/api/tenants` | Change a tenant's rules or budget for a `capability`. Admin token. |

## Request headers (agents)

| Header |  |
|---|---|
| `Allowed-By` | the agent's passport (level 0 routes), or the grant or delegation chain, leaf first |
| `AllowedBy-Proof` | a proof JWT signed by the agent's key for this exact request, new each time |

See [ABY-2](https://docs.allowedby.com/specs/ABY-2-http). Both headers together are at most 8192 characters.

## A refused request

The code and status are in Errors. A missing approval answers `401` with `WWW-Authenticate: AllowedBy ...` and a problem document; an agent follows it and retries.
