# Publishing

Publish documents to GitHub, WordPress or a webhook. A connection holds the credentials; a publication says what goes where.

## Endpoints

- [Get a connection](https://developers.lydie.co/api/publishing/get-a-connection.md): `GET /v1/connections/{id}`
- [Change a connection](https://developers.lydie.co/api/publishing/change-a-connection.md): `PATCH /v1/connections/{id}`
- [Remove a connection](https://developers.lydie.co/api/publishing/remove-a-connection.md): `DELETE /v1/connections/{id}`
- [Test a connection](https://developers.lydie.co/api/publishing/test-a-connection.md): `POST /v1/connections/{id}/test`
- [List publishing connectors](https://developers.lydie.co/api/publishing/list-publishing-connectors.md): `GET /v1/connectors`
- [Publish a document to a connection](https://developers.lydie.co/api/publishing/publish-a-document-to-a-connection.md): `POST /v1/documents/{documentId}/publications`
- [Get a publication](https://developers.lydie.co/api/publishing/get-a-publication.md): `GET /v1/publications/{id}`
- [Change a publication](https://developers.lydie.co/api/publishing/change-a-publication.md): `PATCH /v1/publications/{id}`
- [Remove a publication](https://developers.lydie.co/api/publishing/remove-a-publication.md): `DELETE /v1/publications/{id}`
- [Resolve a diverged document](https://developers.lydie.co/api/publishing/resolve-a-diverged-document.md): `POST /v1/publications/{id}/resolve`
- [Publish now](https://developers.lydie.co/api/publishing/publish-now.md): `POST /v1/publications/{id}/run`
- [List a publication's runs](https://developers.lydie.co/api/publishing/list-a-publications-runs.md): `GET /v1/publications/{id}/runs`
- [Unpublish](https://developers.lydie.co/api/publishing/unpublish.md): `POST /v1/publications/{id}/unpublish`
- [List connections](https://developers.lydie.co/api/publishing/list-connections.md): `GET /v1/workspaces/{workspaceId}/connections`
- [Connect a destination](https://developers.lydie.co/api/publishing/connect-a-destination.md): `POST /v1/workspaces/{workspaceId}/connections`
- [Start connecting with OAuth](https://developers.lydie.co/api/publishing/start-connecting-with-oauth.md): `POST /v1/workspaces/{workspaceId}/connections/authorize`
- [List publications](https://developers.lydie.co/api/publishing/list-publications.md): `GET /v1/workspaces/{workspaceId}/publications`

## The Publication object

- `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)

```json
{
  "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"
}
```
