# auth.md — how an AI agent registers with Rosuii

Rosuii is a bilingual (Bangla–English) restaurant management platform for
Bangladesh: POS, online ordering, menu, inventory, CRM, payroll, attendance and
rider management, with an isolated database per restaurant.

This document tells an autonomous agent how to obtain a working credential for
the Rosuii REST API without a human filling in a signup form.

- **Service:** Rosuii — https://rosuii.com
- **API:** https://api.rosuii.com/v1 (OpenAPI: https://api.rosuii.com/docs/json)
- **Audience for this document:** AI agents and automated clients evaluating or
  integrating the Rosuii API on a user's behalf.

## What you get: a demo credential

Registration is **anonymous** and issues a **demo credential** against the Rosuii
demo restaurant. That is the only identity type offered here, on purpose.

| | |
|---|---|
| Reads | every `/v1` endpoint, against the demo restaurant |
| Writes | create an order; update the status or payment of an order **this credential created** |
| Denied | menu, staff, customers, reservations, riders, settings — and any real restaurant's data |
| Lifetime | 7 days, extended each time you call the token endpoint |
| Cost | free, no email, no human |

Demo orders are deleted an hour after they are created, and no real diner or
restaurant data is reachable with this credential. Anything outside the write
list returns `403` with `{ "code": "demo_mode" }`.

**Real restaurant accounts are not issued to agents.** Rosuii provisions a
separate tenant database per signup, so an automated path to a real account is
an automated path to spam. A person signs up at https://rosuii.com/register and
creates a full API key in **Panel → Settings → API access**. See
https://rosuii.com/agent/claim

## Register

```http
POST https://rosuii.com/agent/auth
Content-Type: application/json

{
  "identity_type": "anonymous",
  "credential_type": "api_key",
  "agent_name": "your agent's name"
}
```

Every field is optional; the body above is also the default. `credential_type`
may be `api_key` or `bearer` — the same token, sent in a different header.

Response `201`:

```json
{
  "identity_type": "anonymous",
  "mode": "demo",
  "client_id": "agent_123",
  "client_secret": "rsk_…",
  "access_token": "rsk_…",
  "token_type": "Bearer",
  "expires_in": 604800,
  "scope": "demo:read demo:orders",
  "resource": "https://api.rosuii.com",
  "api_base": "https://api.rosuii.com/v1",
  "verify": "https://api.rosuii.com/v1/me",
  "restaurant": { "id": "demo", "name": "Bhuri Bhoj" },
  "claim_uri": "https://rosuii.com/agent/claim"
}
```

`GET /agent/auth` returns the same description as JSON and changes nothing, so
it is safe for a passive scan. `POST` mints a credential — do not probe it.

Rate limit: **5 registrations per IP per hour**. Reuse the credential you hold.

## Use the credential

```http
GET https://api.rosuii.com/v1/me
x-api-key: rsk_…
```

`Authorization: Bearer rsk_…` works identically. `/v1/me` echoes the restaurant
the credential resolves to — call it first to confirm the key works.

An unauthenticated `/v1` request answers `401` with a pointer back to the
discovery document, per RFC 9728:

```
WWW-Authenticate: Bearer realm="Rosuii",
  resource_metadata="https://api.rosuii.com/.well-known/oauth-protected-resource"
```

## OAuth token exchange (optional)

The credential from `/agent/auth` is already a bearer token, so this step is not
required. It exists for clients driven by an OAuth library, and it refreshes the
7-day expiry:

```http
POST https://rosuii.com/agent/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=agent_123&client_secret=rsk_…
```

Returns `{ "access_token", "token_type": "Bearer", "expires_in", "scope" }`.
`client_credentials` is the only supported grant.

## Discovery documents

| Document | URL |
|---|---|
| Protected resource metadata (RFC 9728) | https://api.rosuii.com/.well-known/oauth-protected-resource |
| Site-level protected resource metadata (RFC 9728) | https://rosuii.com/.well-known/oauth-protected-resource |
| Authorization server metadata (RFC 8414) | https://rosuii.com/.well-known/oauth-authorization-server |
| The same document at the OIDC probe path | https://rosuii.com/.well-known/openid-configuration |
| Authorization server metadata for owner-delegated access (RFC 8414) | https://api.rosuii.com/.well-known/oauth-authorization-server |
| API catalog (RFC 9727) | https://rosuii.com/.well-known/api-catalog |
| OpenAPI 3.0 description | https://api.rosuii.com/docs/json |
| Product facts for answer engines | https://rosuii.com/llms.txt |

The API-origin document declares `https://api.rosuii.com` as its resource.
The site-level document independently declares `https://rosuii.com`, as RFC 9728
requires the resource value to match the origin used to retrieve its well-known
metadata. Both identify the same Rosuii authorization server and demo scopes.

`https://rosuii.com` is the issuer for anonymous demo credentials and supports
`client_credentials` only: there is no account owner to send to a consent
screen, so it publishes no authorization endpoint and no PKCE methods. A
restaurant owner delegating access to its own account uses the second issuer,
`https://api.rosuii.com`, with `authorization_code` and PKCE (`S256`). The site
document names it under `delegated_authorization_server`; read that issuer's own
metadata for its endpoints.

## agent_auth

```json
{
  "skill": "https://rosuii.com/auth.md",
  "register_uri": "https://rosuii.com/agent/auth",
  "token_uri": "https://rosuii.com/agent/token",
  "claim_uri": "https://rosuii.com/agent/claim",
  "identity_types_supported": ["anonymous"],
  "anonymous": {
    "credential_types_supported": ["api_key", "bearer"],
    "claim_uri": "https://rosuii.com/agent/claim",
    "scopes_supported": ["demo:read", "demo:orders"],
    "credential_lifetime_seconds": 604800
  }
}
```

## Beyond the API

The public content on this site is meant to be read and cited by agents: every
page answers to `Accept: text/markdown`, and every recipe and blog post ships a
markdown twin at `<path>.md`. Start at https://rosuii.com/llms.txt.

Questions a credential cannot answer: info@rosuii.com
