---
title: IronCMS Content API
version: Content API 0.3.x · AI Services 0.2.x
updated: 2026-11-24
---

# IronCMS Content API

The **IronCMS Content API** lets anything send finished articles to your site from anywhere: your own app or script, a desktop editor, another website, an automation tool (n8n, Make…) or an AI assistant. It uploads images, creates drafts with categories, tags, slug and SEO fields, and — when you allow it — publishes them. A writer can draft an article on their own computer and post it with a single request. Nothing is tool-specific: anything that can send an HTTPS request, or connect to a remote MCP server, can use it.

The site calling an AI provider itself is a separate module: see [AI Services](ai-services.html).

All examples use `https://docs.ironcms.com`. Replace it with your site's address **exactly as configured** (scheme, `www` or not, and port must match).

## What do you want to do?

```cards
fa-robot | Send articles with my AI assistant | Connect the site as a tool to an MCP-capable assistant. | #step-by-step-connecting-an-mcp-client
fa-code | Send from my own code or script | Upload images, create drafts and publish with the REST API. | #quick-start
fa-diagram-project | Use an automation tool such as n8n or Make | Create drafts with one HTTP request step. | #step-by-step-creating-a-draft-with-n8n
fa-shield-halved | Have AI review comments and SEO | Use the AI Services module for that. | ai-services.html
```

