> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentonboard.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Publishing auth.md

> Host public /auth.md and /.well-known/auth.md discovery files so AI agents know your Domain, endpoints, and error handling rules.

When a User asks their AI Agent to interact with your app (for example, *"create a note on notes.com"*), the agent needs three facts:

1. Which **Domain** to pass to `get_token`.
2. Which **endpoints** to call and what request and response shapes they expect.
3. What to do when a request returns **`401`**, **`403`**, or **`500`**.

`auth.md` is a plain Markdown file hosted at both `https://<your-domain>/auth.md` and `https://<your-domain>/.well-known/auth.md` that gives agents all three in one GET request.

## Copy-paste agent prompt

```text theme={null}
Publish AgentOnboard discovery files (`auth.md`) in this repository.

1. Inspect the codebase to list every AgentOnboard-protected endpoint, its HTTP method, request/response shapes, and whether `POST /api/signup` exists.
2. Read https://docs.agentonboard.xyz/auth-md.md and https://docs.agentonboard.xyz/accounts.md before editing.
3. Ask me before writing files:
   - What is the production Domain hostname (must match `audience` in backend code)?
   - On `403 ACCOUNT_REQUIRED`, should agents call `POST /api/signup` or direct the User to a browser connect URL?
4. Create/serve the exact same `auth.md` content at both `/auth.md` and `/.well-known/auth.md` (with `200 OK`, `text/markdown` or `text/plain`, no auth, and no cross-host redirects).
5. Verify with `curl -i` against both `/auth.md` and `/.well-known/auth.md`, and run a test token via `POST https://agentonboard.xyz/api/v1/token/exchange` to confirm `403` and `200` responses match the table.
```

***

## Where to host it

Serve the same file at both paths over HTTPS with `200 OK`, no authentication, and no redirects to a different hostname:

* `https://<your-domain>/auth.md`
* `https://<your-domain>/.well-known/auth.md`

Some agents check `/auth.md` first while others check `/.well-known/auth.md` first. Publishing both paths ensures every agent runtime finds your discovery document on the first request.

In a Next.js app, place the file in both `public/auth.md` and `public/.well-known/auth.md` (or serve `public/auth.md` from a route handler at `/.well-known/auth.md/route.ts` so there is one source of truth):

**notes-api**

**public**

**.well-known**

**auth.md**

**auth.md**

**app**

**api**

**notes**

**route.ts**

**package.json**

