# Posts

> List published posts, fetch one with its HTML, and preview drafts from your server.

## List posts

```endpoint
GET /sites/{siteId}/posts
```

Returns published posts. By default featured posts come first, then the rest, newest first.

### Query parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `tag` | string | Only posts with this tag slug |
| `author` | string | Only posts by this author slug |
| `exclude` | string | A post id to leave out, such as the current post in a "related posts" list |
| `order` | `featured` or `latest` | `featured` (default): featured first, then newest. `latest`: newest first |
| `limit` | number | Posts per page, 1 to 100. Leave it out to get every matching post |
| `page` | number | Page number, from 1. Only used with `limit` |

```bash
curl "https://api.quillhive.com/api/public/v1/sites/YOUR_SITE_ID/posts?tag=engineering&limit=10&page=2"
```

```json title="Response"
{
  "posts": [
    {
      "id": "clx123...",
      "title": "Offline sync: what we learned",
      "slug": "offline-sync",
      "excerpt": "Six months, three rewrites...",
      "featureImage": "https://...",
      "featured": false,
      "publishedAt": "2026-10-02T10:00:00.000Z",
      "updatedAt": "2026-10-05T15:30:00.000Z",
      "tags": [
        { "id": "...", "name": "Engineering", "slug": "engineering" }
      ],
      "authors": [
        { "id": "...", "slug": "minji-ahn", "name": "Minji Ahn", "avatar": "https://..." }
      ]
    }
  ],
  "meta": { "page": 2, "limit": 10, "total": 42, "totalPages": 5 }
}
```

- Tags are in the post's order, so the first is the **primary tag**.
- Authors are in byline order.
- Without `limit`, `meta` is `{ "page": 1, "limit": null, "total": 42, "totalPages": 1 }`.

## Get a post

```endpoint
GET /sites/{siteId}/posts/{idOrSlug}
```

Returns one published post with its full HTML, by id or slug. Posts and pages share slugs, so this also finds pages. Drafts and scheduled posts return `404`.

```bash
curl https://api.quillhive.com/api/public/v1/sites/YOUR_SITE_ID/posts/offline-sync
```

```json title="Response"
{
  "post": {
    "id": "clx123...",
    "title": "Offline sync: what we learned",
    "slug": "offline-sync",
    "html": "<p>Six months ago we...</p>",
    "excerpt": "Six months, three rewrites...",
    "featureImage": "https://...",
    "featureImageAlt": "A whiteboard full of arrows",
    "featured": false,
    "publishedAt": "2026-10-02T10:00:00.000Z",
    "updatedAt": "2026-10-05T15:30:00.000Z",
    "tags": [
      { "id": "...", "name": "Engineering", "slug": "engineering" }
    ],
    "authors": [
      {
        "id": "...",
        "slug": "minji-ahn",
        "name": "Minji Ahn",
        "bio": "Writes about sync and storage.",
        "avatar": "https://...",
        "website": null,
        "twitter": "minjiahn",
        "linkedin": null
      }
    ]
  }
}
```

A missing post returns `404` with `{ "post": null }`.

## Preview a post

```endpoint
GET /sites/{siteId}/posts/preview/{idOrUuid}
```

Returns a post or page **in any status**: draft, scheduled or published. Look it up by id or uuid, never by slug. Use it to show unpublished drafts on your own frontend.

> [!WARNING]
> This endpoint **requires the site's API key**. Call it from your server only, and never expose the key to browsers.

```bash
curl https://api.quillhive.com/api/public/v1/sites/YOUR_SITE_ID/posts/preview/0b6c1f9e-... \
  -H "Authorization: Bearer blgg_..."
```

The response is shaped like [Get a post](#get-a-post), plus `status` and `uuid`. It is sent with `Cache-Control: private, no-store`.

| Status | When |
| --- | --- |
| `401` | No key, or a key for another site |
| `404` | No post or page with that id or uuid |

To open drafts from the editor's **Preview** button on your frontend, see [Draft previews](/docs/headless#draft-previews-on-your-frontend).
