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

> ## Agent Instructions
> Mono is an AI platform for small and medium-sized firms in Switzerland, Germany, Austria and Italy. Answer in the reader's language. Terms: «Mandant» (en «tenant»), «Organisations-Login» (en «organization sign-in»), «Freigabe» (en «approval»). Reading needs no approval; every write waits for one. Never suggest pasting a key or token into a chat.

# Use the Node API

> Call a Node’s Console API under /api/v1: sign-in, discovery, CORS, contract and errors.

The Console API under `/api/v1` is the interface through which the Mono Console controls every Node (The tenant’s server. It holds the data, checks permissions and carries out every approval.). Your own tools use the same API, with the same permissions and the same audit as a click in the Console.

> [accordion] What you need
>
> * A running Node, locally with `pnpm dev:gateway` at `http://localhost:8787` ([Run from source](https://mono.mintlify.site/en/developers/run-from-source.md)).
> * A token of the audience `console` for a person of the tenant. What you may do with it is decided by that person’s role.

## The first request

**1. Get a token**

At its first start, the development Node writes the file `services/gateway/.mono/dev-tokens.json`. It holds one token per demo person (Anna Keller and Marco Rossi as admins, Lea Meier as a member) and per audience (`console`, `admin-mono`, `muster-gateway`). The Node never prints the tokens in the log.

```bash macOS and Linux theme={"system"}
# Anna Keller (admin), audience "console"
TOKEN=$(jq -r 'to_entries[]
  | select(.value.audience == "console" and .value.user.id == "u-anna")
  | .key' services/gateway/.mono/dev-tokens.json)
```

```powershell Windows theme={"system"}
# Anna Keller (admin), audience "console"
$tokens = Get-Content services/gateway/.mono/dev-tokens.json | ConvertFrom-Json
$TOKEN = ($tokens.PSObject.Properties |
  Where-Object { $_.Value.audience -eq "console" -and $_.Value.user.id -eq "u-anna" } |
  Select-Object -First 1).Name
```

For the tenant server, replace `console` with `muster-gateway`; for “Mono Admin”, with `admin-mono`. The person ids are `u-anna`, `u-marco` and `u-lea`.

**2. Ask who you are**

```bash macOS and Linux theme={"system"}
curl -s http://localhost:8787/api/v1/me \
  -H "Authorization: Bearer $TOKEN" | jq '.mandanten'
```

```powershell Windows theme={"system"}
Invoke-RestMethod http://localhost:8787/api/v1/me `
  -Headers @{ Authorization = "Bearer $TOKEN" } |
  Select-Object -ExpandProperty mandanten
```

**3. Read the tenant’s MCP servers**

```bash macOS and Linux theme={"system"}
curl -s http://localhost:8787/api/v1/mandanten/muster-ag/servers \
  -H "Authorization: Bearer $TOKEN"
```

```powershell Windows theme={"system"}
Invoke-RestMethod http://localhost:8787/api/v1/mandanten/muster-ag/servers `
  -Headers @{ Authorization = "Bearer $TOKEN" }
```

> [!TIP]
>
> `/me` names Anna Keller with the role `admin` at `muster-ag`. The server list contains “Muster AG” at `http://localhost:8787/muster-gateway/mcp` and “Mono Admin” at `http://localhost:8787/admin-mono/mcp`, each with the number of tools and the tool budget 40.

```json Response of /mandanten/muster-ag/servers (shortened) theme={"system"}
{
  "servers": [
    { "id": "muster-gateway", "name": "Muster AG", "kind": "company", "audience": "all",
      "url": "http://localhost:8787/muster-gateway/mcp", "tools": 10, "toolsVisible": 10, "toolBudget": 40 },
    { "id": "admin-mono", "name": "Mono Admin", "kind": "admin", "audience": "admins",
      "url": "http://localhost:8787/admin-mono/mcp", "tools": 38, "toolsVisible": 38, "toolBudget": 40 }
  ]
}
```

## Every route has a way in the chat

What the Console API can do, “Mono Admin” can do in the chat as well: every route under `/api/v1` has a way in the chat (a tool, a guided flow) or a stated reason why it has none, for example because it concerns a person’s own profile. A test in the Node fails as soon as a new route is added without this entry.

> [!NOTE]
>
> The **API reference** in the navigation lists every route with its method, path, permissions, response and its way in the chat. It is generated from the code.

## Find the Node: discovery

Every Node answers `GET /.well-known/mono-node` publicly, without sign-in, with CORS `*` and cacheable for 5 minutes. The answer contains no secret, no person and no content: only what the sign-in page shows anyway.

```bash theme={"system"}
curl -s http://localhost:8787/.well-known/mono-node
```

**version** `number` *required*

Version of the discovery, today `1`. A Console calmly refuses a higher number.

**node** `object` *required*

**Fields**

**version** `string`

Version of the Node software.

**kind** `"selfhosted" | "cloud"`

Self-hosted or in Mono Cloud.

**region** `string`

Only for hosted Nodes, for example `eu-frankfurt`.

**publicUrl** `string`

The address by which the Node knows itself.

**mandant** `object` *required*

`id` (for example `muster-ag`, the path segment in `/api/v1/mandanten/:id/…`), `name` and optionally `logoUrl` (https only).

**servers** `array` *required*

The MCP servers with `id`, `name` and `audience` (`alle` or `admins`), never their tools.

**console.auth** `object` *required*

How the Console signs in. `kind` is `dev` (only on this computer), `oidc` or `unavailable` with a reason.

**With kind “oidc”**

**provider** `string`

`node` (the Node brokers the sign-in itself), `microsoft`, `google`, `mono-cloud` or `dev`.

**issuer** `string`

The issuer of the tokens.

**clientId** `string`

The Console’s public client, at the Node `mono-console`.

**scopes** `string[]`

For example `openid`, `profile`, `email`, `offline_access`.

**methods** `array`

With `node`: the active sign-in methods, in the order of the sign-in page.

**links.console** `string`

Where the Console for this Node runs, if the Node knows it.

**join.requests** `boolean`

`true` if the sign-in page accepts access requests.

## Sign in

**Authorization** `string` *required*

`Bearer <token>` with the audience `console`. Without a token, the Node answers `401` with «Anmeldung nötig» (“Sign-in needed”).

> [tab] Locally
>
> The development Node accepts the tokens from `.mono/dev-tokens.json`. They are valid without expiry, only on this computer, and never when `NODE_ENV=production` is set.

> [tab] On a Node with sign-in
>
> Your tool signs in like the Console: OAuth 2.1 with authorization code and PKCE (`S256`) at the Node as the OpenID provider.
>
> 1. Read `console.auth` from the discovery. With `provider: "node"`, the Node is the issuer.
> 2. `GET /.well-known/openid-configuration` names the endpoints: `/oauth/authorize`, `/oauth/token`, `/oauth/jwks`, `/oauth/revoke`, `/oauth/logout`.
> 3. Request with `client_id=mono-console`, the scopes from the discovery and an allowed return address. Allowed are `<Console>/anmelden` of an origin from `MONO_CONSOLE_ORIGINS` and, for programs on your own computer, `http://127.0.0.1:<port>/callback` on any port, as the desktop app does.
> 4. The person signs in with their method. The token endpoint returns an access token and a refresh token.
>
> An access token is valid for at most one hour. Every refresh checks the person again: groups, directory and “Who may sign in” apply as they are today. After 90 days, the person signs in again.

> [accordion] A Node with its own identity provider
>
> A Node that runs with `MONO_AUTH=oidc` also accepts access tokens of the organization sign-in. Their audience is the Node’s client ID or one of the audiences from `MONO_CONSOLE_AUDIENCE`. Even then, the Node brokers the Console’s sign-in; the discovery says `provider: "node"`.

## CORS

| Route | Who may access it from the browser |
| - | - |
| `/.well-known/mono-node`, icons, `/.well-known/openid-configuration` | any origin (`*`) |
| `/api/v1/…` | the origins from `MONO_CONSOLE_ORIGINS` (default `http://localhost:5173`) and the desktop app (`tauri://localhost`, `http://tauri.localhost`) |

Allowed headers are `Authorization`, `Content-Type`, `If-Match` and `If-None-Match`; the Node exposes `ETag`. The Node answers the `OPTIONS` preflight request before any sign-in. That is how a Console asks “Will this Node let me in?” without writing a line to the audit.

## The contract: @mono/node-contract

All requests and responses are Zod schemas in the package `@mono/node-contract`. The Node answers through them, the Console reads through them. The schema removes unknown fields.

```ts my-tool.ts theme={"system"}
import { MeResponse, ServersResponse } from "@mono/node-contract";

const node = "http://localhost:8787";
const headers = { Authorization: `Bearer ${process.env.TOKEN}` };

const me = MeResponse.parse(await (await fetch(`${node}/api/v1/me`, { headers })).json());
const mandant = me.mandanten[0]!.id;
const { servers } = ServersResponse.parse(
  await (await fetch(`${node}/api/v1/mandanten/${mandant}/servers`, { headers })).json(),
);
console.log(servers.map((s) => `${s.name}: ${s.url}`));
```

> [!NOTE]
>
> `@mono/node-contract` is a workspace package and is used as TypeScript source, not through npm. A tool in the repository includes it with `"@mono/node-contract": "workspace:*"`.

## Errors

Every refusal has the same shape, with a German sentence that says what happened.

**error** `string` *required*

A stable code, for example `unauthorized`, `forbidden`, `not_found`, `invalid_input`, `conflict`.

**message** `string` *required*

The reason in a full sentence (German), for example «Nur für Admins dieses Mandanten» (“For this tenant’s admins only”).

**reason** `string`

For some refusals, a machine-readable addition, for example `admins_only`.

```json 403 for a member on an admin route theme={"system"}
{ "error": "forbidden", "message": "Nur für Admins dieses Mandanten", "reason": "admins_only" }
```

| Status | `error` | Meaning |
| - | - | - |
| 400 | `invalid_input` | The request does not have the shape of the contract. |
| 401 | `unauthorized` | No token or an unknown one. The response carries `WWW-Authenticate`. |
| 403 | `forbidden`, `tool_off`, `paused` | The person may not do this, or the tool or the app is switched off or paused. |
| 404 | `not_found`, `unknown_tool` | Tenant, object or tool is not known on this Node. |
| 409 | `conflict` | Already decided, or an older version (see below). |
| 428 | `precondition_required` | The version is missing (`If-Match`). |
| 503 | `unavailable` | No allowed provider, for example for a model; the message says why. |
| 500 | `internal` | An internal error. The Node writes the path to the log, never content. |

> [accordion] Versions with ETag and If-Match
>
> Objects that several people edit at the same time, such as the tenant notes or “Groups and roles”, answer with `ETag: "<version>"`. A change sends `If-Match: "<version>"` along. If the version is missing, the Node answers `428`; if it is outdated, `409` with the current version. Then reload and apply your change again.

> [accordion] What goes into the audit
>
> Every change through the API writes an entry to the tenant’s chained audit: who, what, outcome. Content is never in it. If an admin reads the full preview of another person’s approval, `approval.viewed` is written, also without content.

> [accordion] Is there an undo?
>
> No. The Node carries out an approved action at once. Design your tool so that it shows the preview with `GET /api/v1/approvals/:id` before a decision.

## Next

> [card] [MCP servers](https://mono.mintlify.site/en/developers/mcp-servers.md)
>
> The same capabilities in the chat.

> [card] [Tools of “Mono Admin”](https://mono.mintlify.site/en/developers/mcp/admin-mono.md)
>
> The reference of the admin tools.

> [card] [Architecture](https://mono.mintlify.site/en/developers/architecture.md)
>
> Where the contract belongs.

> [card] [Security](https://mono.mintlify.site/en/developers/security.md)
>
> The security model in brief.


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