If a term is unclear, start with [Key concepts](#key-concepts); if something fails, see [Common problems](#common-problems).

## Key concepts

| Term | Meaning |
|---|---|
| Integration and token | The connection you open in the panel for each app or person. It gives you a secret token starting with `ica_`, which the app sends with every request. |
| Permission (scope) | What the token may do: read, write drafts, upload images, publish. Grant only what is needed. |
| Draft | Every article sent through the API starts as a private draft; it stays off the site until you, or an app allowed to publish, publishes it. |
| Slug | The short name in the article's address, for example `/our-new-product`. Generated from the title when not given. |
| Idempotency-Key | A unique label added to every write request. If the connection drops and you resend with the same label, the article is not created twice. |
| Version, ETag, If-Match | Every draft has a version number. When updating you send the version you have in `If-Match`; if someone changed it meanwhile, nothing is overwritten. |
| MCP | Model Context Protocol. A common language that lets AI assistants use external tools, so an assistant can send articles without code. |
| OAuth | A way for an app to connect after you approve it in the panel, without typing the token by hand. Some MCP clients use it. |

## Quick start

1. In the admin panel open **Modules** and make sure **Blog** and **Content API** are enabled.
2. Open **Content API → New integration**, give it a name (for example "Desktop article editor"), tick the permissions you need, choose how long the token stays valid, confirm with your password and create it.
3. Copy the token that starts with `ica_`. It is shown **once**. Store it in your app's secret settings (for example the environment variable `CONTENT_API_TOKEN`). Never paste it anywhere others can read it, such as a chat, an email or a shared document.
4. Test it:

```bash
export CONTENT_API_TOKEN='ica_...'
BASE='https://docs.ironcms.com/api/content/v1'
curl -s "$BASE/me" -H "Authorization: Bearer $CONTENT_API_TOKEN"
# {"data":{"id":"…","name":"Desktop article editor","scopes":["posts:read","posts:write","media:write","posts:autopublish"]}}
```

5. Typical flow for one article:

```text
GET  /taxonomies             → default language, category ids, limits
POST /media                  → upload or import each image, keep id + url
POST /posts                  → create a private draft
POST /posts/{id}/publish {}  → publish (requires posts:autopublish)
```

Without `posts:autopublish` the draft waits in **Admin → Content API → Approval queue**, where you approve and publish it with one click.

## Step by step: connecting an MCP client

1. In the panel create an integration under **Content API ▸ New integration**. Tick only the permissions you need, choose the lifetime and copy the token.
2. In your assistant's or MCP client's settings, open the section for adding a remote MCP server (connector).
3. Enter `https://docs.ironcms.com/api/content/v1/mcp` as the server address (with your own site address).
4. Authentication:
   - If the client lets you add headers, set `Authorization` to `Bearer ica_…`.
   - If the client connects with OAuth, it sends you to your site's approval screen, where you pick the integration and approve the permissions.
5. Try it: ask the assistant to "list the categories on the site". If it answers, the connection works.

> Screenshot: creating an integration in the panel (to be added).

Details: [MCP server](#mcp-server-for-mcp-capable-clients), [OAuth 2.1 for MCP connectors](#oauth-2-1-for-mcp-connectors).

## Step by step: creating a draft with n8n

1. Open **Credentials ▸ Add credential ▸ Header Auth**. Set *Name* to `Authorization` and *Value* to `Bearer ica_…`.
2. Add an **HTTP Request** node to the workflow:
   - Method `POST`, URL `https://docs.ironcms.com/api/content/v1/posts`
   - Authentication: *Generic Credential Type ▸ Header Auth* with the credential above
   - Send Headers: `Idempotency-Key` = a unique value per article (for example the source record's ID)
   - Send Body: JSON; for the fields see [Article fields](#article-fields)
3. Run the node. Keep `data.id` and the version from the response for later steps.
4. If the integration has `posts:autopublish`, add a second HTTP Request node that sends `{}` to `POST …/posts/{{id}}/publish`; otherwise the draft waits for your approval in the panel.

In Make and similar tools use the HTTP module with the same settings.

> Screenshot: n8n HTTP Request node settings (to be added).

## Authentication

### Integration tokens

Every request needs this header:

```http
Authorization: Bearer ica_<64 hexadecimal characters>
```

- Tokens are created in **Admin → Content API**. Creating, rotating and revoking requires the administrator's password.
- You choose the lifetime when you create the integration: **30, 90 (default), 180 or 365 days**, a **custom last day** (up to one year ahead; the token works until the end of that day) or **Never** (valid until rotated or revoked). The panel shows the expiry date next to each integration.
- **Manage → Replace credential** issues a new token, lets you choose a new lifetime and immediately invalidates the old token together with any pending approvals. **Revoke access** is permanent.
- OAuth access tokens issued to MCP connectors always last one hour; their refresh grants never outlive the integration (and last at most one year for a non-expiring one, renewed on use).
- Tokens are stored only as SHA-256 hashes and are bound to the site address. If the site address changes, every request returns `503 site_changed`; re-activate the module and create new integrations.
- Articles created by an integration are authored by the administrator who created it. That account must stay active.
- If you think a token leaked, revoke it in the panel immediately.

### Permissions (scopes)

| Scope | Allows |
|---|---|
| `posts:read` | Read categories/tags/languages (`/taxonomies`), the OpenAPI contract and the integration's own drafts |
| `posts:write` | Create and update private drafts. Never publishes |
| `media:write` | Upload images or let the site download them from a URL. Images stay private until their article is published |
| `posts:autopublish` | **Direct publishing**: `POST /posts/{id}/publish` with `{}` publishes the current version immediately. Give it only to tools you trust; the approval you give inside the AI tool counts as final |
| `posts:publish` | Two-step flow: the tool may publish only a version an administrator approved in the panel (`approval_id`) |

A recommended set for an AI writer is `posts:read`, `posts:write`, `media:write` and, if you want hands-free publishing, `posts:autopublish`.

### OAuth 2.1 for MCP connectors

Some MCP clients (chat apps with "connectors") cannot store a static token and use OAuth instead. The site supports it out of the box:

| Purpose | Address |
|---|---|
| Protected resource metadata | `/.well-known/oauth-protected-resource/api/content/v1/mcp` |
| Authorization server metadata | `/.well-known/oauth-authorization-server/api/content/v1/oauth` |
| Dynamic client registration | `POST /api/content/v1/oauth/register` |
| Token endpoint | `POST /api/content/v1/oauth/token` |
| Consent screen (administrator) | `{admin}/content-api/oauth/authorize` |

Rules: public clients only (authorization code + **S256 PKCE**), 1–3 exact `https://` redirect addresses (no localhost), access tokens live for 1 hour and can be refreshed. The administrator picks an existing integration on the consent screen; the connector receives at most that integration's permissions. `posts:publish` and `posts:autopublish` are never granted implicitly — they must be ticked explicitly.

## Request rules

| Rule | Detail |
|---|---|
| Base URL | `https://docs.ironcms.com/api/content/v1` |
| HTTPS | Required in production (`403 https_required`) |
| Host / Origin | Must equal the configured site address; a browser `Origin` header from another site is rejected (`403 invalid_origin`) |
| Body | One UTF-8 JSON object, `Content-Type: application/json`, max 1,000,000 bytes (MCP: 7,500,000), max nesting depth 32 |
| Idempotency | Every write (`POST`, `PATCH`) needs an [`Idempotency-Key`](#key-concepts): 8–128 characters from `A–Z a–z 0–9 . _ : -`. Re-sending the same key with the same body returns the stored result (kept 7 days) and never duplicates anything. The same key with a different body returns `409 idempotency_conflict` |
| Versions | `GET`/`POST`/`PATCH` on a draft return `ETag: "<version>"`. `PATCH` requires `If-Match: "<version>"` |
| Caching | All responses are `Cache-Control: no-store` |

Response envelope:

```json
{"data": { … }}
{"error": {"code": "invalid_slug", "message": "Slugs use lowercase letters…", "details": { … }}}
```

Branch on `error.code`, never on the message text.

## Endpoints

| Method | Path | Scope | Description |
|---|---|---|---|
| GET | `/me` | any valid token | Integration id, name and scopes |
| GET | `/taxonomies` | `posts:read` | Default and active languages, categories, tags, limits, capabilities |
| GET | `/schema` | `posts:read` | OpenAPI 3.1 contract |
| POST | `/media` | `media:write` | Upload an image (multipart) or import one from a URL (JSON) |
| POST | `/posts` | `posts:write` | Create a private draft (201) |
| GET | `/posts/{id}` | `posts:read` | Read a draft: version, content, `blog_post_id`, `approval_id`, `approval_url` |
| PATCH | `/posts/{id}` | `posts:write` | Partially update a draft (`If-Match` required) |
| POST | `/posts/{id}/publish` | `posts:autopublish` | Body `{}` → publish now, or at `publish_at` |
| POST | `/posts/{id}/publish` | `posts:publish` | Body `{"approval_id":"…"}` → publish the version approved in the panel |
| POST | `/posts/{id}/schedule` | same as `/publish` | Does the same as `/publish`. If the draft has a future `publish_at`, the new post goes live at that time |
| POST | `/mcp` | per tool | MCP endpoint (JSON-RPC 2.0) |

All `{id}` values are 32-character lowercase hexadecimal strings.

### GET /taxonomies

```json
{"data": {
  "default_locale": "en",
  "active_locales": ["en", "tr"],
  "capabilities": {"schedule_new_posts": true, "schedule_live_updates": false},
  "limits": {"article_bytes": 60000, "translation_bytes": 55000, "image_bytes": 5242880},
  "categories": [{"id": 3, "name": "Guides", "slug": "guides"}],
  "tags": [{"id": 7, "name": "tyres", "slug": "tyres"}]
}}
```

Always call it first: `locale` must equal `default_locale`, and `category_ids` must come from this list.

## Article fields

`POST /posts` creates a draft; `PATCH /posts/{id}` accepts the same fields, all optional, and merges them into the draft. Unknown fields are rejected (`422 unknown_field`).

| Field | Type | Required | Rules |
|---|---|---|---|
| `title` | string | ✓ | 1–255 characters |
| `content_html` | string | ✓ | Article HTML, at most **60,000 bytes** after sanitising. See *Allowed HTML* |
| `locale` | string | ✓ (create) | Must be the site's `default_locale` (`422 invalid_locale` otherwise) |
| `slug` | string | | URL slug, ≤100 characters, lowercase letters, digits and single hyphens (`winter-tyre-guide`). Omitted → generated from the title (Turkish characters are transliterated, `-2`, `-3` added if taken). An explicit slug that is taken returns `409 slug_taken`. Locked once the article is live (`409 slug_locked`) |
| `excerpt` | string | | Summary, ≤5,000 characters |
| `is_news` | boolean | | `true` marks the post as news. Default `false` |
| `category_ids` | integer[] | | ≤20 existing category ids from `/taxonomies` |
| `tags` | string[] | | ≤20 tag names, each ≤100 characters. New names are created automatically |
| `featured_media_id` | string \| null | | Cover image: the `id` returned by `/media` |
| `media_ids` | string[] | | ≤20 ids of every image used in the article (cover included is fine) |
| `seo.title` | string | | Meta title, ≤255 (recommended ≤60) |
| `seo.description` | string | | Meta description, ≤255 (recommended 120–155) |
| `seo.keywords` | string | | Focus keywords, comma separated, ≤255 |
| `external_id` | string | | Your stable source id (file name, CMS id…), ≤150. Immutable. A second create with the same value returns `409 duplicate_external_id` with the existing draft in `details.id` |
| `translations` | object | | `{"tr": {"title", "slug", "content_html", "excerpt", "seo"}}` — only real translations into **active** site languages other than the default, ≤10 languages, ≤55,000 bytes in total. Each needs its own `title` and `content_html` |
| `publish_at` | string \| null | | ISO 8601 with timezone, e.g. `2026-12-01T09:00:00+03:00` or `…Z`. A future time schedules a **new** article. A live article cannot be re-scheduled (`409 live_update_schedule_unsupported`) |

Draft response (`POST`, `GET`, `PATCH`):

```json
{"data": {
  "id": "9f1c…32 hex…",
  "version": 1,
  "content": { "title": "…", "slug": "…", "locale": "en", "seo": {"title": "…", "description": "…", "keywords": "…"}, "…": "…" },
  "blog_post_id": null,
  "approval_id": null,
  "approval_url": "https://docs.ironcms.com/admin/content-api/drafts/9f1c…"
}}
```

`blog_post_id` is filled once the article exists in the blog. `approval_url` is the administrator's preview page.

### Allowed HTML

- The HTML passes through the site's sanitiser (HTML Purifier). Allowed tags: `p`, `br`, `h1`–`h6`, `strong`, `b`, `em`, `i`, `u`, `s`, `mark`, `span`, `div`, `ul`, `ol`, `li`, `blockquote`, `aside`, `figure`, `figcaption`, `table`, `thead`, `tbody`, `tr`, `th`, `td`, `pre`, `code`, `hr`, `a[href|title|target]`, `img[src|alt|width|height]`. A `class` attribute is kept on most block tags. Everything else — `style`, event handlers, scripts, `<form>`, unknown attributes — is silently removed.
- `target="_blank"` links automatically get `rel="noopener"`.
- `<iframe>`, `<object>`, `<embed>`, `<video>`, `<audio>`, `<source>`, `<svg>` and `<math>` are rejected (`422 unsupported_embed`).
- Every `<img src>` must be **exactly** the `url` of an image this integration uploaded, and that image must be listed in `media_ids`; `srcset` is not allowed (`422 unowned_image`). To use an image from another website, import it through `/media` first.
- Do not add an `<h1>`; the title is rendered by the theme.

## Images

`POST /media` (scope `media:write`) accepts either a file upload or an image address.

| Rule | Value |
|---|---|
| Formats | Genuine JPEG, PNG or WebP (content is checked, not just the extension) |
| Size | ≤ 5 MB before and after re-encoding |
| Dimensions | ≤ 24 megapixels, longest side ≤ 12,000 px |
| Processing | Every image is decoded and re-encoded; EXIF/metadata and hidden payloads are removed |
| Storage | Media library folder `content-api`, file name built from `filename` (else `title`, else `alt`) plus an 8-character suffix, e.g. `winter-tyre-pressure-3f9a1c2b.jpg` |
| Visibility | Private until an article that uses it is published |
| Rate limits | 20 per minute, 300 per day per integration |
| Quota | 512 MB per integration, 1 GB for all integrations (`403 storage_quota`) |

Metadata fields:

| Field | Required | Rules |
|---|---|---|
| `alt` | ✓ | What the image shows, ≤500 characters (`422 alt_required`) |
| `title` | | Image title, ≤140 |
| `caption` | | Caption, ≤500 |
| `credit` | | Source / photographer, ≤255 |
| `filename` | | SEO file name without extension, ≤120 (slugified to ≤80) |

### Upload a file (multipart)

```bash
curl -s -X POST "$BASE/media" \
  -H "Authorization: Bearer $CONTENT_API_TOKEN" \
  -H "Idempotency-Key: img-2026-11-23-cover" \
  -F "file=@cover.jpg" \
  -F "alt=Mechanic checking winter tyre pressure" \
  -F "title=Winter tyre pressure" \
  -F "filename=winter-tyre-pressure" \
  -F "credit=Studio Example"
```

### Import from a URL (JSON)

```bash
curl -s -X POST "$BASE/media" \
  -H "Authorization: Bearer $CONTENT_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: img-2026-11-23-002" \
  -d '{"url":"https://images.example.org/tyre.jpg","alt":"Tyre tread close-up","caption":"Minimum tread depth is 4 mm","filename":"winter-tyre-tread"}'
```

Response (201):

```json
{"data": {"id": "<MEDIA_ID>", "url": "https://docs.ironcms.com/media/content-api/winter-tyre-pressure-3f9a1c2b.jpg", "width": 1600, "height": 900}}
```

URL imports also return `source_url`. Download rules: `http`/`https` only, ports 80/443, no user:password in the URL, public internet addresses only (local, private and reserved networks are refused with `422 blocked_url`), at most 3 redirects, 5 s to connect, 20 s in total, the server must return a real JPEG/PNG/WebP. If a site blocks downloads (`422 fetch_failed`), download the file yourself and upload it.

### Cover image, alt text and captions

- **Cover:** put the image `id` in `featured_media_id`. The cover does not have to appear in `content_html`.
- **In-article images:** use the returned `url` in `<img src="…" alt="…">`, and add the `id` to `media_ids`.
- **Captions:** wrap the image: `<figure><img src="…" alt="…"><figcaption>Caption</figcaption></figure>`. The `caption`/`credit` fields are stored in the media library.
- Alt text describes the image for screen readers and image search; do not stuff keywords.

## Drafts, updates and publishing

### Create a draft

```bash
curl -s -X POST "$BASE/posts" \
  -H "Authorization: Bearer $CONTENT_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: post-winter-tyres-create" \
  -d '{
    "external_id": "word/winter-tyres.docx",
    "locale": "en",
    "title": "Winter Tyres: The Complete Guide",
    "slug": "winter-tyres-guide",
    "excerpt": "When to switch, how to check tread depth and what pressure to use.",
    "content_html": "<p>Intro…</p><h2>When to switch</h2><p>…</p><figure><img src=\"https://docs.ironcms.com/media/content-api/winter-tyre-pressure-3f9a1c2b.jpg\" alt=\"Mechanic checking winter tyre pressure\"><figcaption>Check pressure when tyres are cold.</figcaption></figure>",
    "featured_media_id": "<MEDIA_ID>",
    "media_ids": ["<MEDIA_ID>"],
    "category_ids": [3],
    "tags": ["winter tyres", "car care"],
    "is_news": false,
    "seo": {"title": "Winter Tyres Guide: When to Switch", "description": "When to fit winter tyres, how to check tread depth and the right pressure for cold weather.", "keywords": "winter tyres, tyre pressure"}
  }'
```

### Update a draft

```bash
curl -s -X PATCH "$BASE/posts/<DRAFT_ID>" \
  -H "Authorization: Bearer $CONTENT_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H 'If-Match: "1"' \
  -H "Idempotency-Key: post-winter-tyres-edit-1" \
  -d '{"title": "Winter Tyres: The 2026 Guide"}'
```

If someone else changed the draft you get `412 version_conflict`: `GET` it again and retry with the new version.

### Publish

**With `posts:autopublish`** — publish the current version:

```bash
curl -s -X POST "$BASE/posts/<DRAFT_ID>/publish" \
  -H "Authorization: Bearer $CONTENT_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: post-winter-tyres-publish" \
  -d '{}'
# {"data":{"id":"<DRAFT_ID>","blog_post_id":42,"status":"published"}}
```

`status` is `scheduled` when `publish_at` is in the future. Repeating the call is safe. Direct publishing is limited to 20 per hour.

**Without it** — the draft appears in **Admin → Content API → Approval queue**. Tick drafts and choose **Approve and publish selected**, or open one draft's preview and press **Approve and publish**. With `posts:publish` the tool can instead publish a panel approval itself: the approval id is returned by `GET /posts/{id}` (`approval_id`), is single-use and expires after 15 minutes.

```bash
curl -s -X POST "$BASE/posts/<DRAFT_ID>/publish" \
  -H "Authorization: Bearer $CONTENT_API_TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: post-winter-tyres-publish-approved" \
  -d '{"approval_id":"<APPROVAL_ID>"}'
```

Good to know:

- Images become public when their article is published.
- `PATCH` on an already published article only stages the change. The live article changes when you publish again.
- If someone edited the article in the admin panel, the API will not overwrite it (`409 live_content_changed`).
- If the optional **Blog Workflow** module is active, the publication is recorded as approved in the editorial workflow; an editorial policy can still refuse it (`409 publication_denied`).

## MCP server (for MCP-capable clients)

Any client that speaks the Model Context Protocol — AI assistants included — can use the same operations as tools without writing code.

| Setting | Value |
|---|---|
| URL | `https://docs.ironcms.com/api/content/v1/mcp` |
| Transport | Streamable HTTP, stateless JSON responses (no SSE stream; `GET` returns 405) |
| Protocol versions | `2025-06-18`, `2025-11-25` (send `MCP-Protocol-Version` after `initialize`) |
| Headers | `Authorization: Bearer ica_…`, `Accept: application/json, text/event-stream`, `Content-Type: application/json` |

Tools (only those allowed by the token's scopes are listed):

| Tool | Scope | Purpose |
|---|---|---|
| `list_taxonomies` | `posts:read` | Languages, categories, tags, limits |
| `read_post` | `posts:read` | Read a draft and its version |
| `create_post` | `posts:write` | `{content, idempotency_key}` — create a private draft |
| `update_post` | `posts:write` | `{id, version, content, idempotency_key}` |
| `import_image_from_url` | `media:write` | `{url, alt, title?, caption?, credit?, filename?, idempotency_key}` |
| `upload_image` | `media:write` | `{base64, mime, alt, …, idempotency_key}` (≤5 MB decoded) |
| `publish_now` | `posts:autopublish` | `{id, idempotency_key}` — publish the current version |
| `request_publication` | `posts:publish` | Approval state and preview link |
| `publish_post` | `posts:publish` | `{id, approval_id, idempotency_key}` |

`content` uses exactly the article fields above. Tool failures return `isError: true` with `structuredContent.error.code` (same codes as REST).

Example remote-MCP tool definition (field names differ per provider; check your provider's current documentation):

```json
{
  "type": "mcp",
  "server_label": "blog",
  "server_url": "https://docs.ironcms.com/api/content/v1/mcp",
  "authorization": "<CONTENT_API_TOKEN>"
}
```

Some providers expect `"headers": {"Authorization": "Bearer <token>"}` instead of `authorization`. Consumer chat subscriptions often cannot call private APIs with your own key; use the provider's developer API, an automation tool, or the script below.

## OpenAPI contract

- `GET /schema` returns the OpenAPI 3.1 document for your site.
- **Admin → Content API → OpenAPI file** downloads it as `content-api-openapi.json`.
- Give it to tools that import OpenAPI (custom GPT actions, Postman, n8n, code generators).

## Rate limits

| Limit | Value |
|---|---|
| Per IP address | 120 requests / minute |
| Per integration | 60 requests / minute, of which 20 writes |
| Drafts | 30 / hour, 200 / day |
| Images | 20 / minute, 300 / day |
| Direct publishing | 20 / hour |
| Failed authentication | after 20 invalid tokens from one IP, further invalid attempts get `429` for 10 minutes (valid tokens keep working) |

A `429 rate_limit` response carries `Retry-After: 60`. Wait and retry with the **same** `Idempotency-Key`.

## Common problems

For each problem, find the cause first, then the fix. For every code see [Error codes](#error-codes).

### 401 invalid_token

**Why it happens:** The token was copied wrongly, has expired, was replaced or revoked. **What to do:** Check the integration's state and expiry date in the panel; if needed, use **Replace credential** and enter the new token in the app. Make sure the header reads `Authorization: Bearer ica_…`.

### 403 invalid_origin

**Why it happens:** The request goes to an address that differs from the site's configured one: with or without `www`, `http` instead of `https`, or a different port. **What to do:** Make the base address in your app exactly match the REST base URL shown in the panel.

### 422 unowned_image

**Why it happens:** An `<img>` address in the article HTML was not uploaded through `/media`, or is missing from `media_ids`. **What to do:** Upload the image with `POST /media` first and use the address it returns.

### 409 slug_taken

**Why it happens:** The slug you sent is used by another post. **What to do:** Send a different slug, or leave it empty so it is generated from the title.

### 412 version_conflict

**Why it happens:** The draft changed after you read it; your version is out of date. **What to do:** Read the draft again with `GET` and retry with the new version in `If-Match`.

### 429 rate_limit

**Why it happens:** Too many requests in a short time. **What to do:** Wait for the time in the `Retry-After` header and retry with the same `Idempotency-Key`. For the limits see [Rate limits](#rate-limits).

## Error codes

Codes are grouped by topic. Use the filter box below to find a code quickly.

### Authentication and permissions

| HTTP | Code | Meaning / fix |
|---|---|---|
| 401 | `invalid_token` | Token wrong, expired, rotated or revoked |
| 401 | `invalid_client` | Integration revoked or expired |
| 403 | `insufficient_scope` | The integration lacks this permission |
| 403 | `invalid_origin` | Host/Origin differs from the site address (check `www`, port) |
| 403 | `https_required` | Use `https://` |
| 404 | `api_disabled` | Content API or Blog module is disabled |

### Request format and content

| HTTP | Code | Meaning / fix |
|---|---|---|
| 400 | `invalid_json` | Body is not a single valid UTF-8 JSON object |
| 400 | `idempotency_required` | `Idempotency-Key` missing or invalid (8–128 chars) |
| 404 | `not_found` | Draft/image does not exist or belongs to another integration |
| 409 | `idempotency_conflict` | Key reused with a different body; use a new key |
| 409 | `conflict` | The resource changed meanwhile; read it again and retry |
| 412 | `version_conflict` | Draft changed; `GET` and retry with the new version |
| 413 | `body_too_large` | JSON body over the limit |
| 415 | `json_required` / `multipart_required` | Wrong `Content-Type` |
| 422 | `unknown_field` | Field not in the contract |
| 422 | `invalid_content` | Title or text content missing, bad `is_news` |
| 422 | `locale_required` / `invalid_locale` | Send the site's default language |
| 422 | `invalid_slug` | Lowercase letters, digits, single hyphens only |
| 422 | `invalid_text` | Not UTF-8, control characters, or over the field limit |
| 422 | `host_content_limit` | Article > 60 KB, translations > 55 KB or SEO description > 255 |
| 422 | `invalid_list` / `invalid_category` / `invalid_tag` | List too long, unknown category, empty tag |
| 422 | `invalid_seo` | Only `title`, `description`, `keywords` |
| 422 | `invalid_translation` | Inactive language, missing title/content, or default language |
| 422 | `invalid_date` | `publish_at` without timezone or invalid |
| 422 | `invalid_id` | The draft or image ID is malformed |
| 422 | `immutable_external_id` | `external_id` cannot be changed after the draft was created |
| 428 | `version_required` | `PATCH` without `If-Match: "<version>"` |
| 429 | `rate_limit` | See *Rate limits* |

### Images

| HTTP | Code | Meaning / fix |
|---|---|---|
| 403 | `storage_quota` | Media quota reached |
| 409 | `media_unavailable` | An attached image was removed |
| 413 | `image_too_large` / `image_dimensions` | Over 5 MB or over 24 MP / 12,000 px |
| 415 | `invalid_image` | Not a genuine JPEG/PNG/WebP |
| 422 | `unowned_image` | `<img>` not uploaded through `/media` or missing from `media_ids` |
| 422 | `unsupported_embed` | iframe/video/audio/svg/embed not accepted |
| 422 | `alt_required` / `invalid_metadata` | Alt text missing / unknown image field |
| 422 | `invalid_url` / `blocked_url` / `unresolvable_url` / `too_many_redirects` / `fetch_failed` | Image URL unusable; upload the file instead |
| 422 | `invalid_file` | No valid image file in the multipart `file` field |
| 503 | `fetch_unavailable` | This server cannot download remote images; upload the file instead |

### Drafts and publishing

| HTTP | Code | Meaning / fix |
|---|---|---|
| 409 | `duplicate_external_id` | Source already has a draft; `PATCH` the id in `details.id` |
| 409 | `slug_taken` | Explicit slug already used |
| 409 | `slug_locked` | A live article's slug can only be changed in the panel |
| 409 | `live_content_changed` | Article edited in the panel; API will not overwrite |
| 409 | `live_update_schedule_unsupported` | A live article cannot be moved to a future date |
| 409 | `approval_required` / `approval_stale` | Panel approval missing, used, expired or outdated |
| 409 | `publication_denied` | Editorial policy refused publication |
| 409 | `author_unavailable` | The integration's author account is inactive |
| 409 | `post_unavailable` | The linked Blog post was deleted or can no longer be edited |
| 422 | `invalid_approval` | `{}` sent without `posts:autopublish`, or malformed `approval_id` |

### OAuth and MCP

| HTTP | Code | Meaning / fix |
|---|---|---|
| 400 | `unsupported_protocol` | MCP: unsupported or missing `MCP-Protocol-Version` |
| 400 | `invalid_request` / `invalid_grant` / `invalid_scope` | OAuth: malformed request, expired or reused code/refresh grant, or scopes that were not granted |
| 400 | `invalid_client_metadata` / `invalid_redirect_uri` | OAuth client registration: only public authorization-code clients with S256 PKCE and one to three exact HTTPS redirect addresses |
| 405 | `no_stream` | MCP `GET`; use `POST` |
| 406 | `invalid_accept` | MCP: `Accept` must include `application/json` and `text/event-stream` |
| 413 | `request_too_large` | OAuth request over its size limit |
| 415 | `invalid_content_type` | OAuth endpoints: send JSON or form-urlencoded data |
| 422 | `unknown_tool` | MCP: the tool name does not exist |
| 429 | `registration_limit` | OAuth client registration capacity reached; ask the site owner |

### Server

| HTTP | Code | Meaning / fix |
|---|---|---|
| 503 | `site_changed` / `not_activated` | Re-activate the module; create new integrations |
| 503 | `invalid_site` / `unsupported_database` | Site address or database setup is unsuitable; the site owner must fix the configuration |
| 503 | `unavailable` / `write_failed` / `storage_unavailable` | Temporary server problem; retry later with the same key |

## Example script (Python)

```python
import os, requests

BASE = "https://docs.ironcms.com/api/content/v1"
H = {"Authorization": f"Bearer {os.environ['CONTENT_API_TOKEN']}"}

tax = requests.get(f"{BASE}/taxonomies", headers=H).json()["data"]

with open("cover.jpg", "rb") as f:
    img = requests.post(f"{BASE}/media", headers={**H, "Idempotency-Key": "winter-tyres-cover"},
                        files={"file": f}, data={"alt": "Mechanic checking tyre pressure",
                                                 "filename": "winter-tyre-pressure"}).json()["data"]

post = requests.post(f"{BASE}/posts", headers={**H, "Idempotency-Key": "winter-tyres-create"}, json={
    "external_id": "winter-tyres.docx", "locale": tax["default_locale"],
    "title": "Winter Tyres: The Complete Guide", "slug": "winter-tyres-guide",
    "content_html": f'<p>Intro…</p><img src="{img["url"]}" alt="Mechanic checking tyre pressure">',
    "featured_media_id": img["id"], "media_ids": [img["id"]],
    "category_ids": [tax["categories"][0]["id"]], "tags": ["winter tyres"],
    "seo": {"title": "Winter Tyres Guide", "description": "When to fit winter tyres and how to check them."},
}).json()["data"]

done = requests.post(f"{BASE}/posts/{post['id']}/publish",
                     headers={**H, "Idempotency-Key": "winter-tyres-publish"}, json={}).json()
print(done)
```

## Ready-to-use AI prompts

These are optional examples for AI assistants; the API works the same without them. Give the assistant the token through its secret/tool settings, never in the prompt itself.

### 1. Word document → published article

```text
You are my blog publishing assistant. Use the "blog" tools (Content API).
1. Call list_taxonomies. Use default_locale as locale and pick the best matching category id.
2. Convert the attached document to clean HTML without changing its meaning: <h2>/<h3> for headings,
   <p>, <ul>/<ol>, <blockquote>, <table>. No <h1>, no inline styles, no scripts, iframes or videos.
3. Write a 2-sentence excerpt, an SEO title (max 60 characters), an SEO description (120–155
   characters), 2–4 focus keywords and a short lowercase ASCII slug with hyphens.
4. For every image: if it is a file, call upload_image; if it is a web address, call
   import_image_from_url. Give each one an accurate alt text, a title and a filename related to the
   article. Use the returned url in <img src>, put every id in media_ids, and the best one in
   featured_media_id.
5. Call create_post with external_id = the document file name and
   idempotency_key = file name + today's date.
6. Show me the title, slug, SEO fields and the first paragraphs. When I answer "publish", call
   publish_now and give me the article link. If a tool returns an error, read error.code, fix the
   cause and retry with the same idempotency_key.
```

### 2. Draft only (human review on the site)

```text
Prepare the attached article exactly as described in my publishing rules, then call create_post only.
Never call publish tools. Reply with the draft id and approval_url so I can review it in the panel.
```

### 3. Research and write a new article

```text
Write an original 1,200-word article in {language} about "{topic}" for my blog. Use facts you can cite,
add a short "Sources" list at the end with links. Find 1–3 freely licensed images and import them with
import_image_from_url (credit the author in credit). Follow my HTML and SEO rules, create a draft and
stop for my approval before publishing.
```

### 4. Update an existing draft

```text
Read draft {id} with read_post. Fix spelling, improve the SEO description (120–155 characters) and add
an FAQ section with 3 questions as <h2>/<h3>/<p>. Call update_post with the version you read. If you
get version_conflict, read it again and reapply the change.
```

### 5. Add a translation

```text
Read draft {id}. If list_taxonomies shows "tr" in active_locales, translate the title, excerpt, content
and SEO fields into natural Turkish and send them with update_post as translations.tr, with its own
Turkish slug. Keep all <img> tags and URLs unchanged.
```

## Security checklist

- Create one integration per app, script or person, with the fewest permissions it needs.
- Keep tokens in secret storage. Prefer a dated lifetime; give a non-expiring token only to apps you trust and replace it from time to time. Revoke immediately if leaked.
- Give `posts:autopublish` only to apps whose output you approve before they publish.
- Use HTTPS and the exact site address.
- Review **Admin → Content API** regularly: it lists integrations, drafts and the approval queue.
