# Pages

Pages are standalone publication content. They have no category, tags, authors,
excerpt, or scheduling workflow. New pages start as drafts; lifecycle changes
use dedicated routes.

## Authentication

All routes require a bearer token and the listed publication capability. Use
`page_id` for an existing page, or use `publication_id` or `publication_slug`
with `slug` where a page selector is accepted.

## Routes

| Route | Methods | Capability | Required input | Optional input and behavior | Success result |
| --- | --- | --- | --- | --- | --- |
| `/page/list` | `GET`, `POST` | `page.list` | Publication selector | `status`, `visibility`, `archived`, pagination | Paginated `pages`. |
| `/page/get` | `POST` | `page.list` | Page selector | — | Full `page`. |
| `/page/save` | `POST` | `page.save` | Create: publication selector and `title`; update: `page_id` | `title`, `slug`, `body`, `body_format`, `visibility` | Saved `page`. |
| `/page/preview` | `POST` | `page.preview` | `page_id` | — | Rendered `preview`. |
| `/page/publish` | `POST` | `page.publish` | Page selector | — | Published `page`. |
| `/page/unpublish` | `POST` | `page.unpublish` | Page selector | — | Draft `page`. |
| `/page/archive` | `POST` | `page.archive` | Page selector | — | Archived `page`. |
| `/page/restore` | `POST` | `page.restore` | Page selector | — | Restored `page`. |
| `/page/delete` | `POST` | `page.delete` | Page selector | — | Deleted `page_id`. |

## Save fields

| Field | Required | Type | Description |
| --- | --- | --- | --- |
| `page_id` | No | UUID | Updates this page. Omit to create. |
| `publication_id` / `publication_slug` | Required on create | UUID / String | Selects the publication. |
| `title` | Required on create | String | Page title. Omit it on update to retain the stored value. |
| `slug` | No | String | Unique in the publication. Omit or send an empty value to derive it from `title`. |
| `body` | No | String | Source content. Omit it on update to retain the stored body. |
| `body_format` | No | `markdown` or `html` | Defaults to `markdown` for a new page. |
| `visibility` | No | `public`, `unlisted`, or `private` | Defaults to `public` for a new page. |

```bash
curl -sS https://api.blog.service.m7.org/v1/page/save \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "publication_slug":"engineering-notes",
    "title":"About us",
    "body":"# About us",
    "body_format":"markdown"
  }'
```

## List, preview, and lifecycle

`/page/list` defaults to `archived: 0` and accepts `status` (`draft` or
`published`), `visibility` (`public`, `unlisted`, or `private`), and the
standard pagination fields. `/page/preview` requires `page_id` and renders the
stored source only; `preview.body` is HTML and `source_body_format` identifies
the stored source format.

`/page/publish` changes a draft, unarchived page to published and sets
`published_at` if it has not been set. `/page/unpublish` returns a published page to draft.
Archive and restore preserve lifecycle state. A page must be archived before
`/page/delete`; otherwise the route returns `409`.

## Public availability

`GET` or `POST /read/page` accepts a publication selector and `page_slug`.
It returns an unarchived published page with `public` or `unlisted` visibility;
the returned body is HTML. Private, draft, and archived pages return `404`.
