# Publication context

Use context after selecting a publication to discover the effective workspace,
membership role, and current permitted actions for an editorial interface.

## Authentication

`POST /v1/context/get` requires a bearer token and the effective principal's
active publication membership. It accepts archived publications to expose their
remaining read and cleanup actions. Service-wide roles do not bypass membership.
Organization workspaces additionally apply current verified Management grants.

## Request

| Field | Required | Type | Description |
| --- | --- | --- | --- |
| `publication_id` | One selector required | UUID | Stable publication ID. |
| `publication_slug` | One selector required | String | Publication slug; prefer the ID once known. |
| `org_id` | No | UUID | Selected organization's native ID; alternatively send the `Org` header. |

```bash
curl -sS https://api.blog.service.m7.org/v1/context/get \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"publication_slug":"engineering-notes"}'
```

The success envelope uses comment `context loaded` and returns `data.context`.
The following excerpt shows the fields used for access decisions; additional
member, principal-capability, and feature fields can be present:

```json
{
  "principal_id": "WORKSPACE_PRINCIPAL_UUID",
  "actor_principal_id": "ACTOR_PRINCIPAL_UUID",
  "workspace": null,
  "publication": {
    "publication_id": "PUBLICATION_UUID",
    "slug": "engineering-notes",
    "name": "Engineering Notes",
    "status": "active",
    "archived": 0
  },
  "role": "member",
  "access_role": "member",
  "scope": "member",
  "capabilities": ["publication.get", "post.list", "post.save"]
}
```

`role` and `access_role` are `owner`, `admin`, or `member`. `principal_id` is
the effective member; `actor_principal_id` identifies the signed actor.
`workspace` is `null` for Personal, or an object containing `org_id`,
`org_name`, and the organization's `principal_id`. Use
`capabilities` for the selected publication's actions and
`principal_capabilities` for publication listing and creation. Membership
defaults or custom selections determine optional grants; archived state and
organization grants further restrict them. The server rechecks on every action,
so a previously returned capability is not a lasting authorization credential.

Missing authentication returns `401`, missing active membership returns `403`,
and an unavailable publication returns `404`. See [workspaces](https://m7.org/docs/api/api.blog.service.m7.org/workspaces.md)
and [membership management](https://m7.org/docs/api/api.blog.service.m7.org/members.md) for selection and role changes.