> [!NOTE]
>
> **Origin & how agents read `auth.md`**
>
> The `/auth.md` discovery convention was pioneered by [WorkOS (`workos.com/auth-md`)](https://workos.com/auth-md) ([`github.com/workos/auth.md`](https://github.com/workos/auth.md)). AgentOnboard uses a 3-section `auth.md` format tailored for direct 5-minute JWT verification. Neither `@agentonboard/sdk` nor our server fetches this file; the **AI Agent** fetches `/auth.md` or `/.well-known/auth.md` before calling your API.

***

## Required sections

Include these three Markdown sections in order:

| Section | Purpose |
| - | - |
| `## Audience` | The exact Domain hostname to pass to `get_token(domain: "<string>")`. |
| `## Endpoints` | One `### <METHOD> <path>` block per endpoint with request body, response shape, and required `Authorization: Bearer <token>` header. |
| `## When a request is rejected` | A table mapping HTTP status codes (`401`, `403`, `500`) and `code` values to the exact action the agent should take. |

### Matching `## Audience` with your backend code

The hostname in `## Audience` must match the `audience` string you pass to `requireAgentAccount` or `verifyAgentToken` after normalization (lowercase hostname, no scheme, no path, no port except on `localhost`).

Write the bare hostname your API serves on (such as `notes.com`). If your API runs on a subdomain such as `api.notes.com`, use `api.notes.com` in both your backend code and `https://api.notes.com/auth.md`.

***

## Complete copy-paste templates

Choose the template that matches how your service handles unknown emails (see [Accounts & Agent Signup](https://docs.agentonboard.xyz/accounts.md)):

> [tab] Reject Unknown Users (Default)
>
> Use this template when all routes use `verifyAgentAccount` / `requireAgentAccount` and unknown users must connect an existing account in your browser UI:
>
> ```markdown title="public/auth.md" theme={null}
> # Notes API
>
> This service accepts AgentOnboard tokens. Requests are authorized against the Notes account matching the verified email in the token.
>
> ## Audience
>
> `notes.com`
>
>     get_token(domain: "notes.com")
>
> Send the token on every request as `Authorization: Bearer <token>`.
>
> ## Endpoints
>
> ### `POST /api/notes`
>
> Create a note. Rate limited to 60 requests per minute per account.
>
> - Request: `{ "title": string, "body": string }`
> - Success: `201` with `{ "id": string, "title": string, "body": string }`
> - Required header: `Authorization: Bearer <token>`
>
> ### `GET /api/notes`
>
> List the calling account's notes.
>
> - Request: no body; optional query `limit` (default 50, max 200)
> - Success: `200` with `{ "notes": Array<{ "id": string, "title": string }> }`
> - Required header: `Authorization: Bearer <token>`
>
> ## When a request is rejected
>
> | Status | `code` | What to do |
> |---|---|---|
> | 401 | any | The token was rejected or expired. Call `get_token` for `notes.com` again and retry **once**. If it fails again, stop and tell the human. |
> | 403 | `ACCOUNT_REQUIRED` | The identity is valid but has no Notes account. Ask the human to connect or create their account at https://notes.com/connect, then retry **once**. Retrying without that step will not succeed. |
> | 500 | `RESOLVER_ERROR` or `CONFIG_ERROR` | Server error during account lookup. Retry after a short delay with the same token. |
> ```

> [tab] Allow Agent Signup (POST /api/signup)
>
> Use this template when you expose a dedicated `POST /api/signup` handler with `createAgentAccount` so agents can register new users automatically:
>
> ```markdown title="public/auth.md" theme={null}
> # Notes API
>
> This service accepts AgentOnboard tokens. Requests are authorized against the Notes account matching the verified email in the token.
>
> ## Audience
>
> `notes.com`
>
>     get_token(domain: "notes.com")
>
> Send the token on every request as `Authorization: Bearer <token>`.
>
> ## Endpoints
>
> ### `POST /api/notes`
>
> Create a note. Rate limited to 60 requests per minute per account.
>
> - Request: `{ "title": string, "body": string }`
> - Success: `201` with `{ "id": string, "title": string, "body": string }`
> - Required header: `Authorization: Bearer <token>`
>
> ### `GET /api/notes`
>
> List the calling account's notes.
>
> - Request: no body; optional query `limit` (default 50, max 200)
> - Success: `200` with `{ "notes": Array<{ "id": string, "title": string }> }`
> - Required header: `Authorization: Bearer <token>`
>
> ### `POST /api/signup`
>
> Create the calling account. When an agent receives `403 ACCOUNT_REQUIRED` on another endpoint, it calls `POST /api/signup` with the same token and then retries the original request once.
>
> - Request: no body
> - Success: `201` with `{ "user": string, "created": boolean }`
> - Required header: `Authorization: Bearer <token>`
>
> ## When a request is rejected
>
> | Status | `code` | What to do |
> |---|---|---|
> | 401 | any | The token was rejected or expired. Call `get_token` for `notes.com` again and retry **once**. If it fails again, stop and tell the human. |
> | 403 | `ACCOUNT_REQUIRED` | The identity is valid but has no Notes account. Call `POST /api/signup` with the same token to create the account, then retry the original request **once**. |
> | 500 | `RESOLVER_ERROR` or `CONFIG_ERROR` | Server error during account lookup. Retry after a short delay with the same token. |
> ```

***

## Pre-publish checklist

* [ ] Both `https://<your-domain>/auth.md` and `https://<your-domain>/.well-known/auth.md` return `200 OK` without authentication or cross-host redirects.
* [ ] `## Audience` matches the normalized `audience` string in your backend code.
* [ ] The `403 ACCOUNT_REQUIRED` row matches your live flow (browser connect URL or `POST /api/signup`).

> [card] [Accounts & Agent Signup](https://docs.agentonboard.xyz/accounts.md)
>
> Compare rejecting unknown users vs. adding POST /api/signup.

> [card] [Testing & Production](https://docs.agentonboard.xyz/testing-and-production.md)
>
> Run all six curl checks before going live.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.