# BackResto Partner API auth.md

This API serves software and agents acting for a partner that one or more restaurants using BackResto have authorised. It is read-only.

## Get credentials

There is no self-service registration. A person on the partner's side requests a key at https://developers.backresto.com/en/docs/access. Once the restaurants concerned agree, BackResto issues a key of the form `brp_<prefix>.<secret>`, scoped to those restaurants and to named record types. An agent cannot register itself: if you have no key, ask the person you act for to request one.

## Use the key

Send it on every request:

```http
Authorization: Bearer brp_<prefix>.<secret>
```

The same header works on the REST API (https://api.backresto.com/v1/...) and on the MCP server (https://api.backresto.com/mcp).

## Connect an MCP client by URL

Clients that take only a server URL (claude.ai and Claude Desktop custom connectors, ChatGPT connectors) find the authorization server through the 401 above, register at https://api.backresto.com/oauth/register, and open https://api.backresto.com/oauth/authorize in a browser. The person pastes the key there. The code flow requires PKCE (S256), and the access token it returns is the key, as below.

## OAuth 2.0 client credentials

Clients that only speak OAuth can exchange the key at the token endpoint. The client_id is the part of the key before the dot, the client_secret the part after it.

```http
POST /oauth/token HTTP/1.1
Host: api.backresto.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic base64(client_id:client_secret)

grant_type=client_credentials
```

The access token returned is the key itself, with `token_type` Bearer and the scopes it carries. It does not expire on its own; it stops working when BackResto revokes the key.

## Discovery

- Protected resource metadata: https://api.backresto.com/.well-known/oauth-protected-resource
- Authorization server metadata: https://api.backresto.com/.well-known/oauth-authorization-server
- A 401 carries `WWW-Authenticate: Bearer resource_metadata="https://api.backresto.com/.well-known/oauth-protected-resource"`.

## Revocation

Keys are revoked by BackResto, on request or when a restaurant withdraws its consent. A revoked key answers 401. Write to contact@backresto.com to revoke a key you hold.
