# Publish a document to a connection

`POST /v1/documents/{documentId}/publications`

Creates a publication of a document (and its subpages with `includeSubpages`) to a connection, and queues the first run unless `publishNow` is false. `config` follows the connector's configSchema (connector.list). Needs edit access to the document.

Scope: `docs:write`.

## Request

```bash
curl -X POST "https://api.lydie.co/v1/documents/01JCQ3V5MZ8G4ZK2X7T9R6N1PB/publications" \
  -H "Authorization: Bearer $LYDIE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "connectionId": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB"
  }'
```

## Path parameters

- `documentId` (ULID, required)

## Body

- `connectionId` (ULID, required)
- `includeSubpages` (boolean, optional): Default: `false`.
- `filter` (object, optional, nullable): Publish only documents whose property equals this (lists: contains it). Default: `null`.
  - `property` (string, required): (1–128 chars)
  - `equals` (any, required)
- `config` (object, optional): Default: `{}`.
- `autoPublish` (boolean, optional): Default: `false`.
- `publishNow` (boolean, optional): Default: `true`.

## Response

- `publication` (Publication, required)
  - `id` (ULID, required)
  - `workspaceId` (string, required): (1–64 chars)
  - `connectionId` (ULID, required)
  - `connector` (string, required)
  - `documentId` (ULID, required)
  - `includeSubpages` (boolean, required)
  - `filter` (object, required, nullable): Publish only documents whose property equals this (lists: contains it).
    - `property` (string, required): (1–128 chars)
    - `equals` (any, required)
  - `config` (object, required)
  - `autoPublish` (boolean, required)
  - `lastRunAt` (timestamp, required, nullable)
  - `items` (PublicationItem[], required)
    - `id` (ULID, required)
    - `documentId` (ULID, required)
    - `state` (string, required): One of: `draft`, `scheduled`, `publishing`, `published`, `updated_pending`, `failed`, `unpublished`, `diverged`.
    - `externalId` (string, required, nullable)
    - `externalUrl` (string, required, nullable)
    - `lastPublishedAt` (timestamp, required, nullable)
    - `lastError` (object, required, nullable)
    - `divergence` (object, required, nullable): For diverged items: reason, base/ours/theirs (destination format), conflicts, marked text and the pull request.
    - `updatedAt` (timestamp, required)
  - `createdBy` (string, required, nullable)
  - `updatedBy` (string, required, nullable)
  - `createdAt` (timestamp, required)
  - `updatedAt` (timestamp, required)
- `run` (PublicationRun, required, nullable): A run and its log.
  - `id` (ULID, required)
  - `publicationId` (ULID, required)
  - `action` (string, required): One of: `publish`, `unpublish`, `resolve`.
  - `trigger` (string, required): One of: `manual`, `auto`, `poll`.
  - `options` (object, required)
  - `status` (string, required): One of: `queued`, `running`, `succeeded`, `partial`, `failed`, `cancelled`.
  - `attempt` (integer, required)
  - `runAt` (timestamp, required)
  - `steps` (object[], required)
    - `at` (timestamp, required)
    - `step` (string, required)
    - `status` (string, required): One of: `ok`, `skipped`, `error`, `info`.
    - `documentId` (string, optional)
    - `ms` (number, optional)
    - `detail` (object, optional)
  - `summary` (object, required, nullable)
  - `error` (object, required, nullable)
  - `requestedBy` (string, required)
  - `createdAt` (timestamp, required)
  - `startedAt` (timestamp, required, nullable)
  - `finishedAt` (timestamp, required, nullable)

```json
{
  "publication": {
    "id": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
    "workspaceId": "01JCQ3TZ0WJ8K4M2X7T9R6N1PA",
    "connectionId": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
    "connector": "string",
    "documentId": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
    "includeSubpages": false,
    "filter": null,
    "config": {},
    "autoPublish": false,
    "lastRunAt": null,
    "items": [
      {
        "id": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
        "documentId": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
        "state": "draft",
        "externalId": null,
        "externalUrl": null,
        "lastPublishedAt": null,
        "lastError": null,
        "divergence": null,
        "updatedAt": "2026-11-12T09:30:00.000Z"
      }
    ],
    "createdBy": null,
    "updatedBy": null,
    "createdAt": "2026-11-12T09:30:00.000Z",
    "updatedAt": "2026-11-12T09:30:00.000Z"
  },
  "run": null
}
```

Errors use the envelope described at https://developers.lydie.co/errors.md.
