# Post Management API

> Part of the [NextBlog documentation](https://nextblog.ai/docs.md). Live page: [https://nextblog.ai/docs/api-manage-posts](https://nextblog.ai/docs/api-manage-posts)

> **Legacy alias.** These endpoints keep working with the same request and response shapes, but new integrations should use the [Full REST API](/docs/api-v1.md): `GET/POST /api/v1/projects/{projectId}/posts`, `GET/PATCH/DELETE /api/v1/projects/{projectId}/posts/{postId}`, plus `/approve`, `/decline` and `/unpublish`. v1 also adds generation, integrations, billing and the same error codes everywhere.

Optional, advanced API for creating and editing posts, changing status, and listing drafts or declined posts. Most users manage content in the NextBlog dashboard; use this when you need full control from your own backend.

Use the same project API key as the display API: `Authorization: Bearer your_api_key`. For embedding published posts on a website, prefer the [Blog Display API](/docs/endpoints.md) (`/api/blog/...`).

### Base URL

```bash
https://nextblog.ai/api/manage
```

### Status values

- `draft` — not shown on the public Blog Display API; editable.
- `approved` with `published: true` — included in the Blog Display API.
- `declined` — not shown on the Blog Display API.

When `status` is `approved` (or you publish via `published: true`), a non-empty `slug` is required. Setting status or publishing through this API updates your NextBlog project data; it does not run the same external CMS publish steps as approving from the dashboard (e.g. WordPress sync). Use the dashboard for integrations that push to third-party platforms.

### Endpoints

#### List all posts (including drafts)

**Endpoint:** `GET /api/manage/{projectId}/posts`

**Query (optional):** `status` (`draft`, `approved`, `declined`), `published` (`true` / `false`), `limit`.

**Example:**

```bash
curl -H "Authorization: Bearer your_api_key_here" \
  "https://nextblog.ai/api/manage/project_123/posts?status=draft"
```

#### Create a post

**Endpoint:** `POST /api/manage/{projectId}/posts`

**Body (JSON):** required `title`, `markdown`. Optional: `slug`, `description`, `cover_image_url`, `cover_image_alt`, `published`, `status`. New posts default to draft unless you set status or published.

```bash
curl -X POST -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"title":"My post","markdown":"# Hello","status":"draft"}' \
  https://nextblog.ai/api/manage/project_123/posts
```

#### Get one post by ID

**Endpoint:** `GET /api/manage/{projectId}/posts/{postId}`

Returns full fields including `markdown` for drafts and declined posts.

```bash
curl -H "Authorization: Bearer your_api_key_here" \
  https://nextblog.ai/api/manage/project_123/posts/blog_uuid
```

#### Update a post (content or status)

**Endpoint:** `PATCH /api/manage/{projectId}/posts/{postId}`

**Body (JSON):** any of `title`, `markdown`, `slug`, `description`, `cover_image_url`, `cover_image_alt`, `published`, `status`. Send only fields you want to change.

```bash
curl -X PATCH -H "Authorization: Bearer your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"status":"approved","slug":"my-post-slug"}' \
  https://nextblog.ai/api/manage/project_123/posts/blog_uuid
```

### Errors

- **400** — validation (e.g. missing slug when approving)
- **401** — missing or invalid API key
- **404** — post not found or not in this project
- **409** — duplicate slug (when applicable)
- **429** — rate limit exceeded (`Retry-After` header)
- **500** — server error

### Rate Limits

Requests are limited to **120 per minute and 1,000 per hour per credential** (shared with the [Blog Display API](/docs/endpoints.md), the [Full REST API](/docs/api-v1.md) and the [MCP Server](/docs/mcp.md)). Exceeding a limit returns `429` with `Retry-After`. See [Full REST API → Rate limits](/docs/api-v1.md#rate-limits).
