# MGWiki – API reference

*MGWiki 5.9.0 · 2026-11-22 · 196 endpoints*

## Overview

Everything the MGWiki interface shows and does goes through this API - the screens use exactly these
endpoints, with the rights of the person signed in. Requests and answers are JSON (UTF-8) unless an
endpoint says otherwise (CSV, PDF, Excel, files, the AI's stream).

The address is the installation's own, e.g. `https://mgwiki.example.com`; on the server itself
`http://127.0.0.1:8719`. All paths below begin with `/api/`. Administration is under `/api/admin/…`.

## Signing in

**API token (for scripts and other systems).** A person creates a token under *Account → API tokens*;
it is shown once. Send it in every request:

```
Authorization: Bearer axw_<token>
```

A token carries exactly the rights of the person who made it - an administrator's token may do what an
administrator may, nothing more. *Who may* below names what an endpoint demands before anything else; on
top of that, an endpoint checks the rights on the very item (a project's permissions, a space's, a page's
restrictions) and answers 403 or 404 where they are missing. A revoked token is refused at once. Keep tokens out of logs and scripts
that others read.

**Session (the browser).** `POST /api/auth/login` with `{"username": "…", "password": "…"}` sets a
session cookie; `POST /api/auth/logout` ends it. Passkeys and the sign-in through identity providers
(Microsoft Entra, Google, Okta) go through the sign-in page, Active Directory accounts through the same
`POST /api/auth/login`.

## Errors

An error is an HTTP status with a JSON body:

```json
{"error": "A sentence that says what is wrong", "code": "optional_machine_readable_code"}
```

| Status | Meaning |
|---|---|
| 400 | The request is not right - the sentence says what. |
| 401 | Not signed in, or the token is not valid. |
| 403 | Signed in, but not allowed - or, for changes, no valid licence (`code: license_required`). |
| 404 | Not there, or not visible to this person (the API does not tell the two apart). |
| 409 | In conflict with what is there (e.g. a name taken). |
| 413 | Too big - send big files in pieces (see below). |
| 429 | Too many requests - wait as long as `Retry-After` says. |
| 500 | Unexpected; the answer carries `ref`, a reference that is in the server's log with the details. |

## Limits

Requests without a session are limited to 300 a minute per address, signed-in clients and tokens to
1200 a minute (each counted per worker process; an installation can change both,
`<PRODUCT>_RATE_LIMIT_ANON` and `<PRODUCT>_RATE_LIMIT`). Above it the answer is `429` with `Retry-After`
in seconds. `/api/health` is never limited; signing in (`/api/auth/…`) has a lockout after failed
attempts of its own instead.

## Formats

- Times are ISO 8601 in UTC, e.g. `2026-11-06T14:30:00Z`; plain dates `2026-11-06`.
- Durations are seconds (`seconds`), or text where an endpoint says so (`timeSpent: "1h 30m"`).
- Lists that can be long take `limit` and `offset` where they say so; the answer says how many there are.

## Big files in pieces

Proxies in front of a server often take only so much per request (Cloudflare: 100 MB). Big files go in
pieces of up to 50 MB:

1. `POST /api/uploads` with `{"filename": "…", "size": <bytes>}` → `{"id": "<upload id>", …}`
2. `PUT /api/uploads/<id>/<n>` with the bytes of piece `n` (0, 1, 2 …) as the body, in order
3. `GET /api/uploads/<id>` says how far it got - ask before sending a piece again after a break
4. attach the finished file with `"uploadId": "<id>"` in place of a form file; `DELETE /api/uploads/<id>`
   gives up

An upload belongs to whoever began it; one not finished within a day is removed.

## The AI assistant's answers

`POST /api/ai/ask` with `{"question": "…", "conversation": "<any id of the conversation>"}` answers as a
stream of JSON lines (`application/x-ndjson`), one event per line, as the work goes on:

| `type` | What it carries |
|---|---|
| `start` | the log id of this question |
| `step` | a tool the assistant used: `tool`, `input`, `summary` |
| `sources` | what it found and opened: `items` |
| `list` | a list from the database, with the query that made it |
| `chart` | a chart to draw: `chart` = `{type, title, labels, series[{name, values}], unit}` |
| `draft` | a change prepared for the person to confirm |
| `text` | the answer, in pieces |
| `error` | what went wrong, in a sentence |
| `end` | the answer is complete |

Every number in a chart comes from a tool result of the same answer; the assistant acts with the rights
of the person who asks.


## Contents

- [admin/ai](#area-admin-ai) – 13
- [admin/announcement](#area-admin-announcement) – 2
- [admin/applinks](#area-admin-applinks) – 6
- [admin/audit-log](#area-admin-audit-log) – 1
- [admin/audit-log.csv](#area-admin-audit-log-csv) – 1
- [admin/branding](#area-admin-branding) – 4
- [admin/changelog](#area-admin-changelog) – 1
- [admin/confluence](#area-admin-confluence) – 7
- [admin/database](#area-admin-database) – 2
- [admin/db](#area-admin-db) – 4
- [admin/entra](#area-admin-entra) – 4
- [admin/global-permissions](#area-admin-global-permissions) – 2
- [admin/groups](#area-admin-groups) – 6
- [admin/identity](#area-admin-identity) – 5
- [admin/instance](#area-admin-instance) – 2
- [admin/labels](#area-admin-labels) – 3
- [admin/license](#area-admin-license) – 3
- [admin/links](#area-admin-links) – 4
- [admin/mail](#area-admin-mail) – 3
- [admin/mail-queue](#area-admin-mail-queue) – 1
- [admin/notification-schemes](#area-admin-notification-schemes) – 2
- [admin/public-site](#area-admin-public-site) – 4
- [admin/sections](#area-admin-sections) – 1
- [admin/space-permission-catalog](#area-admin-space-permission-catalog) – 1
- [admin/spaces](#area-admin-spaces) – 1
- [admin/subjects](#area-admin-subjects) – 1
- [admin/system-info](#area-admin-system-info) – 1
- [admin/templates](#area-admin-templates) – 4
- [admin/users](#area-admin-users) – 3
- [admin/webhooks](#area-admin-webhooks) – 5
- [ai](#area-ai) – 11
- [applinks](#area-applinks) – 4
- [archive](#area-archive) – 2
- [attachments](#area-attachments) – 3
- [auth](#area-auth) – 5
- [comments](#area-comments) – 2
- [dashboard](#area-dashboard) – 1
- [health](#area-health) – 2
- [links](#area-links) – 1
- [macros](#area-macros) – 3
- [me](#area-me) – 8
- [notifications](#area-notifications) – 2
- [pages](#area-pages) – 29
- [pdf-layouts](#area-pdf-layouts) – 3
- [search](#area-search) – 1
- [spaces](#area-spaces) – 16
- [templates](#area-templates) – 1
- [third-party](#area-third-party) – 1
- [uploads](#area-uploads) – 4

## Area: `admin/ai`

<a id="area-admin-ai"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/ai`

**Read AI assistant**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/ai' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `kind` | string | `"ollama"` |
| `baseUrl` | string | `""` |
| `defaultUrl` | string | `"http://127.0.0.1:11434"` |
| `chatModel` | string | `""` |
| `embedModel` | string | `""` |
| `toolModel` | string | `""` |
| `mode` | string | `"guided"` |
| `basicUser` | string | `""` |
| `context` | integer | `16384` |
| `hasKey` | boolean | `false` |
| `hasBasicPassword` | boolean | `false` |
| `enabled` | boolean | `false` |
| `ready` | boolean | `false` |
| `leaves` | boolean | `true` |
| `destination` | string | `""` |
| `consent` | null | `null` |
| `index` | object |  |
| `index.documents` | integer | `0` |
| `index.withVectors` | integer | `0` |
| `index.waiting` | integer | `1` |
| `index.lastRound` | null | `null` |
| `index.lastError` | null | `null` |

<details><summary>Example answer</summary>

```json
{
  "kind": "ollama",
  "baseUrl": "",
  "defaultUrl": "http://127.0.0.1:11434",
  "chatModel": "",
  "embedModel": "",
  "toolModel": "",
  "mode": "guided",
  "basicUser": "",
  "context": 16384,
  "hasKey": false,
  "hasBasicPassword": false,
  "enabled": false,
  "ready": false,
  "leaves": true,
  "destination": "",
  "consent": null,
  "index": {
    "documents": 0,
    "withVectors": 0,
    "waiting": 1,
    "lastRound": null,
    "lastError": null
  }
}
```

</details>

### `PUT /api/admin/ai`

**Change AI assistant**

Saved as given. Switching on with an address that leaves this server needs
the administrator's confirmation of exactly that address.

- **Who may:** Administrators
- **JSON body:** `kind`, `baseUrl`, `chatModel`, `embedModel`, `toolModel`, `mode`, `basicUser`, `context`, `apiKey`, `clearApiKey`, `basicPassword`, `confirmLeaves`, `confirmHost`, `enabled`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/ai' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"kind": "…", "baseUrl": "…", "chatModel": "…", "embedModel": "…", "toolModel": "…", "mode": "…", "basicUser": "…", "context": "…"}'
```

**Returns**

The same as `GET /api/admin/ai`.

### `GET /api/admin/ai/cases`

**List test cases**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/ai/cases' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `cases` | array |  |

<details><summary>Example answer</summary>

```json
{
  "cases": []
}
```

</details>

### `POST /api/admin/ai/cases`

**Create test case**

A question and the pages a right answer has to find (PG-12, PG-40).

- **Who may:** Administrators
- **JSON body:** `question`, `expect`, `expected`, `note`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/ai/cases' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"question": "…", "expect": "…", "expected": "…", "note": "…"}'
```

**Returns**

The same as `GET /api/admin/ai/cases`.

### `POST /api/admin/ai/cases/standard`

**Create standard question**

The standard questions - the ones that went wrong once - into the catalogue: the
measure every change to the assistant is held against. A question already there is
left as it is.

- **Who may:** Administrators

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/ai/cases/standard' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`added`

### `GET /api/admin/ai/glossary`

**List glossary**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/ai/glossary' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `terms` | array |  |
| `terms[].id` | integer | `1` |
| `terms[].term` | string | `"Raum"` |
| `terms[].meaning` | string | `"a space of the wiki"` |

<details><summary>Example answer</summary>

```json
{
  "terms": [
    {
      "id": 1,
      "term": "Raum",
      "meaning": "a space of the wiki"
    },
    {
      "id": 2,
      "term": "zuletzt geändert",
      "meaning": "the pages with the newest change - list_pages, order newest"
    }
  ]
}
```

</details>

### `POST /api/admin/ai/glossary`

**Create glossary term**

A word of this team and what it means here.

- **Who may:** Administrators
- **JSON body:** `term`, `meaning`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/ai/glossary' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"term": "…", "meaning": "…"}'
```

**Returns**

`ok`

### `DELETE /api/admin/ai/glossary/{gid}`

**Delete glossary term**

- **Who may:** Administrators
- **Path parameters:** `gid` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/ai/glossary/{gid}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`

### `GET /api/admin/ai/log`

**List log**

The last questions, for the administrator: way, steps, query, outcome, time, thumbs.

- **Who may:** Administrators
- **Query parameters:** `limit` (int, default 50)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/ai/log?limit=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `entries` | array |  |
| `days` | integer | `30` |

<details><summary>Example answer</summary>

```json
{
  "entries": [],
  "days": 30
}
```

</details>

### `POST /api/admin/ai/reindex`

**Rebuild the index – AI assistant**

- **Who may:** Administrators

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/ai/reindex' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

JSON.

### `GET /api/admin/ai/runs`

**List runs**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/ai/runs' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `runs` | array |  |

<details><summary>Example answer</summary>

```json
{
  "runs": []
}
```

</details>

### `POST /api/admin/ai/runs`

**Create run**

The whole catalogue against the model in use - in the background; the page asks
for progress. mode: the way to test, guided or agent, so the two can be compared.

- **Who may:** Administrators
- **JSON body:** `mode`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/ai/runs' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"mode": "…"}'
```

**Returns**

`id`

### `POST /api/admin/ai/test`

**Test – AI assistant**

Reaches the server, lists its models, and has the chosen one say a word.

- **Who may:** Administrators
- **JSON body:** `kind`, `baseUrl`, `chatModel`, `embedModel`, `basicUser`, `apiKey`, `basicPassword`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/ai/test' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"kind": "…", "baseUrl": "…", "chatModel": "…", "embedModel": "…", "basicUser": "…", "apiKey": "…", "basicPassword": "…"}'
```

**Returns**

JSON.


## Area: `admin/announcement`

<a id="area-admin-announcement"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/announcement`

**Read announcement**

Readable by anybody signed in - everybody is meant to see it.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/announcement' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `message` | string | `""` |
| `active` | boolean | `false` |
| `updatedBy` | null | `null` |
| `updated` | string | `"2026-11-22 07:46:52"` |

<details><summary>Example answer</summary>

```json
{
  "message": "",
  "active": false,
  "updatedBy": null,
  "updated": "2026-11-22 07:46:52"
}
```

</details>

### `PUT /api/admin/announcement`

**Change announcement**

- **Who may:** Administrators
- **JSON body:** `message`, `active`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/announcement' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"message": "…", "active": "…"}'
```

**Returns**

`error`


## Area: `admin/applinks`

<a id="area-admin-applinks"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/applinks`

**Read applinks**

The application links of this installation. Administrators.

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/applinks' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `links` | array |  |
| `product` | string | `"mgwiki"` |

<details><summary>Example answer</summary>

```json
{
  "links": [],
  "product": "mgwiki"
}
```

</details>

### `POST /api/admin/applinks`

**Send applinks**

Set up a link: the other application's address, an administrator's login there (password or API
token - used once, not kept) and this installation's address as the other one reaches it.

- **Who may:** Administrators
- **JSON body:** `base_url`, `username`, `secret`, `own_url`, `own_name`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/applinks' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"base_url": "…", "username": "…", "secret": "…", "own_url": "…", "own_name": "…"}'
```

**Returns**

`link`

### `POST /api/admin/applinks/browser`

**Send browser**

Set up a link in the browser - no password, no token (5.8.1): the address to open, where you approve the
link signed in over there as you are (any identity provider it has, or a password); that application
checks you are one of its
administrators. Back here, /admin/applinks/complete keeps it.

- **Who may:** Administrators
- **JSON body:** `base_url`, `own_url`, `own_name`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/applinks/browser' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"base_url": "…", "own_url": "…", "own_name": "…"}'
```

**Returns**

JSON.

### `POST /api/admin/applinks/complete`

**Complete – applinks**

The browser is back from approving the link over there, with that side's key: kept here too - only for
the administrator who started it.

- **Who may:** Administrators

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/applinks/complete' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`link`

### `DELETE /api/admin/applinks/{link_id}`

**Delete applinks**

Remove a link - here and in the other application.

- **Who may:** Administrators
- **Path parameters:** `link_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/applinks/{link_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`, `other_side`

### `POST /api/admin/applinks/{link_id}/test`

**Test – applinks**

Ask the other application as whom it sees you over the link.

- **Who may:** Administrators
- **Path parameters:** `link_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/applinks/{link_id}/test' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`


## Area: `admin/audit-log`

<a id="area-admin-audit-log"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/audit-log`

**List audit log**

What was done, newest first - filtered, and exportable as CSV.

An auditor asks "who changed this" and has to be able to look it up and
take it away as a file.

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/audit-log' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `entries` | array |  |
| `entries[].id` | integer | `3` |
| `entries[].user_id` | null | `null` |
| `entries[].action` | string | `"POST /api/auth/logout"` |
| `entries[].target_type` | string | `"request"` |
| `entries[].target_id` | null | `null` |
| `entries[].detail` | string | `"{}"` |
| `entries[].ip` | string | `"127.0.0.1"` |
| `entries[].created_at` | string | `"2026-11-22 07:46:50"` |
| `entries[].username` | null | `null` |
| `entries[].display_name` | null | `null` |
| `entries[].user` | string | `"System"` |
| `total` | integer | `3` |

<details><summary>Example answer</summary>

```json
{
  "entries": [
    {
      "id": 3,
      "user_id": null,
      "action": "POST /api/auth/logout",
      "target_type": "request",
      "target_id": null,
      "detail": "{}",
      "ip": "127.0.0.1",
      "created_at": "2026-11-22 07:46:50",
      "username": null,
      "display_name": null,
      "user": "System"
    },
    {
      "id": 2,
      "user_id": null,
      "action": "sign-in failed",
      "target_type": "request",
      "target_id": "",
      "detail": null,
      "ip": "127.0.0.1",
      "created_at": "2026-11-22 07:46:50",
      "username": null,
      "display_name": null,
      "user": "System"
    },
    "…"
  ],
  "total": 3
}
```

</details>


## Area: `admin/audit-log.csv`

<a id="area-admin-audit-log-csv"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/audit-log.csv`

**Export audit log as CSV**

The same rows the page shows, with the same filter, as a file.

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/audit-log.csv' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

A file (text/csv).


## Area: `admin/branding`

<a id="area-admin-branding"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/branding`

**Read logo and colours**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/branding' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `light` | object |  |
| `light.set` | boolean | `false` |
| `light.filename` | string | `""` |
| `light.size_bytes` | integer | `0` |
| `dark` | object |  |
| `dark.set` | boolean | `false` |
| `dark.filename` | string | `""` |
| `dark.size_bytes` | integer | `0` |
| `icon` | object |  |
| `icon.set` | boolean | `false` |
| `icon.filename` | string | `""` |
| `icon.size_bytes` | integer | `0` |
| `icon_max_kb` | integer | `256` |
| `max_kb` | integer | `512` |
| `accepts` | array |  |
| `accent` | string | `"#50226B"` |
| `accent_mode` | string | `"auto"` |
| `shades` | object |  |
| `shades.accent` | string | `"#50226B"` |
| `shades.deep` | string | `"#331644"` |
| `shades.soft` | string | `"#F1E9F7"` |
| `shades.hover` | string | `"#6A2D8E"` |
| `shades.dark_accent` | string | `"#B284CD"` |
| `shades.dark_deep` | string | `"#CCB2DC"` |
| `shades.dark_soft` | string | `"#2D1839"` |

<details><summary>Example answer</summary>

```json
{
  "light": {
    "set": false,
    "filename": "",
    "size_bytes": 0
  },
  "dark": {
    "set": false,
    "filename": "",
    "size_bytes": 0
  },
  "icon": {
    "set": false,
    "filename": "",
    "size_bytes": 0
  },
  "icon_max_kb": 256,
  "max_kb": 512,
  "accepts": [
    "image/jpeg",
    "image/png",
    "…"
  ],
  "accent": "#50226B",
  "accent_mode": "auto",
  "shades": {
    "accent": "#50226B",
    "deep": "#331644",
    "soft": "#F1E9F7",
    "hover": "#6A2D8E",
    "dark_accent": "#B284CD",
    "dark_deep": "#CCB2DC",
    "dark_soft": "#2D1839"
  }
}
```

</details>

### `PUT /api/admin/branding/accent`

**Change accent colour**

The one colour everything else is mixed from.

"auto" means it was read out of the logo and should be read again when the
logo changes; "manual" means somebody chose it and nothing may overrule
that - not even a new logo.

- **Who may:** Administrators
- **JSON body:** `color`, `mode`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/branding/accent' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"color": "…", "mode": "…"}'
```

**Returns**

`error`

### `POST /api/admin/branding/logo`

**Send logo**

Store a logo for the top left corner.

Two slots, because the wordmark that reads on a white page rarely reads on
a dark one. Only the light slot is needed: without a dark one the same file
is used for both, which is right for a mark that works either way.

- **Who may:** Administrators
- **Query parameters:** `variant` (string)
- **JSON body:** `(multipart form: file)`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/branding/logo?variant=…' \
  -H 'Authorization: Bearer $TOKEN' \
  -F 'file=@/path/to/file'
```

**Returns**

`error`, `ok`, `variant`, `size_bytes`

### `DELETE /api/admin/branding/logo`

**Delete logo**

Back to the delivered mark for one slot, or for both.

- **Who may:** Administrators
- **Query parameters:** `variant` (string)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/branding/logo?variant=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`


## Area: `admin/changelog`

<a id="area-admin-changelog"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/changelog`

**Read changelog**

The changelog that shipped with this build, straight from the file.

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/changelog' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `releases` | array |  |
| `releases[].version` | string | `"5.9.0"` |
| `releases[].notes` | array |  |
| `version` | string | `"5.9.0"` |

<details><summary>Example answer</summary>

```json
{
  "releases": [
    {
      "version": "5.9.0",
      "notes": [
        "The MGProject and MGService macros show the columns you choose: in the macro'…",
        "MGService macro: the Assignee is shown by default (Key, Summary, Status, Repo…",
        "…"
      ]
    },
    {
      "version": "5.8.4",
      "notes": [
        "The MGService macro with \"Only the open ones\" listed resolved, closed and can…",
        "tests/applinks_e2e_check.py checks it against MGService's own statuses; it fa…"
      ]
    },
    "…"
  ],
  "version": "5.9.0"
}
```

</details>


## Area: `admin/confluence`

<a id="area-admin-confluence"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/confluence`

**Read Confluence import**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/confluence' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `settings` | object |  |
| `settings.url` | string | `""` |
| `settings.email` | string | `""` |
| `settings.hasToken` | boolean | `false` |
| `settings.custom_domain` | boolean | `false` |
| `settings.canonical` | null | `null` |
| `job` | null | `null` |

<details><summary>Example answer</summary>

```json
{
  "settings": {
    "url": "",
    "email": "",
    "hasToken": false,
    "custom_domain": false,
    "canonical": null
  },
  "job": null
}
```

</details>

### `PUT /api/admin/confluence`

**Change Confluence import**

- **Who may:** Administrators
- **JSON body:** `url`, `email`, `token`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/confluence' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"url": "…", "email": "…", "token": "…"}'
```

**Returns**

The same as `GET /api/admin/confluence`.

### `POST /api/admin/confluence/import`

**Import – Confluence import**

- **Who may:** Administrators

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/confluence/import' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `space`, `job`

### `GET /api/admin/confluence/job/{job_id}`

**Read the job – Confluence import**

- **Who may:** Administrators
- **Path parameters:** `job_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/confluence/job/{job_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `POST /api/admin/confluence/probe`

**Probe – Confluence import**

Check what actually happens when an attachment is fetched.

- **Who may:** Administrators

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/confluence/probe' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `report`, `custom_domain`, `canonical`, `configured`

### `GET /api/admin/confluence/spaces`

**List spaces**

What is over there, and what already came across: spaces of every type (knowledge base,
collaboration...) with their kind; ?archived=1 lists the archived ones too.

- **Who may:** Administrators
- **Query parameters:** `archived` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/confluence/spaces?archived=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `spaces`

### `POST /api/admin/confluence/test`

**Test – Confluence import**

- **Who may:** Administrators
- **JSON body:** `token`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/confluence/test' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"token": "…"}'
```

**Returns**

`ok`, `error`, `user`, `custom_domain`, `canonical`


## Area: `admin/database`

<a id="area-admin-database"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/database`

**Read database**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/database' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `backend` | string | `"postgres"` |
| `postgres` | object |  |
| `postgres.host` | string | `"127.0.0.1"` |
| `postgres.port` | integer | `5432` |
| `postgres.user` | string | `"mg"` |
| `postgres.password` | string | `"********"` |
| `postgres.dbname` | string | `"mgwiki_apidocs_3368477_1795333609"` |
| `has_password` | boolean | `true` |
| `config_path` | string | `"/tmp/apidocs-4jol8o_p/database.json"` |
| `driver_installed` | boolean | `true` |
| `counts` | array |  |
| `counts[].label` | string | `"spaces"` |
| `counts[].count` | integer | `1` |

<details><summary>Example answer</summary>

```json
{
  "backend": "postgres",
  "postgres": {
    "host": "127.0.0.1",
    "port": 5432,
    "user": "mg",
    "password": "********",
    "dbname": "mgwiki_apidocs_3368477_1795333609"
  },
  "has_password": true,
  "config_path": "/tmp/apidocs-4jol8o_p/database.json",
  "driver_installed": true,
  "counts": [
    {
      "label": "spaces",
      "count": 1
    },
    {
      "label": "pages",
      "count": 1
    },
    "…"
  ]
}
```

</details>

### `POST /api/admin/database/test`

**Test – database**

- **Who may:** Administrators
- **JSON body:** `password`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/database/test' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"password": "…"}'
```

**Returns**

`ok`, `error`


## Area: `admin/db`

<a id="area-admin-db"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `POST /api/admin/db/query`

**Send query**

Run one statement. SELECT shows rows; anything else says how many it hit.

One statement at a time: a semicolon in the middle is refused, because a
second statement after a checked first one is exactly how this kind of
page gets abused.

- **Who may:** Administrators
- **JSON body:** `sql`, `preview`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/db/query' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"sql": "…", "preview": "…"}'
```

**Returns**

`error`, `kind`, `columns`, `rows`, `total`, `shown`, `table`, `message`

### `GET /api/admin/db/table/{name}`

**Read table**

One page of a table, with a filter per column.

- **Who may:** Administrators
- **Path parameters:** `name` (string)
- **Query parameters:** `f_` (string), `page` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/db/table/{name}?f_=…&page=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `table` | string | `"users"` |
| `columns` | array |  |
| `columns[].name` | string | `"id"` |
| `columns[].type` | string | `"integer"` |
| `key` | string | `"id"` |
| `sealed` | array |  |
| `total` | integer | `1` |
| `page` | integer | `0` |
| `pages` | integer | `1` |
| `rows` | array |  |
| `rows[].id` | integer | `1` |
| `rows[].username` | string | `"admin"` |
| `rows[].email` | string | `""` |
| `rows[].display_name` | string | `"Administrator"` |
| `rows[].password_hash` | string | `"<hidden>"` |
| `rows[].ms_oid` | null | `null` |
| `rows[].avatar_color` | string | `"#1F9D6B"` |
| `rows[].job_title` | null | `null` |
| `rows[].is_active` | integer | `1` |
| `rows[].is_admin` | integer | `1` |
| `rows[].source` | string | `"local"` |
| `rows[].last_login` | string | `"2026-11-22 07:46:50"` |
| `rows[].created_at` | string | `"2026-11-22 07:46:50"` |
| `rows[].must_change_password` | string | `"<hidden>"` |
| `rows[].password_changed` | string | `"<hidden>"` |
| `rows[].failed_logins` | integer | `0` |
| `rows[].locked_until` | null | `null` |
| `rows[].white_pages` | string | `""` |

<details><summary>Example answer</summary>

```json
{
  "table": "users",
  "columns": [
    {
      "name": "id",
      "type": "integer"
    },
    {
      "name": "username",
      "type": "character varying"
    },
    "…"
  ],
  "key": "id",
  "sealed": [
    "client_secret",
    "credential_id",
    "…"
  ],
  "total": 1,
  "page": 0,
  "pages": 1,
  "rows": [
    {
      "id": 1,
      "username": "admin",
      "email": "",
      "display_name": "Administrator",
      "password_hash": "<hidden>",
      "ms_oid": null,
      "avatar_color": "#1F9D6B",
      "job_title": null,
      "is_active": 1,
      "is_admin": 1,
      "source": "local",
      "last_login": "2026-11-22 07:46:50",
      "created_at": "2026-11-22 07:46:50",
      "must_change_password": "<hidden>",
      "password_changed": "<hidden>",
      "failed_logins": 0,
      "locked_until": null,
      "white_pages": ""
    }
  ]
}
```

</details>

### `PUT /api/admin/db/table/{name}`

**Change table**

Change one value in one row, named by its key. Nothing else.

- **Who may:** Administrators
- **Path parameters:** `name` (string)
- **JSON body:** `column`, `keyColumn`, `keyValue`, `value`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/db/table/{name}' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"column": "…", "keyColumn": "…", "keyValue": "…", "value": "…"}'
```

**Returns**

`error`, `table`, `column`, `was`, `now`

### `GET /api/admin/db/tables`

**List database tables**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/db/tables' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `tables` | array |  |
| `tables[].name` | string | `"ai_cases"` |
| `tables[].rows` | integer | `0` |
| `database` | string | `"127.0.0.1/mgwiki_apidocs_3368477_1795333609"` |

<details><summary>Example answer</summary>

```json
{
  "tables": [
    {
      "name": "ai_cases",
      "rows": 0
    },
    {
      "name": "ai_docs",
      "rows": 0
    },
    "…"
  ],
  "database": "127.0.0.1/mgwiki_apidocs_3368477_1795333609"
}
```

</details>


## Area: `admin/entra`

<a id="area-admin-entra"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/entra`

**List Microsoft Entra settings**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/entra' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `enabled` | boolean | `false` |
| `tenantId` | string | `""` |
| `clientId` | string | `""` |
| `hasSecret` | boolean | `false` |
| `domainAllowList` | string | `""` |
| `autoCreate` | boolean | `true` |
| `entraOnly` | boolean | `false` |
| `defaultGroups` | string | `"wiki-users"` |
| `syncEnabled` | boolean | `false` |
| `syncHours` | integer | `12` |
| `deactivateMissing` | boolean | `false` |
| `lastSync` | null | `null` |
| `lastSyncResult` | string | `""` |
| `redirectUri` | string | `"/auth/microsoft/callback"` |

<details><summary>Example answer</summary>

```json
{
  "enabled": false,
  "tenantId": "",
  "clientId": "",
  "hasSecret": false,
  "domainAllowList": "",
  "autoCreate": true,
  "entraOnly": false,
  "defaultGroups": "wiki-users",
  "syncEnabled": false,
  "syncHours": 12,
  "deactivateMissing": false,
  "lastSync": null,
  "lastSyncResult": "",
  "redirectUri": "/auth/microsoft/callback"
}
```

</details>

### `PUT /api/admin/entra`

**Change Microsoft Entra settings**

- **Who may:** Administrators
- **JSON body:** `tenantId`, `clientId`, `clientSecret`, `domainAllowList`, `defaultGroups`, `autoCreate`, `enabled`, `entraOnly`, `syncEnabled`, `syncHours`, `deactivateMissing`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/entra' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"tenantId": "…", "clientId": "…", "clientSecret": "…", "domainAllowList": "…", "defaultGroups": "…", "autoCreate": "…", "enabled": "…", "entraOnly": "…"}'
```

**Returns**

`error`

### `POST /api/admin/entra/sync`

**Run the sync – Microsoft Entra setting**

- **Who may:** Administrators

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/entra/sync' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `POST /api/admin/entra/test`

**Test – Microsoft Entra setting**

- **Who may:** Administrators

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/entra/test' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`, `error`, `issuer`, `redirectUri`


## Area: `admin/global-permissions`

<a id="area-admin-global-permissions"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/global-permissions`

**List general permissions**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/global-permissions' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `available` | array |  |
| `available[].key` | string | `"CAN_USE"` |
| `available[].label` | string | `"Can use MGWiki"` |
| `subjects` | array |  |
| `subjects[].subject_type` | string | `"group"` |
| `subjects[].subject_id` | integer | `1` |
| `subjects[].name` | string | `"wiki-administrators"` |
| `subjects[].permissions` | array |  |

<details><summary>Example answer</summary>

```json
{
  "available": [
    {
      "key": "CAN_USE",
      "label": "Can use MGWiki"
    },
    {
      "key": "CREATE_SPACE",
      "label": "Create spaces"
    },
    "…"
  ],
  "subjects": [
    {
      "subject_type": "group",
      "subject_id": 1,
      "name": "wiki-administrators",
      "permissions": [
        "CAN_USE",
        "CREATE_SPACE",
        "…"
      ]
    },
    {
      "subject_type": "group",
      "subject_id": 2,
      "name": "wiki-users",
      "permissions": [
        "CAN_USE",
        "CREATE_SPACE",
        "…"
      ]
    }
  ]
}
```

</details>

### `PUT /api/admin/global-permissions`

**Change general permissions**

- **Who may:** Administrators

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/global-permissions' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`


## Area: `admin/groups`

<a id="area-admin-groups"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/groups`

**List groups**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/groups' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `groups` | array |  |
| `groups[].id` | integer | `1` |
| `groups[].name` | string | `"wiki-administrators"` |
| `groups[].description` | string | `"Full access to MGWiki"` |
| `groups[].is_system` | boolean | `true` |
| `groups[].created_at` | string | `"2026-11-22 07:46:50"` |
| `groups[].member_count` | integer | `1` |
| `groups[].members` | array |  |

<details><summary>Example answer</summary>

```json
{
  "groups": [
    {
      "id": 1,
      "name": "wiki-administrators",
      "description": "Full access to MGWiki",
      "is_system": true,
      "created_at": "2026-11-22 07:46:50",
      "member_count": 1,
      "members": [
        {
          "id": 1,
          "username": "admin",
          "display_name": "Administrator",
          "is_active": 1
        }
      ]
    },
    {
      "id": 2,
      "name": "wiki-users",
      "description": "Everyone who may use MGWiki",
      "is_system": true,
      "created_at": "2026-11-22 07:46:50",
      "member_count": 0,
      "members": []
    }
  ]
}
```

</details>

### `POST /api/admin/groups`

**Create group**

- **Who may:** Administrators
- **JSON body:** `name`, `description`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/groups' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name": "…", "description": "…"}'
```

**Returns**

`error`, `group`

### `PUT /api/admin/groups/{group_id}`

**Change group**

Rename a group or change its description.

The other two products have had this since they had groups; here the
screen offered a Delete and nothing else, so a typo in a group name meant
deleting it and starting over - and every permission granted to it went
with it.

- **Who may:** Administrators
- **Path parameters:** `group_id` (integer)
- **JSON body:** `name`, `description`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/groups/{group_id}' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name": "…", "description": "…"}'
```

**Returns**

`error`, `group`

### `DELETE /api/admin/groups/{group_id}`

**Delete group**

- **Who may:** Administrators
- **Path parameters:** `group_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/groups/{group_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`

### `GET /api/admin/groups/{group_id}/members`

**List members (group)**

- **Who may:** Administrators
- **Path parameters:** `group_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/groups/{group_id}/members' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `members` | array |  |
| `members[].id` | integer | `1` |
| `members[].username` | string | `"admin"` |
| `members[].email` | string | `""` |
| `members[].display_name` | string | `"Administrator"` |
| `members[].job_title` | null | `null` |
| `members[].is_active` | boolean | `true` |
| `members[].is_admin` | boolean | `true` |
| `members[].source` | string | `"local"` |
| `members[].last_login` | string | `"2026-11-22 07:46:50"` |
| `members[].must_change_password` | boolean | `false` |
| `members[].created_at` | string | `"2026-11-22 07:46:50"` |
| `members[].avatar_color` | string | `"#1F9D6B"` |
| `members[].groups` | array |  |

<details><summary>Example answer</summary>

```json
{
  "members": [
    {
      "id": 1,
      "username": "admin",
      "email": "",
      "display_name": "Administrator",
      "job_title": null,
      "is_active": true,
      "is_admin": true,
      "source": "local",
      "last_login": "2026-11-22 07:46:50",
      "must_change_password": false,
      "created_at": "2026-11-22 07:46:50",
      "avatar_color": "#1F9D6B",
      "groups": [
        "wiki-administrators"
      ]
    }
  ]
}
```

</details>

### `PUT /api/admin/groups/{group_id}/members`

**Change members (group)**

Replace who is in a group.

Reading the members was possible, setting them was not - so the group
editor could name a group and describe it, and the one thing a group is
for had to be done from each person's own screen instead.

- **Who may:** Administrators
- **Path parameters:** `group_id` (integer)
- **JSON body:** `members`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/groups/{group_id}/members' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"members": "…"}'
```

**Returns**

`error`, `members`


## Area: `admin/identity`

<a id="area-admin-identity"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/identity`

**List identity providers**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/identity' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `settings` | object |  |
| `settings.order` | array |  |
| `settings.onlyThroughIdp` | boolean | `false` |
| `providers` | object |  |
| `providers.entra` | object |  |
| `providers.entra.label` | string | `"Microsoft Entra"` |
| `providers.entra.enabled` | boolean | `false` |
| `providers.entra.people` | integer | `0` |
| `providers.google` | object |  |
| `providers.google.label` | string | `"Google Workspace"` |
| `providers.google.enabled` | boolean | `false` |
| `providers.google.autoCreate` | boolean | `true` |
| `providers.google.domainAllowList` | string | `""` |
| `providers.google.syncEnabled` | boolean | `false` |
| `providers.google.syncHours` | integer | `12` |
| `providers.google.deactivateMissing` | boolean | `false` |
| `providers.google.lastSync` | null | `null` |
| `providers.google.lastSyncResult` | string | `""` |
| `providers.google.defaultGroups` | string | `""` |
| `providers.google.clientId` | string | `""` |
| `providers.google.hostedDomain` | string | `""` |
| `providers.google.adminEmail` | string | `""` |
| `providers.google.hasClientSecret` | boolean | `false` |
| `providers.google.hasServiceAccountJson` | boolean | `false` |
| `providers.google.people` | integer | `0` |
| `providers.google.redirectUri` | string | `"http://localhost/auth/google/callback"` |
| `providers.okta` | object |  |
| `providers.okta.label` | string | `"Okta"` |
| `providers.okta.enabled` | boolean | `false` |
| `providers.okta.autoCreate` | boolean | `true` |
| `providers.okta.domainAllowList` | string | `""` |
| `providers.okta.syncEnabled` | boolean | `false` |
| `providers.okta.syncHours` | integer | `12` |
| `providers.okta.deactivateMissing` | boolean | `false` |
| `providers.okta.lastSync` | null | `null` |
| `providers.okta.lastSyncResult` | string | `""` |
| `providers.okta.defaultGroups` | string | `""` |
| `providers.okta.domain` | string | `""` |
| `providers.okta.clientId` | string | `""` |
| `providers.okta.hasClientSecret` | boolean | `false` |

<details><summary>Example answer</summary>

```json
{
  "settings": {
    "order": [
      "entra",
      "ldap",
      "…"
    ],
    "onlyThroughIdp": false
  },
  "providers": {
    "entra": {
      "label": "Microsoft Entra",
      "enabled": false,
      "people": 0
    },
    "google": {
      "label": "Google Workspace",
      "enabled": false,
      "autoCreate": true,
      "domainAllowList": "",
      "syncEnabled": false,
      "syncHours": 12,
      "deactivateMissing": false,
      "lastSync": null,
      "lastSyncResult": "",
      "defaultGroups": "",
      "clientId": "",
      "hostedDomain": "",
      "adminEmail": "",
      "hasClientSecret": false,
      "hasServiceAccountJson": false,
      "people": 0,
      "redirectUri": "http://localhost/auth/google/callback"
    },
    "okta": {
      "label": "Okta",
      "enabled": false,
      "autoCreate": true,
      "domainAllowList": "",
      "syncEnabled": false,
      "syncHours": 12,
      "deactivateMissing": false,
      "lastSync": null,
      "lastSyncResult": "",
      "defaultGroups": "",
      "domain": "",
      "clientId": "",
      "hasClientSecret": false,
      "hasApiToken": false,
      "people": 0,
      "redirectUri": "http://localhost/auth/okta/callback"
    },
    "ldap": {
      "label": "Active Directory",
      "enabled": false,
      "autoCreate": true,
      "domainAllowList": "",
      "syncEnabled": false,
      "syncHours": 12,
      "deactivateMissing": false,
      "lastSync": null,
      "lastSyncResult": "",
      "defaultGroups": "",
      "server": "",
      "startTls": false,
      "verifyCertificate": true,
      "baseDn": "",
      "bindDn": "",
      "loginAttribute": "sAMAccountName",
      "userFilter": "(&(objectCategory=person)(objectClass=user))",
      "groupDn": "",
      "hasBindPassword": false,
      "peo
…
```

</details>

### `PUT /api/admin/identity`

**Change identity providers**

- **Who may:** Administrators
- **JSON body:** `order`, `onlyThroughIdp`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/identity' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"order": "…", "onlyThroughIdp": "…"}'
```

**Returns**

`error`

### `PUT /api/admin/identity/{provider}`

**Change identity provider**

- **Who may:** Administrators
- **Path parameters:** `provider` (string)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/identity/{provider}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `POST /api/admin/identity/{provider}/sync`

**Run the sync – identity provider**

- **Who may:** Administrators
- **Path parameters:** `provider` (string)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/identity/{provider}/sync' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `POST /api/admin/identity/{provider}/test`

**Test – identity provider**

- **Who may:** Administrators
- **Path parameters:** `provider` (string)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/identity/{provider}/test' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`, `lines`


## Area: `admin/instance`

<a id="area-admin-instance"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/instance`

**List instance settings**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/instance' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `base_url` | string | `""` |
| `title` | string | `""` |
| `primary_color` | string | `"#50226B"` |
| `redirect_uri` | string | `"/auth/microsoft/callback"` |
| `env_base_url` | string | `""` |
| `bind` | string | `"127.0.0.1:8719"` |

<details><summary>Example answer</summary>

```json
{
  "base_url": "",
  "title": "",
  "primary_color": "#50226B",
  "redirect_uri": "/auth/microsoft/callback",
  "env_base_url": "",
  "bind": "127.0.0.1:8719"
}
```

</details>

### `PUT /api/admin/instance`

**Change instance settings**

The base URL only builds links, so a change takes effect at once - no
restart, no redeploy.

- **Who may:** Administrators
- **JSON body:** `base_url`, `title`, `primary_color`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/instance' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"base_url": "…", "title": "…", "primary_color": "…"}'
```

**Returns**

`error`, `base_url`, `title`, `primary_color`, `redirect_uri`, `entra_changed`


## Area: `admin/labels`

<a id="area-admin-labels"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/labels`

**List labels**

Every label in use, with where it is used.

A label nobody has put on anything is worth seeing too: that is usually a
typo left over from a page that has since been edited.

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/labels' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `labels` | array |  |

<details><summary>Example answer</summary>

```json
{
  "labels": []
}
```

</details>

### `PUT /api/admin/labels/{label_id}`

**Change label**

Rename a label everywhere at once.

Renaming onto a label that already exists merges the two rather than
failing: that is what somebody means by it, and two labels differing only
in case are the usual reason for doing it.

- **Who may:** Administrators
- **Path parameters:** `label_id` (integer)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/labels/{label_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`, `merged`

### `DELETE /api/admin/labels/{label_id}`

**Delete label**

Remove a label from every page. The pages themselves are untouched.

- **Who may:** Administrators
- **Path parameters:** `label_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/labels/{label_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`


## Area: `admin/license`

<a id="area-admin-license"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/license`

**Read licence**

Where this installation stands. Any signed-in person may ask.

Not admin-only on purpose: the banner that says the wiki is read-only is
shown to everybody, and it would be odd to make people guess why their
Save button stopped working.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/license' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `valid` | boolean | `true` |
| `state` | string | `"ok"` |
| `message` | string | `""` |

<details><summary>Example answer</summary>

```json
{
  "valid": true,
  "state": "ok",
  "message": ""
}
```

</details>

### `PUT /api/admin/license`

**Change licence**

- **Who may:** Administrators

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/license' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `DELETE /api/admin/license`

**Delete licence**

- **Who may:** Administrators

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/license' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

The same as `GET /api/admin/license`.


## Area: `admin/links`

<a id="area-admin-links"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/links`

**List links**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/links' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `links` | array |  |

<details><summary>Example answer</summary>

```json
{
  "links": []
}
```

</details>

### `POST /api/admin/links`

**Create link**

- **Who may:** Administrators
- **JSON body:** `label`, `url`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/links' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"label": "…", "url": "…"}'
```

**Returns**

`error`, `id`

### `PUT /api/admin/links/{link_id}`

**Change link**

- **Who may:** Administrators
- **Path parameters:** `link_id` (integer)
- **JSON body:** `label`, `url`, `position`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/links/{link_id}' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"label": "…", "url": "…", "position": "…"}'
```

**Returns**

`error`, `ok`

### `DELETE /api/admin/links/{link_id}`

**Delete link**

- **Who may:** Administrators
- **Path parameters:** `link_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/links/{link_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`


## Area: `admin/mail`

<a id="area-admin-mail"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/mail`

**List mail settings**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/mail' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `enabled` | boolean | `false` |
| `tenantId` | string | `""` |
| `clientId` | string | `""` |
| `sender` | string | `""` |
| `fromName` | string | `"MGWiki"` |
| `hasSecret` | boolean | `false` |
| `replyTo` | string | `""` |
| `footer` | string | `""` |
| `transport` | string | `"graph"` |
| `smtpHost` | string | `""` |
| `smtpPort` | string | `""` |
| `smtpSecurity` | string | `"starttls"` |
| `smtpUser` | string | `""` |
| `hasSmtpPassword` | boolean | `false` |

<details><summary>Example answer</summary>

```json
{
  "enabled": false,
  "tenantId": "",
  "clientId": "",
  "sender": "",
  "fromName": "MGWiki",
  "hasSecret": false,
  "replyTo": "",
  "footer": "",
  "transport": "graph",
  "smtpHost": "",
  "smtpPort": "",
  "smtpSecurity": "starttls",
  "smtpUser": "",
  "hasSmtpPassword": false
}
```

</details>

### `PUT /api/admin/mail`

**Change mail settings**

- **Who may:** Administrators
- **JSON body:** `enabled`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/mail' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"enabled": "…"}'
```

**Returns**

The same as `GET /api/admin/mail`.

### `POST /api/admin/mail/test`

**Test – mail setting**

Send one message to the person asking, so the setup can be checked.

- **Who may:** Administrators
- **JSON body:** `to`, `enabled`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/mail/test' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"to": "…", "enabled": "…"}'
```

**Returns**

`error`, `sent`, `enabled`


## Area: `admin/mail-queue`

<a id="area-admin-mail-queue"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/mail-queue`

**List mail queue**

- **Who may:** Administrators
- **Query parameters:** `status` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/mail-queue?status=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `queue` | array |  |
| `enabled` | boolean | `false` |
| `sender` | string | `""` |

<details><summary>Example answer</summary>

```json
{
  "queue": [],
  "enabled": false,
  "sender": ""
}
```

</details>


## Area: `admin/notification-schemes`

<a id="area-admin-notification-schemes"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/notification-schemes`

**List notification schemes**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/notification-schemes' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `schemes` | array |  |
| `schemes[].id` | integer | `1` |
| `schemes[].name` | string | `"Default notification scheme"` |
| `schemes[].description` | string | `"Used by every space that does not point at its own"` |
| `schemes[].is_default` | boolean | `true` |
| `schemes[].rules` | array |  |
| `events` | array |  |
| `events[].key` | string | `"page_created"` |
| `events[].label` | string | `"Page created"` |

<details><summary>Example answer</summary>

```json
{
  "schemes": [
    {
      "id": 1,
      "name": "Default notification scheme",
      "description": "Used by every space that does not point at its own",
      "is_default": true,
      "rules": [
        {
          "id": 6,
          "scheme_id": 1,
          "event": "attachment_added",
          "subject_type": "watchers",
          "subject_id": null
        },
        {
          "id": 4,
          "scheme_id": 1,
          "event": "comment_added",
          "subject_type": "watchers",
          "subject_id": null
        },
        "…"
      ]
    }
  ],
  "events": [
    {
      "key": "page_created",
      "label": "Page created"
    },
    {
      "key": "page_updated",
      "label": "Page updated"
    },
    "…"
  ]
}
```

</details>

### `PUT /api/admin/notification-schemes/{scheme_id}`

**Change notification scheme**

- **Who may:** Administrators
- **Path parameters:** `scheme_id` (integer)
- **JSON body:** `name`, `description`, `rules`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/notification-schemes/{scheme_id}' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name": "…", "description": "…", "rules": "…"}'
```

**Returns**

`error`, `ok`


## Area: `admin/public-site`

<a id="area-admin-public-site"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/public-site`

**Read public site**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/public-site' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `enabled` | boolean | `false` |
| `host` | string | `""` |
| `port` | string | `""` |
| `space_key` | string | `""` |
| `title` | string | `""` |
| `tagline` | string | `"Help and documentation"` |
| `footer` | string | `""` |
| `show_search` | boolean | `true` |
| `url` | string | `""` |
| `listen` | string | `""` |
| `listening` | null | `null` |
| `spaces` | array |  |
| `spaces[].space_key` | string | `"MG"` |
| `spaces[].name` | string | `"MGWiki demo"` |
| `bind` | string | `"127.0.0.1:8719"` |
| `counts` | object |  |
| `counts.live` | integer | `0` |
| `counts.new` | integer | `0` |
| `counts.changed` | integer | `0` |
| `counts.restricted` | integer | `0` |
| `counts.orphans` | integer | `0` |

<details><summary>Example answer</summary>

```json
{
  "enabled": false,
  "host": "",
  "port": "",
  "space_key": "",
  "title": "",
  "tagline": "Help and documentation",
  "footer": "",
  "show_search": true,
  "url": "",
  "listen": "",
  "listening": null,
  "spaces": [
    {
      "space_key": "MG",
      "name": "MGWiki demo"
    }
  ],
  "bind": "127.0.0.1:8719",
  "counts": {
    "live": 0,
    "new": 0,
    "changed": 0,
    "restricted": 0,
    "orphans": 0
  }
}
```

</details>

### `PUT /api/admin/public-site`

**Change public site**

- **Who may:** Administrators
- **JSON body:** `host`, `port`, `enabled`, `space_key`, `title`, `tagline`, `footer`, `show_search`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/public-site' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"host": "…", "port": "…", "enabled": "…", "space_key": "…", "title": "…", "tagline": "…", "footer": "…", "show_search": "…"}'
```

**Returns**

`error`

### `GET /api/admin/public-site/pages`

**List pages**

What is live, what has moved on, and what has never been out.

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/public-site/pages' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `pages` | array |  |
| `orphans` | array |  |
| `counts` | object |  |

<details><summary>Example answer</summary>

```json
{
  "pages": [],
  "orphans": [],
  "counts": {}
}
```

</details>

### `POST /api/admin/public-site/publish`

**Publish – public site**

Move the chosen pages out. Everything not chosen stays as it was.

- **Who may:** Administrators
- **JSON body:** `page_ids`, `withdraw`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/public-site/publish' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"page_ids": "…", "withdraw": "…"}'
```

**Returns**

`error`, `published`, `withdrawn`, `counts`


## Area: `admin/sections`

<a id="area-admin-sections"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/sections`

**List sections**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/sections' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `sections` | array |  |
| `sections[].group` | string | `"Identity settings"` |
| `sections[].note` | string | `"Who may sign in, how they are reached, and what they may do` |
| `sections[].items` | array |  |

<details><summary>Example answer</summary>

```json
{
  "sections": [
    {
      "group": "Identity settings",
      "note": "Who may sign in, how they are reached, and what they may do above the spaces.",
      "items": [
        {
          "key": "people",
          "label": "People",
          "icon": "people",
          "text": "Accounts, sign-in methods, roles and activation."
        },
        {
          "key": "groups",
          "label": "Groups",
          "icon": "people",
          "text": "Bundle people so space permissions can be granted to a team rather than one a…"
        },
        "…"
      ]
    },
    {
      "group": "Space settings",
      "note": "How content is organised, who may reach it, and who hears about it.",
      "items": [
        {
          "key": "spaces",
          "label": "Spaces",
          "icon": "layers",
          "text": "Every space in this installation, active and archived."
        },
        {
          "key": "space-permissions",
          "label": "Space permissions",
          "icon": "shield",
          "text": "Who may do what inside a space, edited per space."
        },
        "…"
      ]
    },
    "…"
  ]
}
```

</details>


## Area: `admin/space-permission-catalog`

<a id="area-admin-space-permission-catalog"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/space-permission-catalog`

**List space permissions**

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/space-permission-catalog' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `permissions` | array |  |
| `permissions[].key` | string | `"SPACE_VIEW"` |
| `permissions[].label` | string | `"View the space"` |

<details><summary>Example answer</summary>

```json
{
  "permissions": [
    {
      "key": "SPACE_VIEW",
      "label": "View the space"
    },
    {
      "key": "PAGE_ADD",
      "label": "Add pages"
    },
    "…"
  ]
}
```

</details>


## Area: `admin/spaces`

<a id="area-admin-spaces"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/spaces`

**List spaces**

Every space, for System settings > Spaces and Space permissions: its name, key, kind, state and who may
enter it is an administrator's business - what is in it is not (5.5.0). Whether this administrator may
open it themselves is said; somebody else's personal space shows only its owner.

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/spaces' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `spaces` | array |  |
| `spaces[].id` | integer | `1` |
| `spaces[].key` | string | `"MG"` |
| `spaces[].name` | string | `"MGWiki demo"` |
| `spaces[].type` | string | `"global"` |
| `spaces[].status` | string | `"current"` |
| `spaces[].personal` | boolean | `false` |
| `spaces[].owner_name` | null | `null` |
| `spaces[].can_open` | boolean | `true` |
| `spaces[].can_archive` | boolean | `true` |
| `spaces[].can_restore` | boolean | `false` |
| `spaces[].manageable` | boolean | `true` |

<details><summary>Example answer</summary>

```json
{
  "spaces": [
    {
      "id": 1,
      "key": "MG",
      "name": "MGWiki demo",
      "type": "global",
      "status": "current",
      "personal": false,
      "owner_name": null,
      "can_open": true,
      "can_archive": true,
      "can_restore": false,
      "manageable": true
    }
  ]
}
```

</details>


## Area: `admin/subjects`

<a id="area-admin-subjects"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/subjects`

**List subjects**

People and groups, for the permission dialogs.

- **Who may:** Anybody signed in
- **Query parameters:** `q` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/subjects?q=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `users` | array |  |
| `users[].id` | integer | `1` |
| `users[].username` | string | `"admin"` |
| `users[].display_name` | string | `"Administrator"` |
| `users[].avatar_color` | string | `"#1F9D6B"` |
| `groups` | array |  |
| `groups[].id` | integer | `1` |
| `groups[].name` | string | `"wiki-administrators"` |

<details><summary>Example answer</summary>

```json
{
  "users": [
    {
      "id": 1,
      "username": "admin",
      "display_name": "Administrator",
      "avatar_color": "#1F9D6B"
    }
  ],
  "groups": [
    {
      "id": 1,
      "name": "wiki-administrators"
    },
    {
      "id": 2,
      "name": "wiki-users"
    }
  ]
}
```

</details>


## Area: `admin/system-info`

<a id="area-admin-system-info"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/system-info`

**Read system information**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/system-info' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `version` | string | `"5.9.0"` |
| `python` | string | `"3.12.3"` |
| `platform` | string | `"Linux-6.8.0-139-generic-x86_64-with-glibc2.39"` |
| `database` | string | `"postgres"` |
| `env_bind` | string | `"127.0.0.1:8719"` |
| `base_url` | string | `""` |
| `title` | string | `"MGWiki"` |
| `counts` | object |  |
| `counts.users` | integer | `1` |
| `counts.groups` | integer | `2` |
| `counts.spaces` | integer | `1` |
| `counts.pages` | integer | `1` |
| `counts.page_versions` | integer | `1` |
| `counts.comments` | integer | `0` |
| `counts.attachments` | integer | `0` |
| `counts.mail_queue` | integer | `0` |
| `migrations` | array |  |
| `migrations[].number` | integer | `1` |
| `migrations[].name` | string | `"core"` |
| `migrations[].applied_at` | string | `"2026-11-22 07:46:50"` |
| `mail_enabled` | boolean | `false` |
| `microsoft_enabled` | boolean | `false` |
| `data_dir` | string | `"/tmp/apidocs-4jol8o_p"` |

<details><summary>Example answer</summary>

```json
{
  "version": "5.9.0",
  "python": "3.12.3",
  "platform": "Linux-6.8.0-139-generic-x86_64-with-glibc2.39",
  "database": "postgres",
  "env_bind": "127.0.0.1:8719",
  "base_url": "",
  "title": "MGWiki",
  "counts": {
    "users": 1,
    "groups": 2,
    "spaces": 1,
    "pages": 1,
    "page_versions": 1,
    "comments": 0,
    "attachments": 0,
    "mail_queue": 0
  },
  "migrations": [
    {
      "number": 1,
      "name": "core",
      "applied_at": "2026-11-22 07:46:50"
    },
    {
      "number": 2,
      "name": "password_state",
      "applied_at": "2026-11-22 07:46:50"
    },
    "…"
  ],
  "mail_enabled": false,
  "microsoft_enabled": false,
  "data_dir": "/tmp/apidocs-4jol8o_p"
}
```

</details>


## Area: `admin/templates`

<a id="area-admin-templates"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/templates`

**List templates**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/templates' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `templates` | array |  |
| `spaces` | array |  |
| `spaces[].id` | integer | `1` |
| `spaces[].name` | string | `"MGWiki demo"` |
| `spaces[].space_key` | string | `"MG"` |

<details><summary>Example answer</summary>

```json
{
  "templates": [],
  "spaces": [
    {
      "id": 1,
      "name": "MGWiki demo",
      "space_key": "MG"
    }
  ]
}
```

</details>

### `POST /api/admin/templates`

**Create template**

- **Who may:** Administrators
- **JSON body:** `name`, `space_id`, `description`, `body`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/templates' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name": "…", "space_id": "…", "description": "…", "body": "…"}'
```

**Returns**

`error`, `id`

### `PUT /api/admin/templates/{template_id}`

**Change template**

- **Who may:** Administrators
- **Path parameters:** `template_id` (integer)
- **JSON body:** `name`, `description`, `space_id`, `body`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/templates/{template_id}' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name": "…", "description": "…", "space_id": "…", "body": "…"}'
```

**Returns**

`error`, `ok`

### `DELETE /api/admin/templates/{template_id}`

**Delete template**

- **Who may:** Administrators
- **Path parameters:** `template_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/templates/{template_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`


## Area: `admin/users`

<a id="area-admin-users"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/users`

**List people**

- **Who may:** Administrators
- **Query parameters:** `q` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/users?q=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `users` | array |  |
| `users[].id` | integer | `1` |
| `users[].username` | string | `"admin"` |
| `users[].email` | string | `""` |
| `users[].display_name` | string | `"Administrator"` |
| `users[].job_title` | null | `null` |
| `users[].is_active` | boolean | `true` |
| `users[].is_admin` | boolean | `true` |
| `users[].source` | string | `"local"` |
| `users[].last_login` | string | `"2026-11-22 07:46:50"` |
| `users[].must_change_password` | boolean | `false` |
| `users[].created_at` | string | `"2026-11-22 07:46:50"` |
| `users[].avatar_color` | string | `"#1F9D6B"` |
| `users[].groups` | array |  |

<details><summary>Example answer</summary>

```json
{
  "users": [
    {
      "id": 1,
      "username": "admin",
      "email": "",
      "display_name": "Administrator",
      "job_title": null,
      "is_active": true,
      "is_admin": true,
      "source": "local",
      "last_login": "2026-11-22 07:46:50",
      "must_change_password": false,
      "created_at": "2026-11-22 07:46:50",
      "avatar_color": "#1F9D6B",
      "groups": [
        "wiki-administrators"
      ]
    }
  ]
}
```

</details>

### `POST /api/admin/users`

**Create person**

- **Who may:** Administrators
- **JSON body:** `username`, `password`, `email`, `display_name`, `job_title`, `is_admin`, `groups`, `generated_password`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/users' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"username": "…", "password": "…", "email": "…", "display_name": "…", "job_title": "…", "is_admin": "…", "groups": "…", "generated_password": "…"}'
```

**Returns**

`error`

### `PUT /api/admin/users/{user_id}`

**Change person**

- **Who may:** Administrators
- **Path parameters:** `user_id` (integer)
- **JSON body:** `password`, `is_active`, `is_admin`, `groups`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/users/{user_id}' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"password": "…", "is_active": "…", "is_admin": "…", "groups": "…"}'
```

**Returns**

`error`, `user`


## Area: `admin/webhooks`

<a id="area-admin-webhooks"></a>

System settings, for administrators: licence, mail, database, logo, announcements, the AI, identity providers, users, groups and more.

### `GET /api/admin/webhooks`

**List webhooks**

- **Who may:** Administrators

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/admin/webhooks' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `webhooks` | array |  |
| `events` | object |  |
| `events.page_created` | string | `"Page created"` |
| `events.page_updated` | string | `"Page updated"` |
| `events.page_deleted` | string | `"Page deleted"` |
| `events.comment_added` | string | `"Comment added"` |
| `events.attachment_added` | string | `"Attachment added"` |
| `events.mention` | string | `"Someone mentioned"` |
| `events.space_created` | string | `"Space created"` |
| `formats` | object |  |
| `formats.teams` | string | `"Teams message card"` |
| `formats.json` | string | `"Plain JSON"` |
| `spaces` | array |  |
| `spaces[].id` | integer | `1` |
| `spaces[].name` | string | `"MGWiki demo"` |
| `spaces[].space_key` | string | `"MG"` |

<details><summary>Example answer</summary>

```json
{
  "webhooks": [],
  "events": {
    "page_created": "Page created",
    "page_updated": "Page updated",
    "page_deleted": "Page deleted",
    "comment_added": "Comment added",
    "attachment_added": "Attachment added",
    "mention": "Someone mentioned",
    "space_created": "Space created"
  },
  "formats": {
    "teams": "Teams message card",
    "json": "Plain JSON"
  },
  "spaces": [
    {
      "id": 1,
      "name": "MGWiki demo",
      "space_key": "MG"
    }
  ]
}
```

</details>

### `POST /api/admin/webhooks`

**Create webhook**

- **Who may:** Administrators

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/webhooks' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `id`

### `PUT /api/admin/webhooks/{webhook_id}`

**Change webhook**

- **Who may:** Administrators
- **Path parameters:** `webhook_id` (integer)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/admin/webhooks/{webhook_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`

### `DELETE /api/admin/webhooks/{webhook_id}`

**Delete webhook**

- **Who may:** Administrators
- **Path parameters:** `webhook_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/admin/webhooks/{webhook_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`

### `POST /api/admin/webhooks/{webhook_id}/test`

**Test – webhook**

Post one message to this endpoint, whatever events it is subscribed to.

- **Who may:** Administrators
- **Path parameters:** `webhook_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/admin/webhooks/{webhook_id}/test' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`, `detail`


## Area: `ai`

<a id="area-ai"></a>

The AI assistant: asking a question (answered as a stream of events), searching, drafts the assistant prepared and the person confirms, and feedback on answers.

### `POST /api/ai/ask`

**Ask – AI assistant**

Answers as lines of JSON: first what was found, then the answer piece by piece.

- **Who may:** Anybody signed in
- **JSON body:** `question`, `previous`, `history`, `conversation`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/ai/ask' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"question": "…", "previous": "…", "history": "…", "conversation": "…"}'
```

**Returns**

A stream of JSON lines (application/x-ndjson), one event per line - see “The AI assistant's answers”.

### `GET /api/ai/box`

**Read AI box**

Where the person put the box, and how big they made it - theirs on every browser.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/ai/box' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

```json
{}
```

### `PUT /api/ai/box`

**Change AI box**

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/ai/box' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

The same as `GET /api/ai/box`.

### `POST /api/ai/drafts/{draft_id}/carry-out`

**Carry out – draft**

The button on a draft: the person confirms, and it is carried out as them.

- **Who may:** Anybody signed in
- **Path parameters:** `draft_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/ai/drafts/{draft_id}/carry-out' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`, `message`, `url`, `draft`

### `POST /api/ai/drafts/{draft_id}/discard`

**Discard – draft**

- **Who may:** Anybody signed in
- **Path parameters:** `draft_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/ai/drafts/{draft_id}/discard' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`draft`

### `POST /api/ai/feedback`

**Give feedback – AI assistant**

- **Who may:** Anybody signed in
- **JSON body:** `question`, `refs`, `good`, `logId`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/ai/feedback' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"question": "…", "refs": "…", "good": "…", "logId": "…"}'
```

**Returns**

`ok`

### `GET /api/ai/pages-export.{fmt}`

**Export pages export.<fmt> as a file**

A list of pages as a file - PDF, Excel or CSV - with this person's rights: the spaces
they may see, every page restriction included, as the list in the box.

- **Who may:** Anybody signed in
- **Path parameters:** `fmt` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/ai/pages-export.{fmt}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

JSON.

### `POST /api/ai/query`

**Send query**

The assistant's read-only query, for a caller with the same rights - the probe run and MGHub.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/ai/query' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `GET /api/ai/schema`

**Read schema**

The views the assistant queries, as it is told about them - for this person.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/ai/schema' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `views` | string | `"pages(id: page number (join versions.page_id, comments.page` |

<details><summary>Example answer</summary>

```json
{
  "views": "pages(id: page number (join versions.page_id, comments.page_id …), title: its…"
}
```

</details>

### `POST /api/ai/search`

**Send search**

- **Who may:** Anybody signed in
- **JSON body:** `question`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/ai/search' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"question": "…"}'
```

**Returns**

`items`

### `GET /api/ai/state`

**Read the state – AI assistant**

For the box: whether it is shown to this person at all.

- **Who may:** No sign-in needed

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/ai/state' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `box` | boolean | `false` |
| `signedIn` | boolean | `true` |
| `product` | string | `"mgwiki"` |
| `user` | string | `"Administrator"` |

<details><summary>Example answer</summary>

```json
{
  "box": false,
  "signedIn": true,
  "product": "mgwiki",
  "user": "Administrator"
}
```

</details>


## Area: `applinks`

<a id="area-applinks"></a>

Application links between MGWiki, MGProject and MGService: what an installation is, the key exchange when an administrator links two of them, removing a link, and as whom a linked request is seen.

### `GET /api/applinks/about`

**Read what this is – applinks**

What this installation is - the first question of an application setting up a link. Open to all.

- **Who may:** No sign-in needed

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/applinks/about' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `product` | string | `"mgwiki"` |
| `product_name` | string | `"MGWiki"` |
| `applinks` | integer | `1` |

<details><summary>Example answer</summary>

```json
{
  "product": "mgwiki",
  "product_name": "MGWiki",
  "applinks": 1
}
```

</details>

### `POST /api/applinks/handshake`

**Exchange the keys – applinks**

The other side of setting up a link: an administrator of this installation (by API token or signed in)
accepts the other application's key and hands over this one's.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/applinks/handshake' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `code`

### `POST /api/applinks/unlink`

**Remove the link – applinks**

The linked application removed the link - signed by the link itself.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/applinks/unlink' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`

### `GET /api/applinks/whoami`

**Read as whom – applinks**

As whom a request over an application link is seen here - the test of a link.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/applinks/whoami' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `product` | string | `"mgwiki"` |
| `product_name` | string | `"MGWiki"` |
| `username` | string | `"admin"` |
| `display_name` | string | `"Administrator"` |
| `email` | string | `""` |
| `matched_by` | null | `null` |

<details><summary>Example answer</summary>

```json
{
  "product": "mgwiki",
  "product_name": "MGWiki",
  "username": "admin",
  "display_name": "Administrator",
  "email": "",
  "matched_by": null
}
```

</details>


## Area: `archive`

<a id="area-archive"></a>

The archive: archived spaces and pages - what is in it, sending pages and spaces there and taking them out again.

### `GET /api/archive`

**Archive**

The archive: every space you may read that is archived, or has archived pages you may read, with how
many. Takes "View the archive".

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/archive' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `spaces` | array |  |

<details><summary>Example answer</summary>

```json
{
  "spaces": []
}
```

</details>

### `GET /api/archive/{key}`

**Archive**

One space in the archive: the space (archived or active, with when and by whom), its archived pages
you may read and what you may do with them. Takes "View the archive".

- **Who may:** Permission: `SPACE_VIEW`
- **Path parameters:** `key` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/archive/{key}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `space`, `pages`


## Area: `attachments`

<a id="area-attachments"></a>

Files attached to issues or pages: reading, downloading, the preview of office documents, changing who may see them and removing them.

### `GET /api/attachments/{attachment_id}`

**Read attachment**

- **Who may:** Permission: `view`
- **Path parameters:** `attachment_id` (integer)
- **Query parameters:** `dl` (string), `download` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/attachments/{attachment_id}?dl=…&download=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `DELETE /api/attachments/{attachment_id}`

**Delete attachment**

- **Who may:** Permission: `ATTACHMENT_DELETE`
- **Path parameters:** `attachment_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/attachments/{attachment_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`

### `GET /api/attachments/{attachment_id}/preview`

**Preview – attachment**

An office document as PDF, converted by LibreOffice on the server.

Without LibreOffice, or for a format it cannot read, this answers 415 and
the viewer offers the download instead.

- **Who may:** Permission: `view`
- **Path parameters:** `attachment_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/attachments/{attachment_id}/preview' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `libreoffice`, `mime`, `detail`


## Area: `auth`

<a id="area-auth"></a>

Signing in and out, the own account: password, passkeys, API tokens and personal settings.

### `POST /api/auth/login`

**Sign in – sign-in**

- **Who may:** No sign-in needed
- **JSON body:** `username`, `password`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/auth/login' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"username": "…", "password": "…"}'
```

**Returns**

`error`, `user`

### `POST /api/auth/logout`

**Sign out – sign-in**

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/auth/logout' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`

### `GET /api/auth/me`

**Read own account**

- **Who may:** No sign-in needed

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/auth/me' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `user` | object |  |
| `user.id` | integer | `1` |
| `user.username` | string | `"admin"` |
| `user.email` | string | `""` |
| `user.display_name` | string | `"Administrator"` |
| `user.avatar_color` | string | `"#1F9D6B"` |
| `user.job_title` | null | `null` |
| `user.is_admin` | boolean | `true` |
| `user.source` | string | `"local"` |
| `user.must_change_password` | boolean | `false` |
| `user.white_pages` | string | `""` |
| `user.personal_space` | null | `null` |
| `user.may_create_personal_space` | boolean | `true` |
| `permissions` | array |  |
| `microsoft_enabled` | boolean | `false` |

<details><summary>Example answer</summary>

```json
{
  "user": {
    "id": 1,
    "username": "admin",
    "email": "",
    "display_name": "Administrator",
    "avatar_color": "#1F9D6B",
    "job_title": null,
    "is_admin": true,
    "source": "local",
    "must_change_password": false,
    "white_pages": "",
    "personal_space": null,
    "may_create_personal_space": true
  },
  "permissions": [
    "ARCHIVE",
    "ATTACH_PROFILE",
    "…"
  ],
  "microsoft_enabled": false
}
```

</details>

### `PUT /api/auth/me/appearance`

**Change appearance**

In the dark theme, pages and/or the editor white - everything around them stays dark. Per person.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/auth/me/appearance' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `white_pages`

### `POST /api/auth/password`

**Send password**

Used both for the forced change at first sign-in and voluntarily.

- **Who may:** Anybody signed in
- **JSON body:** `current_password`, `new_password`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/auth/password' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"current_password": "…", "new_password": "…"}'
```

**Returns**

`error`, `ok`


## Area: `comments`

<a id="area-comments"></a>

Comments: changing and deleting them. New comments are added under the issue or page.

### `PUT /api/comments/{comment_id}`

**Change comment**

Correct a comment.

Own words are one's own to correct. Somebody else's take the right to
moderate comments in that space - the same right that allows deleting them,
because being able to rewrite what another person said is at least as
far-reaching as removing it.

The page it belongs to never changes, and neither does the author: an edit
corrects what was said, it does not transfer it.

- **Who may:** Permission: `COMMENT_DELETE`
- **Path parameters:** `comment_id` (integer)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/comments/{comment_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `DELETE /api/comments/{comment_id}`

**Delete comment**

- **Who may:** Permission: `COMMENT_DELETE`
- **Path parameters:** `comment_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/comments/{comment_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`


## Area: `dashboard`

<a id="area-dashboard"></a>

The start page of a person: what is waiting for them.

### `GET /api/dashboard`

**Read dashboard**

- **Who may:** No sign-in needed

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/dashboard' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `recent` | array |  |
| `recent[].id` | integer | `1` |
| `recent[].space_id` | integer | `1` |
| `recent[].parent_id` | null | `null` |
| `recent[].type` | string | `"page"` |
| `recent[].title` | string | `"MGWiki demo"` |
| `recent[].slug` | string | `"mgwiki-demo"` |
| `recent[].version` | integer | `1` |
| `recent[].status` | string | `"current"` |
| `recent[].excerpt` | string | `"Welcome"` |
| `recent[].created_by` | object |  |
| `recent[].created_at` | string | `"2026-11-22 07:46:50"` |
| `recent[].updated_by` | object |  |
| `recent[].updated_at` | string | `"2026-11-22 07:46:50"` |
| `recent[].space` | object |  |
| `my_pages` | array |  |
| `my_pages[].id` | integer | `1` |
| `my_pages[].space_id` | integer | `1` |
| `my_pages[].parent_id` | null | `null` |
| `my_pages[].type` | string | `"page"` |
| `my_pages[].title` | string | `"MGWiki demo"` |
| `my_pages[].slug` | string | `"mgwiki-demo"` |
| `my_pages[].version` | integer | `1` |
| `my_pages[].status` | string | `"current"` |
| `my_pages[].excerpt` | string | `"Welcome"` |
| `my_pages[].created_by` | object |  |
| `my_pages[].created_at` | string | `"2026-11-22 07:46:50"` |
| `my_pages[].updated_by` | object |  |
| `my_pages[].updated_at` | string | `"2026-11-22 07:46:50"` |
| `my_pages[].space` | object |  |
| `favourites` | array |  |
| `viewed` | array |  |
| `viewed[].id` | integer | `1` |
| `viewed[].space_id` | integer | `1` |
| `viewed[].parent_id` | null | `null` |
| `viewed[].type` | string | `"page"` |
| `viewed[].title` | string | `"MGWiki demo"` |
| `viewed[].slug` | string | `"mgwiki-demo"` |
| `viewed[].version` | integer | `1` |
| `viewed[].status` | string | `"current"` |

<details><summary>Example answer</summary>

```json
{
  "recent": [
    {
      "id": 1,
      "space_id": 1,
      "parent_id": null,
      "type": "page",
      "title": "MGWiki demo",
      "slug": "mgwiki-demo",
      "version": 1,
      "status": "current",
      "excerpt": "Welcome",
      "created_by": {
        "id": 1,
        "username": "admin",
        "display_name": "Administrator",
        "avatar_color": "#1F9D6B",
        "active": true
      },
      "created_at": "2026-11-22 07:46:50",
      "updated_by": {
        "id": 1,
        "username": "admin",
        "display_name": "Administrator",
        "avatar_color": "#1F9D6B",
        "active": true
      },
      "updated_at": "2026-11-22 07:46:50",
      "space": {
        "key": "MG",
        "name": "MGWiki demo",
        "color": "#E07B39"
      }
    }
  ],
  "my_pages": [
    {
      "id": 1,
      "space_id": 1,
      "parent_id": null,
      "type": "page",
      "title": "MGWiki demo",
      "slug": "mgwiki-demo",
      "version": 1,
      "status": "current",
      "excerpt": "Welcome",
      "created_by": {
        "id": 1,
        "username": "admin",
        "display_name": "Administrator",
        "avatar_color": "#1F9D6B",
        "active": true
      },
      "created_at": "2026-11-22 07:46:50",
      "updated_by": {
        "id": 1,
        "username": "admin",
        "display_name": "Administrator",
        "avatar_color": "#1F9D6B",
        "active": true
      },
      "updated_at": "2026-11-22 07:46:50",
      "space": {
        "key": "MG",
        "name": "MGWiki demo",
        "color": "#E07B39"
      }
    }
  ],
  "favourites": [],
  "viewed": [
    {
      "id": 1,
      "space_id": 1,
      "parent_id": null,
      "type": "page",
      "title": "MGWiki demo",
      "slug": "mgwiki-demo",
      "version": 1,
      "status"
…
```

</details>


## Area: `health`

<a id="area-health"></a>

For monitoring: whether the service answers, and in detail how it stands.

### `GET /api/health`

**Read health check**

Is the service there at all - the question a load balancer asks.

Deliberately thin: the details live one level down, so that something a
monitoring system wants to see cannot make a deployment or a balancer
believe the service is unwell.

- **Who may:** No sign-in needed

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/health' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `product` | string | `"mgwiki"` |
| `status` | string | `"ok"` |
| `version` | string | `"5.9.0"` |

<details><summary>Example answer</summary>

```json
{
  "product": "mgwiki",
  "status": "ok",
  "version": "5.9.0"
}
```

</details>

### `GET /api/health/details`

**Read details**

For monitoring: answers to an administrator, or to the server itself.

- **Who may:** No sign-in needed

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/health/details' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `status` | string | `"degraded"` |
| `version` | string | `"5.9.0"` |
| `checks` | object |  |
| `checks.database` | object |  |
| `checks.database.ok` | boolean | `true` |
| `checks.database.backend` | string | `"postgres"` |
| `checks.database.latencyMs` | number | `0.2` |
| `checks.migrations` | object |  |
| `checks.migrations.ok` | boolean | `true` |
| `checks.migrations.current` | integer | `35` |
| `checks.migrations.latest` | integer | `35` |
| `checks.backgroundJobs` | object |  |
| `checks.backgroundJobs.ok` | boolean | `false` |
| `checks.backgroundJobs.leaseUntil` | null | `null` |
| `checks.backgroundJobs.holder` | null | `null` |
| `checks.backgroundJobs.note` | string | `"no background process has reported yet"` |
| `checks.disk` | object |  |
| `checks.disk.ok` | boolean | `true` |
| `checks.disk.freeMb` | integer | `85129` |

<details><summary>Example answer</summary>

```json
{
  "status": "degraded",
  "version": "5.9.0",
  "checks": {
    "database": {
      "ok": true,
      "backend": "postgres",
      "latencyMs": 0.2
    },
    "migrations": {
      "ok": true,
      "current": 35,
      "latest": 35
    },
    "backgroundJobs": {
      "ok": false,
      "leaseUntil": null,
      "holder": null,
      "note": "no background process has reported yet"
    },
    "disk": {
      "ok": true,
      "freeMb": 85129
    }
  }
}
```

</details>


## Area: `links`

<a id="area-links"></a>

Links between issues (blocks, relates to …) or the quick links of the navigation.

### `GET /api/links`

**List links**

What the menu shows everybody. The address comes along because the menu
has to link somewhere; only the text is drawn.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/links' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `links` | array |  |

<details><summary>Example answer</summary>

```json
{
  "links": []
}
```

</details>


## Area: `macros`

<a id="area-macros"></a>

Data behind the macros in pages.

### `POST /api/macros/axproject`

**Send MGProject connection**

What one macro on a page should show, fetched now.

Called every time a page is opened, and again when somebody presses the
refresh arrow - the point of the macro is that it is not a copy of how
things looked when the page was written.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/macros/axproject' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `GET /api/macros/fields`

**List fields**

Every field the MGProject and the MGService macro can show, and what each shows by default.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/macros/fields' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `axproject` | object |  |
| `axproject.fields` | array |  |
| `axproject.fields[].key` | string | `"key"` |
| `axproject.fields[].label` | string | `"Key"` |
| `axproject.defaults` | array |  |
| `mgservice` | object |  |
| `mgservice.fields` | array |  |
| `mgservice.fields[].key` | string | `"key"` |
| `mgservice.fields[].label` | string | `"Key"` |
| `mgservice.defaults` | array |  |

<details><summary>Example answer</summary>

```json
{
  "axproject": {
    "fields": [
      {
        "key": "key",
        "label": "Key"
      },
      {
        "key": "summary",
        "label": "Summary"
      },
      "…"
    ],
    "defaults": [
      "key",
      "summary",
      "…"
    ]
  },
  "mgservice": {
    "fields": [
      {
        "key": "key",
        "label": "Key"
      },
      {
        "key": "summary",
        "label": "Summary"
      },
      "…"
    ],
    "defaults": [
      "key",
      "summary",
      "…"
    ]
  }
}
```

</details>

### `POST /api/macros/mgservice`

**Send MGService connection**

What one MGService macro on a page shows, fetched now, as you: the open tickets of a service project
(mode project) or the tickets matching a query (mode mql).

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/macros/mgservice' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`


## Area: `me`

<a id="area-me"></a>

The signed-in person: profile, settings, the pages they watch or wrote.

### `GET /api/me/axproject`

**Read MGProject connection**

Whether there is an application link to MGProject (5.8.0: set up by an administrator, no personal
connection any more).

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/me/axproject' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `configured` | boolean | `false` |
| `base_url` | string | `""` |
| `name` | string | `""` |

<details><summary>Example answer</summary>

```json
{
  "configured": false,
  "base_url": "",
  "name": ""
}
```

</details>

### `GET /api/me/axproject/boards`

**List boards**

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/me/axproject/boards' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`boards`

### `GET /api/me/axproject/boards/{board_id}/sprints`

**List sprints (board)**

- **Who may:** Anybody signed in
- **Path parameters:** `board_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/me/axproject/boards/{board_id}/sprints' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`sprints`

### `GET /api/me/mgservice`

**Read MGService connection**

Whether there is an application link to MGService.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/me/mgservice' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `configured` | boolean | `false` |
| `base_url` | string | `""` |
| `name` | string | `""` |

<details><summary>Example answer</summary>

```json
{
  "configured": false,
  "base_url": "",
  "name": ""
}
```

</details>

### `GET /api/me/mgservice/projects`

**List projects**

The service projects you see in MGService - for the macro dialog.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/me/mgservice/projects' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`projects`

### `GET /api/me/tokens`

**List API tokens**

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/me/tokens' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `tokens` | array |  |

<details><summary>Example answer</summary>

```json
{
  "tokens": []
}
```

</details>

### `POST /api/me/tokens`

**Create API token**

Issue a token. The plain text is in this answer and nowhere else.

- **Who may:** Anybody signed in
- **JSON body:** `days`, `name`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/me/tokens' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"days": "…", "name": "…"}'
```

**Returns**

The same as `GET /api/me/tokens`.

### `DELETE /api/me/tokens/{token_id}`

**Delete API token**

- **Who may:** Anybody signed in
- **Path parameters:** `token_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/me/tokens/{token_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`


## Area: `notifications`

<a id="area-notifications"></a>

Notices in the browser for the signed-in person.

### `GET /api/notifications/pending`

**List pending items**

What the browser has not shown yet, handed over once.

Marked as delivered as it is read: a message shown twice is worse than one
missed, and a second tab would otherwise repeat everything.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/notifications/pending' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `notices` | array |  |

<details><summary>Example answer</summary>

```json
{
  "notices": []
}
```

</details>

### `POST /api/notifications/test`

**Test – notification**

Put one notice in this person's own queue.

The whole chain is otherwise hard to check: whoever does something is left
out of its notices on purpose, so the obvious test - edit a page and watch -
shows nothing and looks broken.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/notifications/test' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`queued`


## Area: `pages`

<a id="area-pages"></a>

Pages: reading, writing, versions, the tree, comments, attachments, labels, restrictions, watching, export.

### `POST /api/pages`

**Create page**

- **Who may:** Anybody signed in
- **JSON body:** `space_id`, `parent_id`, `type`, `body`, `title`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"space_id": "…", "parent_id": "…", "type": "…", "body": "…", "title": "…"}'
```

**Returns**

`error`, `page`

### `PUT /api/pages/order`

**Change order**

The order somebody dragged a set of siblings into.

All of them are numbered, not only the one that moved: half a list with
numbers and half without would order by the numbers first and look shuffled.

- **Who may:** Permission: `PAGE_EDIT`
- **JSON body:** `ids`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/pages/order' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"ids": "…"}'
```

**Returns**

`error`, `ok`

### `POST /api/pages/order/reset`

**Reset – order**

Back to the alphabet for one group.

Setting every position to nought is what alphabetical means here, so this
is genuinely undoing the arrangement rather than replacing it with another.

- **Who may:** Permission: `PAGE_EDIT`
- **JSON body:** `space_id`, `parent_id`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/order/reset' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"space_id": "…", "parent_id": "…"}'
```

**Returns**

`error`, `ok`

### `GET /api/pages/{page_id}`

**Read page**

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pages/{page_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `page` | object |  |
| `page.id` | integer | `1` |
| `page.space_id` | integer | `1` |
| `page.parent_id` | null | `null` |
| `page.type` | string | `"page"` |
| `page.title` | string | `"MGWiki demo"` |
| `page.slug` | string | `"mgwiki-demo"` |
| `page.version` | integer | `1` |
| `page.status` | string | `"current"` |
| `page.excerpt` | string | `"Welcome"` |
| `page.created_by` | object |  |
| `page.created_by.id` | integer | `1` |
| `page.created_by.username` | string | `"admin"` |
| `page.created_by.display_name` | string | `"Administrator"` |
| `page.created_by.avatar_color` | string | `"#1F9D6B"` |
| `page.created_by.active` | boolean | `true` |
| `page.created_at` | string | `"2026-11-22 07:46:50"` |
| `page.updated_by` | object |  |
| `page.updated_by.id` | integer | `1` |
| `page.updated_by.username` | string | `"admin"` |
| `page.updated_by.display_name` | string | `"Administrator"` |
| `page.updated_by.avatar_color` | string | `"#1F9D6B"` |
| `page.updated_by.active` | boolean | `true` |
| `page.updated_at` | string | `"2026-11-22 07:46:50"` |
| `page.body` | string | `"<h2>Welcome</h2><p>This is the home page of the demo space.` |
| `page.toc` | array |  |
| `page.space` | object |  |
| `page.space.id` | integer | `1` |
| `page.space.key` | string | `"MG"` |
| `page.space.name` | string | `"MGWiki demo"` |
| `page.space.color` | string | `"#E07B39"` |
| `page.space.personal` | boolean | `false` |
| `page.breadcrumbs` | array |  |
| `page.labels` | array |  |
| `page.can_edit` | boolean | `true` |
| `page.archived` | null | `null` |
| `page.can_archive` | boolean | `true` |
| `page.can_restore` | boolean | `false` |
| `page.archive_visible` | boolean | `true` |
| `page.archive_children` | integer | `0` |

<details><summary>Example answer</summary>

```json
{
  "page": {
    "id": 1,
    "space_id": 1,
    "parent_id": null,
    "type": "page",
    "title": "MGWiki demo",
    "slug": "mgwiki-demo",
    "version": 1,
    "status": "current",
    "excerpt": "Welcome",
    "created_by": {
      "id": 1,
      "username": "admin",
      "display_name": "Administrator",
      "avatar_color": "#1F9D6B",
      "active": true
    },
    "created_at": "2026-11-22 07:46:50",
    "updated_by": {
      "id": 1,
      "username": "admin",
      "display_name": "Administrator",
      "avatar_color": "#1F9D6B",
      "active": true
    },
    "updated_at": "2026-11-22 07:46:50",
    "body": "<h2>Welcome</h2><p>This is the home page of the demo space. Use <b>Create</b>…",
    "toc": [],
    "space": {
      "id": 1,
      "key": "MG",
      "name": "MGWiki demo",
      "color": "#E07B39",
      "personal": false
    },
    "breadcrumbs": [],
    "labels": [],
    "can_edit": true,
    "archived": null,
    "can_archive": true,
    "can_restore": false,
    "archive_visible": true,
    "archive_children": 0,
    "can_export_pdf": true
  }
}
```

</details>

### `PUT /api/pages/{page_id}`

**Change page**

- **Who may:** Permission: `edit`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `title`, `body`, `base_version`, `comment`, `minor_edit`, `parent_id`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/pages/{page_id}' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"title": "…", "body": "…", "base_version": "…", "comment": "…", "minor_edit": "…", "parent_id": "…"}'
```

**Returns**

`error`, `code`, `page`, `merged`, `conflicts`

### `DELETE /api/pages/{page_id}`

**Delete page**

- **Who may:** Permission: `PAGE_DELETE`
- **Path parameters:** `page_id` (integer)
- **Query parameters:** `purge` (string)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/pages/{page_id}?purge=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`

### `POST /api/pages/{page_id}/archive`

**Archive – page**

Archive a page - with the pages below it (children: true, the default) or without them: then they move
up a level and stay. Takes "Archive pages" in its space.

- **Who may:** Permission: `view`, `PAGE_ARCHIVE`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `children`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/archive' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"children": "…"}'
```

**Returns**

`error`, `ok`, `archived`, `visible`

### `POST /api/pages/{page_id}/attachments`

**Create attachment (page)**

- **Who may:** Permission: `ATTACHMENT_ADD`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `(multipart form: file)`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/attachments' \
  -H 'Authorization: Bearer $TOKEN' \
  -F 'file=@/path/to/file'
```

**Returns**

`error`, `attachment`, `id`, `filename`, `size_bytes`, `mime_type`

### `PUT /api/pages/{page_id}/attachments/order`

**Change order (page)**

The order somebody dragged them into.

- **Who may:** Permission: `edit`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/pages/{page_id}/attachments/order' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`

### `GET /api/pages/{page_id}/comments`

**List comments (page)**

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pages/{page_id}/comments' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `comments` | array |  |

<details><summary>Example answer</summary>

```json
{
  "comments": []
}
```

</details>

### `POST /api/pages/{page_id}/comments`

**Create comment (page)**

- **Who may:** Permission: `view`, `COMMENT_ADD`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `body`, `parent_id`, `anchor`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/comments' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"body": "…", "parent_id": "…", "anchor": "…"}'
```

**Returns**

`error`, `comment`

### `GET /api/pages/{page_id}/draft`

**Draft – page**

- **Who may:** Anybody signed in
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pages/{page_id}/draft' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `draft` | null | `null` |

<details><summary>Example answer</summary>

```json
{
  "draft": null
}
```

</details>

### `POST /api/pages/{page_id}/draft`

**Draft – page**

Keep unsaved work where a closed browser cannot take it with it.

The draft belongs to one person on one page: it is what they were writing,
not a version of the page, and nobody else ever sees it.

- **Who may:** Permission: `edit`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `title`, `body`, `base_version`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/draft' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"title": "…", "body": "…", "base_version": "…"}'
```

**Returns**

`error`, `ok`, `saved_at`

### `PUT /api/pages/{page_id}/draft`

**Draft – page**

Keep unsaved work where a closed browser cannot take it with it.

The draft belongs to one person on one page: it is what they were writing,
not a version of the page, and nobody else ever sees it.

- **Who may:** Permission: `edit`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `title`, `body`, `base_version`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/pages/{page_id}/draft' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"title": "…", "body": "…", "base_version": "…"}'
```

**Returns**

`error`, `ok`, `saved_at`

### `DELETE /api/pages/{page_id}/draft`

**Draft – page**

- **Who may:** Anybody signed in
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/pages/{page_id}/draft' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`ok`

### `POST /api/pages/{page_id}/editing`

**Mark as being edited – page**

A heartbeat from somebody with the page open, and who else is in it.

Deliberately one call: the browser has to say it is still here anyway, and
making it ask separately who else is here would double the traffic for
nothing.

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `block`, `leaving`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/editing' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"block": "…", "leaving": "…"}'
```

**Returns**

`error`, `editors`

### `GET /api/pages/{page_id}/export.pdf`

**Export – page**

The page as a PDF (pdf_export.py) - for whoever may open it and has "Export pages as PDF". POST takes a
header and a footer (5.6.0): {header_html, footer_html, first_page_different} - printed on every page, or
from the second page on; {page}, {pages}, {title}, {space}, {date} and {user} are filled in.

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pages/{page_id}/export.pdf' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

A file (application/pdf).

### `POST /api/pages/{page_id}/export.pdf`

**Export – page**

The page as a PDF (pdf_export.py) - for whoever may open it and has "Export pages as PDF". POST takes a
header and a footer (5.6.0): {header_html, footer_html, first_page_different} - printed on every page, or
from the second page on; {page}, {pages}, {title}, {space}, {date} and {user} are filled in.

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/export.pdf' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`

### `POST /api/pages/{page_id}/favourite`

**Create favourite (page)**

- **Who may:** Anybody signed in
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/favourite' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`favourite`

### `PUT /api/pages/{page_id}/labels`

**Change labels (page)**

- **Who may:** Permission: `edit`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/pages/{page_id}/labels' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `labels`

### `POST /api/pages/{page_id}/move`

**Move – page**

- **Who may:** Permission: `edit`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `parent_id`, `space_id`, `position`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/move' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"parent_id": "…", "space_id": "…", "position": "…"}'
```

**Returns**

`error`, `ok`

### `POST /api/pages/{page_id}/restore`

**Restore – page**

Take an archived page out of the archive, with what was archived below it: back where it was - or,
with parent_id, under that active page of the same space (null: the top). Takes "View the archive" and
"Archive pages" in its space; a page of an archived space comes back with the space.

- **Who may:** Permission: `view`, `PAGE_ARCHIVE`
- **Path parameters:** `page_id` (integer)
- **JSON body:** `parent_id`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/restore' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"parent_id": "…"}'
```

**Returns**

`error`

### `GET /api/pages/{page_id}/restrictions`

**List restrictions (page)**

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pages/{page_id}/restrictions' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `restrictions` | array |  |

<details><summary>Example answer</summary>

```json
{
  "restrictions": []
}
```

</details>

### `PUT /api/pages/{page_id}/restrictions`

**Change restrictions (page)**

- **Who may:** Permission: `RESTRICTIONS_SET`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/pages/{page_id}/restrictions' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`, `withdrawn_from_help_site`

### `GET /api/pages/{page_id}/subtree`

**Read subtree (page)**

The pages under this one, as deep as asked for.

Each level is filtered by what the person asking may see, so a restricted
branch simply is not there rather than showing as a title they cannot open.

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer)
- **Query parameters:** `depth` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pages/{page_id}/subtree?depth=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `pages` | array |  |

<details><summary>Example answer</summary>

```json
{
  "pages": []
}
```

</details>

### `GET /api/pages/{page_id}/versions`

**List versions (page)**

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pages/{page_id}/versions' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `versions` | array |  |
| `versions[].id` | integer | `1` |
| `versions[].version` | integer | `1` |
| `versions[].title` | string | `"MGWiki demo"` |
| `versions[].comment` | string | `"Created"` |
| `versions[].minor_edit` | integer | `0` |
| `versions[].created_at` | string | `"2026-11-22 07:46:50"` |
| `versions[].editor` | object |  |

<details><summary>Example answer</summary>

```json
{
  "versions": [
    {
      "id": 1,
      "version": 1,
      "title": "MGWiki demo",
      "comment": "Created",
      "minor_edit": 0,
      "created_at": "2026-11-22 07:46:50",
      "editor": {
        "id": 1,
        "username": "admin",
        "display_name": "Administrator",
        "avatar_color": "#1F9D6B",
        "active": true
      }
    }
  ]
}
```

</details>

### `GET /api/pages/{page_id}/versions/{version}`

**Read version (page)**

- **Who may:** Permission: `view`
- **Path parameters:** `page_id` (integer), `version` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pages/{page_id}/versions/{version}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `version` | object |  |
| `version.id` | integer | `1` |
| `version.page_id` | integer | `1` |
| `version.version` | integer | `1` |
| `version.title` | string | `"MGWiki demo"` |
| `version.body` | string | `"<h2>Welcome</h2>"` |
| `version.comment` | string | `"Created"` |
| `version.minor_edit` | integer | `0` |
| `version.created_at` | string | `"2026-11-22 07:46:50"` |
| `version.editor` | object |  |
| `version.editor.id` | integer | `1` |
| `version.editor.username` | string | `"admin"` |
| `version.editor.display_name` | string | `"Administrator"` |
| `version.editor.avatar_color` | string | `"#1F9D6B"` |
| `version.editor.active` | boolean | `true` |

<details><summary>Example answer</summary>

```json
{
  "version": {
    "id": 1,
    "page_id": 1,
    "version": 1,
    "title": "MGWiki demo",
    "body": "<h2>Welcome</h2>",
    "comment": "Created",
    "minor_edit": 0,
    "created_at": "2026-11-22 07:46:50",
    "editor": {
      "id": 1,
      "username": "admin",
      "display_name": "Administrator",
      "avatar_color": "#1F9D6B",
      "active": true
    }
  }
}
```

</details>

### `POST /api/pages/{page_id}/versions/{version}/restore`

**Restore – version**

- **Who may:** Permission: `edit`
- **Path parameters:** `page_id` (integer), `version` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/versions/{version}/restore' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`, `version`

### `POST /api/pages/{page_id}/watch`

**Watch or stop watching – page**

- **Who may:** Anybody signed in
- **Path parameters:** `page_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pages/{page_id}/watch' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`watching`


## Area: `pdf-layouts`

<a id="area-pdf-layouts"></a>

### `GET /api/pdf-layouts`

**Read pdf layouts**

This person's headers and footers - each belongs to whoever kept it, nobody else sees it.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/pdf-layouts' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `layouts` | array |  |

<details><summary>Example answer</summary>

```json
{
  "layouts": []
}
```

</details>

### `POST /api/pdf-layouts`

**Send pdf layouts**

Kept under a name; the same name again replaces it.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/pdf-layouts' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `layout`

### `DELETE /api/pdf-layouts/{layout_id}`

**Delete pdf layouts**

- **Who may:** Anybody signed in
- **Path parameters:** `layout_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/pdf-layouts/{layout_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`


## Area: `search`

<a id="area-search"></a>

Searching issues with MQL, and exporting the result.

### `GET /api/search`

**Read search**

Pages and spaces by a piece of text (q, at least 2 characters) - optionally in one space (space_id);
archived=1 takes in the archived pages too, for whoever may see the archive.

- **Who may:** Permission: `view`
- **Query parameters:** `q` (string), `space_id` (string), `archived` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/search?q=…&space_id=…&archived=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `results` | array |  |

<details><summary>Example answer</summary>

```json
{
  "results": []
}
```

</details>


## Area: `spaces`

<a id="area-spaces"></a>

Spaces: creating them, their permissions, the page tree, templates and labels.

### `GET /api/spaces`

**List spaces**

- **Who may:** No sign-in needed
- **Query parameters:** `archived` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/spaces?archived=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `spaces` | array |  |
| `spaces[].id` | integer | `1` |
| `spaces[].key` | string | `"MG"` |
| `spaces[].name` | string | `"MGWiki demo"` |
| `spaces[].description` | string | `"A place to try things out"` |
| `spaces[].type` | string | `"global"` |
| `spaces[].icon` | string | `"book"` |
| `spaces[].color` | string | `"#E07B39"` |
| `spaces[].status` | string | `"current"` |
| `spaces[].homepage_id` | integer | `1` |
| `spaces[].owner_id` | integer | `1` |
| `spaces[].personal` | boolean | `false` |
| `spaces[].owner_name` | null | `null` |
| `spaces[].permissions` | array |  |
| `spaces[].can_delete` | boolean | `true` |
| `spaces[].archived_at` | null | `null` |

<details><summary>Example answer</summary>

```json
{
  "spaces": [
    {
      "id": 1,
      "key": "MG",
      "name": "MGWiki demo",
      "description": "A place to try things out",
      "type": "global",
      "icon": "book",
      "color": "#E07B39",
      "status": "current",
      "homepage_id": 1,
      "owner_id": 1,
      "personal": false,
      "owner_name": null,
      "permissions": [
        "ATTACHMENT_ADD",
        "ATTACHMENT_DELETE",
        "…"
      ],
      "can_delete": true,
      "archived_at": null
    }
  ]
}
```

</details>

### `POST /api/spaces`

**Create space**

- **Who may:** Permission: `CREATE_SPACE`
- **JSON body:** `name`, `key`, `color`, `description`, `icon`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/spaces' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name": "…", "key": "…", "color": "…", "description": "…", "icon": "…"}'
```

**Returns**

`error`, `space`

### `GET /api/spaces/palette`

**Read palette**

The colours a space may carry, and the one that would be picked now.

The suggestion is what happens if nobody chooses: away from what the last
few spaces took. Offering it rather than imposing it means the common case
stays one click and the deliberate case stays possible.

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/spaces/palette' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `colors` | array |  |
| `suggested` | string | `"#5B8C2A"` |

<details><summary>Example answer</summary>

```json
{
  "colors": [
    "#50226B",
    "#6B5BC4",
    "…"
  ],
  "suggested": "#5B8C2A"
}
```

</details>

### `POST /api/spaces/personal`

**Send personal**

One's own personal space - with "Create a personal space" alone, also for somebody who may otherwise only
edit what exists. One each; asked again, it answers the one there is.

- **Who may:** Permission: `PERSONAL_SPACE`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/spaces/personal' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `space`, `existing`

### `GET /api/spaces/{key}`

**Read space**

- **Who may:** Permission: `view`
- **Path parameters:** `key` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/spaces/{key}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `space` | object |  |
| `space.id` | integer | `1` |
| `space.key` | string | `"MG"` |
| `space.name` | string | `"MGWiki demo"` |
| `space.description` | string | `"A place to try things out"` |
| `space.type` | string | `"global"` |
| `space.icon` | string | `"book"` |
| `space.color` | string | `"#E07B39"` |
| `space.status` | string | `"current"` |
| `space.homepage_id` | integer | `1` |
| `space.owner_id` | integer | `1` |
| `space.personal` | boolean | `false` |
| `space.owner_name` | null | `null` |
| `space.permissions` | array |  |
| `space.can_delete` | boolean | `true` |
| `space.archived_at` | null | `null` |

<details><summary>Example answer</summary>

```json
{
  "space": {
    "id": 1,
    "key": "MG",
    "name": "MGWiki demo",
    "description": "A place to try things out",
    "type": "global",
    "icon": "book",
    "color": "#E07B39",
    "status": "current",
    "homepage_id": 1,
    "owner_id": 1,
    "personal": false,
    "owner_name": null,
    "permissions": [
      "ATTACHMENT_ADD",
      "ATTACHMENT_DELETE",
      "…"
    ],
    "can_delete": true,
    "archived_at": null
  }
}
```

</details>

### `PUT /api/spaces/{space_id}`

**Change space**

- **Who may:** Permission: `SPACE_ADMIN`, `SPACE_ARCHIVE`
- **Path parameters:** `space_id` (integer)
- **JSON body:** `status`, `space_key`, `key`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/spaces/{space_id}' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"status": "…", "space_key": "…", "key": "…"}'
```

**Returns**

`error`, `space`

### `DELETE /api/spaces/{space_id}`

**Delete space**

- **Who may:** Permission: `SPACE_ADMIN`
- **Path parameters:** `space_id` (integer)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/spaces/{space_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`, `name`, `pages`, `files`

### `GET /api/spaces/{space_id}/access-log`

**Read access log (space)**

Who of the administrators opened or changed something in this personal space - for its owner (and the
administrators). Looked at by the owner, nothing in it counts as new any more.

- **Who may:** Anybody signed in
- **Path parameters:** `space_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/spaces/{space_id}/access-log' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `entries`, `unseen`

### `PUT /api/spaces/{space_id}/admin-access`

**Change admin access (space)**

The owner of a personal space shuts administrators out - or lets them in again. Shut, nobody but the owner
gets in: not the space, its pages and files, the list of spaces, the search, the AI or the database pages
of System settings. The owner's decision alone; written into the audit log.

- **Who may:** Anybody signed in
- **Path parameters:** `space_id` (integer)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/spaces/{space_id}/admin-access' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `admins_excluded`

### `POST /api/spaces/{space_id}/archive`

**Archive – space**

Archive a whole space with all its pages. Takes "Archive the space" in it; a personal space its owner.

- **Who may:** Permission: `SPACE_ARCHIVE`
- **Path parameters:** `space_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/spaces/{space_id}/archive' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`, `pages`, `visible`

### `GET /api/spaces/{space_id}/members`

**List members (space)**

Who can be mentioned here: the people who may read this space.

Anyone else would be told about a page they cannot open, which is worse
than not being told at all.

- **Who may:** Anybody signed in
- **Path parameters:** `space_id` (integer)
- **Query parameters:** `q` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/spaces/{space_id}/members?q=…' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `members` | array |  |
| `members[].id` | integer | `1` |
| `members[].username` | string | `"admin"` |
| `members[].display_name` | string | `"Administrator"` |
| `members[].avatar_color` | string | `"#1F9D6B"` |

<details><summary>Example answer</summary>

```json
{
  "members": [
    {
      "id": 1,
      "username": "admin",
      "display_name": "Administrator",
      "avatar_color": "#1F9D6B"
    }
  ]
}
```

</details>

### `GET /api/spaces/{space_id}/permissions`

**List permissions (space)**

- **Who may:** Permission: `SPACE_ADMIN`
- **Path parameters:** `space_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/spaces/{space_id}/permissions' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `available` | array |  |
| `available[].key` | string | `"SPACE_VIEW"` |
| `available[].label` | string | `"View the space"` |
| `subjects` | array |  |
| `subjects[].subject_type` | string | `"group"` |
| `subjects[].subject_id` | integer | `1` |
| `subjects[].name` | string | `"wiki-administrators"` |
| `subjects[].permissions` | array |  |

<details><summary>Example answer</summary>

```json
{
  "available": [
    {
      "key": "SPACE_VIEW",
      "label": "View the space"
    },
    {
      "key": "PAGE_ADD",
      "label": "Add pages"
    },
    "…"
  ],
  "subjects": [
    {
      "subject_type": "group",
      "subject_id": 1,
      "name": "wiki-administrators",
      "permissions": [
        "SPACE_VIEW",
        "PAGE_ADD",
        "…"
      ]
    },
    {
      "subject_type": "group",
      "subject_id": 2,
      "name": "wiki-users",
      "permissions": [
        "SPACE_VIEW",
        "PAGE_ADD",
        "…"
      ]
    }
  ]
}
```

</details>

### `PUT /api/spaces/{space_id}/permissions`

**Change permissions (space)**

- **Who may:** Permission: `SPACE_ADMIN`
- **Path parameters:** `space_id` (integer)
- **JSON body:** `subjects`

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/spaces/{space_id}/permissions' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"subjects": "…"}'
```

**Returns**

`error`, `ok`

### `POST /api/spaces/{space_id}/restore`

**Restore – space**

Take an archived space out of the archive, with the pages archived with it. Takes "View the archive"
and "Archive the space" in it.

- **Who may:** Permission: `SPACE_ARCHIVE`
- **Path parameters:** `space_id` (integer)

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/spaces/{space_id}/restore' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `ok`, `pages`, `key`

### `GET /api/spaces/{space_id}/templates`

**List templates (space)**

What somebody creating a page here can start from: this space's own
templates and the ones that belong to no space in particular.

- **Who may:** Anybody signed in
- **Path parameters:** `space_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/spaces/{space_id}/templates' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `templates` | array |  |

<details><summary>Example answer</summary>

```json
{
  "templates": []
}
```

</details>

### `GET /api/spaces/{space_id}/tree`

**Read page tree (space)**

- **Who may:** Permission: `SPACE_VIEW`
- **Path parameters:** `space_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/spaces/{space_id}/tree' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `tree` | array |  |
| `tree[].id` | integer | `1` |
| `tree[].title` | string | `"MGWiki demo"` |
| `tree[].type` | string | `"page"` |
| `tree[].parent_id` | null | `null` |
| `tree[].position` | integer | `0` |
| `tree[].children` | array |  |

<details><summary>Example answer</summary>

```json
{
  "tree": [
    {
      "id": 1,
      "title": "MGWiki demo",
      "type": "page",
      "parent_id": null,
      "position": 0,
      "children": []
    }
  ]
}
```

</details>


## Area: `templates`

<a id="area-templates"></a>

Page templates.

### `GET /api/templates/{template_id}`

**Read template**

- **Who may:** Anybody signed in
- **Path parameters:** `template_id` (integer)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/templates/{template_id}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

`error`, `template`


## Area: `third-party`

<a id="area-third-party"></a>

### `GET /api/third-party`

**Read third party**

- **Who may:** Anybody signed in

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/third-party' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

| Field | Type | Example |
|---|---|---|
| `product` | string | `"mgwiki5"` |
| `version` | string | `"5.9.0"` |
| `made` | string | `""` |
| `components` | array |  |
| `components[].name` | string | `"draw.io"` |
| `components[].version` | string | `"32.7.4"` |
| `components[].kind` | string | `"Diagram editor"` |
| `components[].url` | string | `"https://github.com/jgraph/drawio"` |
| `components[].licences` | array |  |
| `components[].description` | string | `"The diagram editor of the page editor, served from static/d` |
| `components[].texts` | array |  |
| `source` | string | `"installation"` |

<details><summary>Example answer</summary>

```json
{
  "product": "mgwiki5",
  "version": "5.9.0",
  "made": "",
  "components": [
    {
      "name": "draw.io",
      "version": "32.7.4",
      "kind": "Diagram editor",
      "url": "https://github.com/jgraph/drawio",
      "licences": [
        "Apache-2.0"
      ],
      "description": "The diagram editor of the page editor, served from static/drawio",
      "texts": [
        {
          "file": "LICENSE (Apache 2.0, the program)",
          "text": "                                 Apache License\n                           Ve…"
        },
        {
          "file": "templates/LICENSE (CC BY 4.0, the diagram templates)",
          "text": "Creative Commons Attribution 4.0 International Public License\n\nBy exercising …"
        },
        "…"
      ]
    },
    {
      "name": "Barlow (font)",
      "version": "",
      "kind": "Font",
      "url": "",
      "licences": [
        "OFL-1.1"
      ],
      "description": "",
      "texts": [
        {
          "file": "LICENSE-barlow-condensed.txt",
          "text": "Copyright 2017 The Barlow Project Authors (https://github.com/jpt/barlow) Bar…"
        }
      ],
      "files": [
        "barlow-condensed-600.woff2",
        "barlow-condensed-700.woff2"
      ]
    },
    "…"
  ],
  "source": "installation"
}
```

</details>


## Area: `uploads`

<a id="area-uploads"></a>

Big files in pieces: begin, send piece by piece, ask how far it got, cancel.

### `POST /api/uploads`

**Create upload**

Begin a big file in pieces: its name and size, checked against the limit first.

- **Who may:** Anybody signed in
- **JSON body:** `filename`, `size`

**Call**

```bash
curl -s -X POST 'http://127.0.0.1:8719/api/uploads' \
  -H 'Authorization: Bearer $TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"filename": "…", "size": "…"}'
```

**Returns**

JSON.

### `GET /api/uploads/{uid}`

**Read upload**

- **Who may:** Anybody signed in
- **Path parameters:** `uid` (string)

**Call**

```bash
curl -s -X GET 'http://127.0.0.1:8719/api/uploads/{uid}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

JSON.

### `DELETE /api/uploads/{uid}`

**Delete upload**

- **Who may:** Anybody signed in
- **Path parameters:** `uid` (string)

**Call**

```bash
curl -s -X DELETE 'http://127.0.0.1:8719/api/uploads/{uid}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

The same as `GET /api/uploads/{uid}`.

### `PUT /api/uploads/{uid}/{index}`

**Change upload**

- **Who may:** Anybody signed in
- **Path parameters:** `uid` (string), `index` (integer)

**Call**

```bash
curl -s -X PUT 'http://127.0.0.1:8719/api/uploads/{uid}/{index}' \
  -H 'Authorization: Bearer $TOKEN'
```

**Returns**

JSON.

