# Integration API — complete guide > For any team with a blog or CMS (such as Sky CMS) that wants articles from the content > system. The blog sends a **topic and languages**; the system does the research, planning, > writing, SEO, images, translation and quality control, and reports **every step as it > happens** by signed webhook. When the article is ready, **everything about it** (preview, > text, SEO, images, sources, links, structured data, quality, versions, runs) reaches the > blog so its editors can read, edit, approve or reject it in their own panel. --- ## Contents 1. [Overview](#overview) 2. [Quick start](#quick-start) 3. [Authentication and limits](#authentication-and-limits) 4. [Creating a request](#creating-a-request) 5. [Translating your own posts](#translating-your-own-posts) and [pictures for your own posts](#pictures-for-your-own-posts) 6. [Statuses](#statuses) 7. [Step by step: from analysis to delivery](#step-by-step-from-analysis-to-delivery) 8. [Webhooks: signing, retries, response](#webhooks-signing-retries-response) 9. [Every event, with examples](#every-event-with-examples) 10. [The full article record (`details`)](#the-full-article-record-details) 11. [Review: approve, reject, request changes, edit](#review-approve-reject-request-changes-edit) 12. [A new version of one image](#a-new-version-of-one-image) 13. [Without a webhook (pull)](#without-a-webhook-pull) 14. [Your search data: Search Console and Analytics](#your-search-data-search-console-and-analytics) 15. [Finding titles](#finding-titles) 16. [All endpoints](#all-endpoints) 17. [Errors](#errors) 18. [AI cost and usage](#ai-cost-and-usage) 19. [Building it into a blog panel, end to end](#building-it-into-a-blog-panel-end-to-end) --- ## Overview ``` Blog Content system │ POST /requests {title, languages, site} ──────▶ stored; one article per language │ ◀── 202 {id: 01k6…, articles: [art_…]} │ source article (one of your languages): │ ◀── article.stage_started (duplicate_check) duplicate check │ ◀── article.stage_completed (duplicate_check) │ ◀── article.stage_started / completed (research) research: sources, facts │ ◀── … (planning) plan: structure and keywords │ ◀── … (generation) writing │ ◀── … (seo) SEO: title, description, slug, schema │ ◀── … (images) images │ ◀── … (validation) quality control │ every other language: │ ◀── … (translation), … (validation) translation of that article + quality control │ │ ◀── article.review_required + details preview and full record │ POST /articles/{id}/approve | edit | revise | reject ──▶ │ ◀── article.completed + details approved version │ ── 200 {"url": "https://blog/…"} ──▶ recorded: published ``` - **One article, many languages.** Only the languages you ask for are written. With one language, the article is researched and written in it. With several, it is researched and written once in the language you choose as `source_language` (default: the first in `languages`), and that same article is **translated** into each other one: the same sections in the same order, the same sources, the same images. The source reports its own steps, and **every translation still waiting for it** gets the same steps with `on_source`, so no language sits silently "queued". Suggested display: a step bar per language (research, planning, writing, SEO, images, quality check; for a translation: the source's steps first, then translation and quality check), the running step with the time elapsed since `started_at`, and "next step waiting for a free writer" when the last event was a `stage_completed`. - **Each language** has its own id (`art_…`) and status; on translations `translated_from` is the source language. - **The blog decides.** With the key's review option, every article waits for the blog's decision; without it, only articles the quality check flags. The rest are delivered automatically. --- ## Quick start The content system team creates an API key (`cs_live_…`) and a webhook secret (`whsec_…`) **for each blog separately** and hands both to you once; they cannot be shown again, only replaced. Tell the team your blog's webhook URL so they can register it with the key. ### What you receive - **API key**: `cs_live_` + 40 characters. Send it as `Authorization: Bearer cs_live_…`. - **Webhook secret**: `whsec_` + 40 characters. Used to verify webhook signatures. - **Base URL**: the service address, `https://content.nx.plus`. CMSs like Sky CMS ask for this address and add `/api/public/v1` themselves; code that calls the API directly uses `https://content.nx.plus/api/public/v1`. - **Settings the team chose for your key** (read them any time with `GET /me`): webhook URL (none = pull mode), which events you receive (none = all), whether your blog approves every article (`require_review`, off by default), allowed languages (none = every active language), monthly AI token limit, articles per day and requests per minute (default 60). Keep the key and secret in environment variables or a secrets store, never in code or chats. `GET /` on the same address with `Accept: application/json` returns the service's addresses (no key needed): `{ "service": "…", "docs": "…/docs", "apis": { "integration": "…/api/public/v1" }, "integration_api_version": "2026-09-29" }`. ### First request ```bash curl -X POST https://content.nx.plus/api/public/v1/requests \ -H "Authorization: Bearer cs_live_…" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -d '{ "title": "Best time to visit Lisbon", "languages": ["fa", "en"], "site": { "url": "https://blog.example.com", "name": "Example Blog" }, "keywords": ["lisbon travel", "best time to visit lisbon"], "external_ref": "topic-123" }' ``` Response `202 Accepted` (the full request shape is under [All endpoints](#all-endpoints)): ```json { "data": { "id": "01k6c2t3b8x4n7q9r2s5t8v0wy", "external_ref": "topic-123", "status": "processing", "title": "Best time to visit Lisbon", "languages": ["fa", "en"], "site": { "name": "Example Blog", "url": "https://blog.example.com" }, "options": { "images": "all", "keywords": ["lisbon travel", "best time to visit lisbon"] }, "errors": [], "usage": { "input_tokens": 0, "output_tokens": 0, "total_tokens": 0, "images": 0, "cost_usd": 0 }, "articles": [ { "id": "art_01k6c2t3c1m5p8r2t6v9x3z7ab", "request_id": "01k6c2t3b8x4n7q9r2s5t8v0wy", "external_ref": "topic-123", "language": "en", "status": "processing", "stage": "queued", "title": "Best time to visit Lisbon", "error": null, "published_url": null, "translated_from": null, "quality": null, "images": "all", "usage": { "input_tokens": 0, "output_tokens": 0, "total_tokens": 0, "images": 0, "cost_usd": 0 }, "created_at": "2026-10-03T10:00:01+00:00", "updated_at": "2026-10-03T10:00:01+00:00" }, { "id": "art_01k6c2t3c9a2b4c6d8e0f2g4h6", "request_id": "01k6c2t3b8x4n7q9r2s5t8v0wy", "external_ref": "topic-123", "language": "fa", "status": "processing", "stage": "awaiting_source", "title": "Best time to visit Lisbon", "error": null, "published_url": null, "translated_from": "en", "quality": null, "images": "all", "usage": { "input_tokens": 0, "output_tokens": 0, "total_tokens": 0, "images": 0, "cost_usd": 0 }, "created_at": "2026-10-03T10:00:01+00:00", "updated_at": "2026-10-03T10:00:01+00:00" } ], "created_at": "2026-10-03T10:00:01+00:00" } } ``` **Ids:** a request id is a 26-character lowercase ULID with **no prefix**; an article id is `art_` + ULID; a webhook event id is `evt_` + ULID; and the `X-Request-Id` response header is `req_` + ULID (that last one identifies the HTTP call, not a content request). From this moment `article.stage_*` events reach the webhook. --- ## Authentication and limits ``` Authorization: Bearer cs_live_… ``` (or `X-Api-Key: cs_live_…`. The key is **not** accepted in the query string.) - **Server side only.** Keep the key and secret in server-side settings (encrypted); never in a browser, mobile app, code repository or log. - When the content system team rotates a key or secret, the previous value stops working immediately. - Every response has an `X-Request-Id` header; quote it to support when tracing a problem. - Requests and responses are JSON; send `Accept: application/json`, and for `POST`, `Content-Type: application/json`. Times are ISO 8601 with a time zone. - A missing or invalid key (or one without the `cs_live_` prefix) → `401 unauthorized`; a disabled key → `403 client_disabled`. A key only sees its own requests, articles and sites; another key's id answers `404 not_found`, exactly like an id that does not exist. - **Rate limit** per key (default 60 requests per minute, 60-second window): exceeding it → `429 rate_limited` with `Retry-After` (seconds), `X-RateLimit-Limit` and `X-RateLimit-Remaining: 0` (those two headers only appear on that 429 response). - **Daily article quota** and **monthly AI token limit** (both optional, on the key): exceeding them → `429` with `quota_exceeded` or `token_limit_reached` and `resets_at`. - **Monthly AI budget** in US dollars (optional, on the key): once this month's spend has reached it, nothing new starts (`429 budget_reached`); a new request or added languages whose estimate does not fit in what is left are refused (`429 budget_insufficient`, with `estimated_cost`). See [Monthly budget](#monthly-budget). - **Allowed languages** (optional): a language not allowed → `403 language_not_allowed`. - **Articles in progress per blog** (default 10; the content system team can change it at any time; `0` means no limit): each language is one article. An article is "in progress" while it is queued, waiting for its source (translations) or in a step. If a request would take the count above the limit, **no article is created** and the answer is `429 too_many_in_progress`: ```json { "error": { "code": "too_many_in_progress", "message": "This blog already has 8 article(s) being written; up to 10 can be written at once. Ask for at most 2 language(s) now, or wait for some to finish.", "in_progress": 8, "max_in_progress": 10, "available": 2 } } ``` There is no `Retry-After`: wait until some articles finish (`article.review_required`, `article.completed`, `article.failed` events) or ask for fewer languages. The limit and the current count are in `GET /me` → `client.max_in_progress` and `client.in_progress`; **the CMS should stop an oversized request before sending it** (see [Building it into a blog panel](#building-it-into-a-blog-panel-end-to-end)). - `GET /me`: the key's settings, quota, in-progress limit and **usage** (`usage.today|month|all_time`: articles, input/output/total tokens, images and **`cost_usd`**, the cost in dollars; details and estimates under [AI cost and usage](#ai-cost-and-usage)). `usage.month.articles` counts the articles the AI **actually wrote** this month (by the article's creation date, only those with at least one version; one cancelled before writing is not counted), including those removed on your side. An article brought back by asking for a topic again is not "new" and counts in its own month. Do not mix this number with your panel's counters: "articles" = cards in the topic tabs, "removed" = rows of the removed tab, each article **once** by `art_…` (an article may come again under a new request when a topic is asked for again). Show "new this month" and tokens separately from `usage.month`. **`GET /me`**, a full response: ```json { "client": { "name": "Example Blog", "key_prefix": "cs_live_a1B2", "default_site": { "name": "Example Blog", "url": "https://blog.example.com" }, "webhook": { "url": "https://blog.example.com/api/content-system/webhook", "signed": true, "events": ["article.stage_started", "article.stage_completed", "article.stage_failed", "article.review_required", "article.completed", "article.updated", "article.failed", "titles.found", "ping"] }, "require_review": true, "allowed_languages": null, "rate_limit_per_minute": 60, "daily_quota": null, "used_today": 3, "monthly_token_limit": 2000000, "monthly_budget_usd": 50, "max_in_progress": 10, "in_progress": 2 }, "usage": { "today": { "input_tokens": 41230, "output_tokens": 9120, "total_tokens": 50350, "images": 4, "articles": 1, "cost_usd": 1.0731 }, "month": { "input_tokens": 412300, "output_tokens": 91200, "total_tokens": 503500, "images": 40, "articles": 10, "cost_usd": 10.731 }, "all_time": { "input_tokens": 912300, "output_tokens": 191200, "total_tokens": 1103500, "images": 88, "articles": 22, "cost_usd": 23.5512 }, "currency": "USD", "pricing_configured": true }, "budget": { "monthly_usd": 50, "used_usd": 10.73, "remaining_usd": 39.27, "percent": 21, "resets_at": "2026-11-01T00:00:00+00:00" }, "estimates": { "currency": "USD", "article_text": 0.31, "translation": 0.05, "image": 0.25, "images_per_article": 4.0 }, "tools": { "translations": { "enabled": true }, "images": { "enabled": true, "quality": "medium", "per_day": 10, "used_today": 2, "left_today": 8 }, "image_versions": { "enabled": true, "per_image_per_day": 3 } }, "api_version": "2026-09-29" } ``` | Field | Meaning | |---|---| | `client.default_site` | The key's default site, or `null` (then `site.url` is required on every request) | | `client.webhook.url` | `null` means pull mode | | `client.webhook.signed` | Whether webhooks are signed (always `true` for keys issued by the content system) | | `client.webhook.events` | Events that are sent; all of them when none were chosen. `ping` is always sent | | `client.allowed_languages` | `null` = every active language | | `client.daily_quota` / `client.used_today` | Daily article quota (`null` = unlimited) and articles created today (since midnight, server time). Each language is one article; a request asking for more than `daily_quota - used_today` languages is refused whole. Check it in your form when a language is picked, not only after sending. | | `client.monthly_token_limit` | Token limit for the calendar month (`null` = unlimited) | | `client.monthly_budget_usd` | AI budget for the calendar month in USD (`null` = no budget) | | `budget` | Where this month's budget stands: `monthly_usd`, `used_usd`, `remaining_usd`, `percent`, `resets_at` (start of next month); `null` without a budget | | `client.max_in_progress` / `client.in_progress` | Limit of articles in progress (`0` = none) and the current count | | `usage.*` | The key's usage today, this month and in total; see [AI cost and usage](#ai-cost-and-usage) | | `estimates` | Cost estimates before sending | | `tools` | The tools for your own posts, set for your key by the content system team: `translations.enabled` (`POST /translations`), `images.enabled` with `quality`, `per_day`, `used_today`, `left_today` (`POST /images`), and `image_versions.enabled` with `per_image_per_day` (new versions of our articles' images, `…/images/{plan_id}/regenerate`). **Hide a tool that is off** (calling it answers `403 tool_disabled`); when one is on but today's limit is used up (`left_today: 0`), keep it visible and say so. Show what it costs (`estimates.translation`, `estimates.image`) and the budget before sending | | `api_version` | API version; the same as the webhook envelope's `api_version` | --- ## Creating a request ``` POST /api/public/v1/requests ``` | Field | Type | Required | Description | |---|---|---|---| | `title` | string | **yes** | Topic or proposed title (3 to 500 characters), in any language. | | `languages` | array of language codes | **yes** | e.g. `["fa","en"]`; list from `GET /languages`. At most 20. | | `source_language` | language code | with several languages | The language the article is written in; every other language is translated from it. Must be one of `languages` (else `422`); default: the first of `languages`. Ignored with one language. Comes back in `options.source_language`. | | `site.url` | URL | if the key has no default site | The target blog's address; a new site is registered automatically. | | `site.name` / `site.description` / `site.audience` | string | no | About the blog (max 255 / 5000 / 2000); shapes tone and context. | | `content_type` | string | no | `guide`, `how_to`, `comparison`, `listicle`, `explainer`, `review_roundup`, `definition`, `news_analysis`, `landing_support`; empty = automatic. | | `images` | `all` \| `cover` \| `none` | no | Which images are made: `all` = cover + in-text images (default), `cover` = cover only, `none` = no images. **Images are the most expensive part** (one image usually costs more than an article's whole text); translations reuse the source's images and add no image cost. The choice comes back in the request's `options.images` and each article's `images`. With `none`, missing images are not a flaw in the quality check. | | `target_audience` | string | no | The audience of this article (max 2000). | | `keywords` | array of strings | no | Desired keywords (at most 20, each max 100). | | `ai_queries` | array of strings | no | To be found in AI answers (ChatGPT, Perplexity, Google's AI Mode): the questions people ask AI assistants about this, and the searches those run (at most 15, each max 300). The article answers each directly in a passage an assistant can quote. Without them, the writer works out such questions itself. | | `instructions` | string | no | Free instructions for the writer (max 5000). | | `category` | string | no | Category name (max 191). | | `priority` | integer 1 to 10 | no | Queue priority; default 5. | | `external_ref` | string | **recommended** | The request's id in your system (max 191). | | `link_targets` | array of objects | **recommended** | Your blog's published posts, so the new articles link to the related ones. See [Internal links to your posts](#internal-links-to-your-posts). | - **Site:** `site.url` (`http`/`https` only, max 255) names the target site; it is compared case-insensitively and without a trailing `/`. A site this key has not used before is registered automatically (with `site.name`, or the host name); `site.description` and `site.audience` are only stored on that first registration, and a new `site.name` renames the registered site. Without `site` the key's default site is used; if there is none → `422 site_required`. - **Safe retries:** a request with an `external_ref` already used (by this key) creates nothing and returns that earlier request with `200`, **ignoring the rest of the body** (a new one = `202`). If you send no `external_ref`, the `Idempotency-Key` header (its first 191 characters) is stored in its place and comes back as `external_ref`. With neither, every call creates a new request. - **`errors`:** if some languages cannot be created but at least one can, the answer is still `202` and the refused languages are listed in `data.errors`: `[{ "language": "de", "error": "…" }]`. - **`options`:** the options you sent (`content_type`, `images`, `target_audience`, `instructions`, `keywords`, `category`, `priority`) come back in `data.options`; `images` is always there (default `all`). `keywords` and `instructions` are given to research, planning and writing as your notes. With your [search data](#your-search-data-search-console-and-analytics) connected, the real queries people use for the subject are given to them as well. - **Same topic again:** if this blog asked for the same topic before (even if it removed it on its side since), no language is refused or written again; the same articles are attached to the new request and, depending on their state: | Earlier article's state | What happens | |---|---| | `failed` or cancelled, `rejected` | Written again (steps are reported again) | | `processing` | Carries on; its events come under the new request | | `in_review` | The preview is sent again with `article.review_required` | | `ready` / `delivered` | The content is sent again with `article.updated` (or `article.completed`) | New languages are translated from that same article's source (whatever its language). Article ids (`art_…`) stay the same, so an upsert on `data.article.id` on your side is enough. If no language can be created (e.g. an inactive language): `422 no_articles_created`. - **Internal links to your posts:** see the next section. - **Cancel:** `POST /requests/{id}/cancel` (no body) stops the `processing` and `in_review` articles: they become `failed` with `error.code: "cancelled"` (no `article.failed` event is sent for a cancellation). `ready`/`delivered`/`rejected` articles are untouched. The answer is `200` with the request and `status: "cancelled"`; cancelling again has no effect and returns the same. ### Internal links to your posts Articles link to your blog's own posts, in their language, when you send them in `link_targets`. Send your published posts in the request's languages, newest first (at most 300; 200 is plenty): ```json "link_targets": [ { "path": "/best-time-to-visit-milan", "title": "Best time to visit Milan", "language": "en", "excerpt": "Weather, crowds and event weeks month by month.", "keyword": "best time to visit Milan", "group": "grp-41", "article_id": null }, { "path": "/بهترین-زمان-سفر-به-میلان", "title": "بهترین زمان سفر به میلان", "language": "fa", "group": "grp-41" } ] ``` | Field | Rule | Meaning | |---|---|---| | `path` | **required**, starts with `/` (not `//`), max 500 | The post's address on your blog, root-relative | | `title` | **required**, max 500 | Its title | | `language` | **required**, max 10 | Its language code | | `excerpt` | max 2000 | A line on what it covers (helps choose it) | | `keyword` | max 191 | Its focus keyword | | `group` | max 191 | Your id for "the same post in several languages": a translation links to the post of the same group in its own language | | `article_id` | max 64 | When the post is one of our articles (`art_…`): it is never offered as a link from that article or its translations | - Each list replaces the posts stored for its languages and the request's languages (a post you removed is no longer linked). Without `link_targets` the stored list is kept. The same field is accepted by `POST /requests/{id}/languages`. - The article links **2 to 8** of them (the range is set by the content system team) where they genuinely help the reader, with natural anchor text in the article's language, never "click here". Only posts from your list (or articles we published) can ever be linked. - In `content.blocks` a link to your post is `[[link:p45|anchor]]` (`p` + a number; a link to one of our articles is a plain number). In `content_html` it is a normal link with your path: `anchor` — **root-relative**, so it works under every address of your blog; prefix it with your base path when you render it, as for your own links. `details.links[]` lists each one (`target.url` = the path). - A translation links to the post of the same `group` in its own language; if you have none, the anchor stays as plain text. The source already picks among the posts of every requested language, so a Persian translation of a German article can link your Persian posts. - The quality check `internal_links` counts these links. When you have no post in the article's language (and we have no other article in it), it passes with a note instead of warning: there is nothing to link to yet. ### Adding languages to a request ``` POST /api/public/v1/requests/{id}/languages { "languages": ["it"] } ``` A new language is added to **the same topic**, even while its articles are still being written. Each language is a translation of the request's source article (the same article, with the same quality check and the same images; no extra image cost). If the source is not finished yet, the new article waits in `processing` and is translated when the source finishes; if it is finished, it starts at once. The request's options (`images`, `content_type`, `instructions`, `keywords`…) apply to the new language too. - Answer `202`: `{ "data": , "added": ["it"] }`. The new articles are in `data.articles` and `data.languages` is updated; build the cards from this answer. Their progress arrives through `article.stage_*` like the others. - Languages the request already has are ignored; if no new language remains: `422 no_new_languages`. A language refused earlier (`errors`) and added now is removed from `errors`. - A cancelled request: `409 request_cancelled` (send a new request). - The same limits as creating a request: inactive or disallowed language, daily quota, token limit and the **in-progress limit** (`429 too_many_in_progress`; each language is one article). - A translation of one of your posts (`kind: "translation"`) gets more languages from a new `POST /translations`, not here: `409 not_supported`. --- ## Translating your own posts A post your team wrote (not one of ours) can be translated into other languages with the same translation step our articles use: a native, faithful translation, then a translation review, then your review. Nothing is researched or written, and no image is made: **only the text is translated**. ``` POST /api/public/v1/translations { "title": "Two days in Rome", "excerpt": "A short plan for a first visit.", "slug": "two-days-in-rome", "content_html": "

Why visit Rome

Read our Rome guide.

\"…\"
", "language": "en", "languages": ["fa", "de"], "seo": { "seo_title": "Two days in Rome", "meta_description": "…", "og_title": null, "og_description": null, "primary_keyword": "rome in two days", "secondary_keywords": ["rome itinerary"] }, "faq": [{ "question": "Is two days enough?", "answer": "For the main sights, yes." }], "instructions": "Keep brand names in English.", "post_ref": "post_123", "external_ref": "order_9", "link_map": [{ "href": "/rome-guide", "languages": { "fa": "/rahnamaye-rome" } }], "retranslate": false } ``` | Field | Required | Meaning | |---|---|---| | `title`, `content_html` | yes | The post's title and body (HTML, up to 2 MB) | | `language` | yes | The post's language | | `languages` | yes | 1 to 20 languages to translate into (not the post's own) | | `post_ref` | yes | Your id for the post. Orders of the same post share it; see `409 translation_exists` below | | `excerpt`, `slug` | no | Translated (the slug is written for the new language) | | `seo` | no | `seo_title`, `meta_description`, `og_title`, `og_description`, `primary_keyword`, `secondary_keywords[]`: localised, keywords as people search in each language | | `faq` | no | Up to 50 `{ question, answer }`: translated; delivered in `content.faq`, never added to the HTML | | `instructions` | no | A note for the translator (tone, terms to keep), up to 5,000 characters | | `external_ref` | no | Your id for this order: sent again, the same order is answered with `200` | | `link_map` | no | Links in the post to your other posts, with that post's address in each language you have it: `[{ href, languages: { code: href } }]` | | `retranslate` | no | `true` to translate again a language this post already has from us (the post changed) | | `site` | no | `{ url, name }` as in `POST /requests` | **What is kept exactly.** Every tag, attribute, link address, image (`src`, `alt`, size), embed (for example `
`), code block and table structure comes back as it was sent; only the text between tags is translated. Inline formatting (links, bold, italic, line breaks) stays on the translated words. A translation that loses or changes any of it is refused on our side and translated again, so the HTML you receive always has the structure you sent. A link listed in `link_map` points at your post in the new language; a link with no version in that language keeps its address. **What you receive.** The answer is `202` with a request object of `kind: "translation"`; `data.articles` has one article per language (the post itself is never listed or delivered). Each language then goes like any translated article: `article.stage_*` events (`translation`, then `validation`), `article.review_required` with the preview, your decision (`approve`, `reject`, `revise`, `edit`), then `article.completed`. `content` carries the translated `title`, `slug`, `excerpt`, `content_html`, `seo` and `faq`; there is no `featured_image` (keep the post's own picture). `translated_from` is the post's language. **Quality.** Only the translation is judged (fidelity, numbers and names, language quality, keyword localisation, metadata, plus the SEO checks). There is no content verdict to carry over: `quality.translation.source_score` is `null` and `score` is the translation's own. **Cost and limits.** Charged as translations (text only), against the key's daily quota (one article per language), token limit, monthly budget and in-progress limit, with the same `429` errors as `POST /requests`. The content system team turns translating your own posts on or off for each key: when it is off, `403 tool_disabled` (and `GET /me` → `tools.translations.enabled` is `false`). **Errors.** `403 tool_disabled` (turned off), `422 unsupported_language` (a language, or the post's language, that is unknown or inactive; one this key may not use: `403 language_not_allowed`), `422 same_language` (the post's own language asked for), `422 empty_content` (no text to translate), `409 translation_exists` (this `post_ref` is already being translated into one of these languages, or already has a translation into it and `retranslate` was not sent; `languages: { code: status }` says which). --- ## Pictures for your own posts A cover or a picture for the text of a post your team wrote, made from what the post says (its text), or from a short description; then new versions of it with an instruction, until one fits. Each is drawn as our articles' images are: a photograph in the house style, never text in the picture, no recognisable people unless the content system allows them, and marked as AI-generated in the file. Nothing is written to any post; you decide what to do with the picture. ``` POST /api/public/v1/images { "role": "cover", "description": "the yellow tram on a steep street in Alfama at golden hour", "title": "Tram rides in Lisbon", "excerpt": "…", "content": "

…

…

", "language": "en", "post_ref": "post_123" } ``` | Field | Meaning | |---|---| | `role` | `cover` (16:9, with a 1200×630 social variant) or `inline` (3:2); default `cover` | | `description` | What to picture, up to 1,000 characters; optional | | `content` | The post's text (HTML or plain). Without a `description` the picture is made from it, and it needs at least 30 words: otherwise `422 content_required` (`words`, `min_words`), so a picture is never made for an empty post | | `title`, `excerpt`, `language` | The post, for context; `language` is the alt text's language | | `post_ref` | Your id for the post, kept on the picture | | `from`, `instruction` | A new version of a picture made before: its `id` and what to change (up to 300 characters). The previous prompt is adjusted, never replaced by the instruction | Answer `202`: `{ "data": , "limits": { "per_day", "used_today", "left_today" } }`. Follow it with `GET /images/{id}` until `status` is `ready` (usually within a minute or two): `{ "data": , "versions": [, …], "limits": { … } }`, `versions` being every version of that picture, newest first. **Picture object:** `id` (`bimg_…`), `from` (the version it was made from, or `null`), `post_ref`, `role`, `status` (`generating`, `ready`, `failed`), `description`, `instruction`, `url` (new for every picture, so nothing cached shows an older one), `alt_text` (written for the picture, in `language`), `width`, `height`, `ai_generated` (always `true`), `error` (`{ code, message }` when failed; `policy_refused`: the image service refused it, ask again with a different description), `created_at`. Copy the picture into your own media library; the address is ours. **Limits and cost.** Each picture, versions included, costs one AI image against the key's monthly budget and token limit (`429 budget_reached`, `budget_insufficient`, `token_limit_reached`) and counts against your key's **pictures per day** (10 unless the content system team set another number for your key; `429 image_limit` with `limit`, `used`, `resets_at`). The quality they are drawn at is set for your key too (`tools.images.quality`). When pictures for your own posts are off for your key: `403 tool_disabled`. Other errors: `422 content_required` (no `description` and fewer than 30 words of `content`), `404 not_found` (another key's picture), `409 image_not_ready` (`from` a picture that was not made). --- ## Statuses **Article** (`status`): | Status | Meaning | |---|---| | `processing` | Being worked on; the current step is in `stage`. | | `in_review` | Written and checked, waiting for your decision; the content is a preview (`content_state: "preview"`). | | `ready` | Approved; the final content is available. | | `delivered` | You reported that you published it (`published_url`). | | `rejected` | You rejected it; ask again with `revise`. If the article already had an approved version, rejecting a new version returns it to `ready` (or `delivered`) with that earlier version. | | `failed` | Could not be produced; see `error` (`code`, `stage`, `message`). Try again with `POST /articles/{id}/retry`. | **`stage`** only has a value while `status` is `processing` (otherwise `null`): `draft`, `queued`, `researching`, `planning`, `generating`, `seo_analysis`, `image_generation`, `validation` (quality check and improvement rounds), `awaiting_source` (a translation waiting for its source), `translating`. If the duplicate check finds a very similar article, work may stay stopped at `stage: "queued"` until the content system team decides (after `article.stage_started` for `duplicate_check`, no completion event arrives until then). **Request** (`status`): | Status | Meaning | |---|---| | `processing` | At least one article is still `processing`, `in_review` or `rejected` | | `completed` | Every article is `ready` or `delivered` | | `partially_failed` | Some `failed`, the rest `ready`/`delivered` | | `failed` | Every article `failed` | | `cancelled` | The request was cancelled (always, even if one of its articles is retried later) | **Steps** (`step.stage`): `duplicate_check`, `research`, `planning`, `generation` (writing), `seo`, `images`, `validation` (quality check), `translation`, `improvement` (quality improvement). The source article goes through every step except translation; translations only `translation` and `validation`. `improvement` only appears when the quality score is below the target (see "Quality gate" below) and may repeat. --- ## Step by step: from analysis to delivery Each step sends two or three events: `article.stage_started` when it starts, `article.stage_completed` with **that step's output** when it finishes, and `article.stage_failed` if it fails (`will_retry: true` means it is retried automatically). Each step's output (`step.output`) has the shape of the matching section of the record: | Step | What happens | `step.output` | |---|---|---| | `duplicate_check` | Is there a similar article on this site? | none (`step.summary`: `{ "checks": [{ "compared_article_id", "risk", "score" }] }`) | | `research` | Searching and collecting reliable sources, facts, user questions | `{ brief, sources[] }` | | `planning` | Search intent, heading structure, keywords, image and link placement | `{ plan }` | | `generation` | Writing the full text with citations | `{ title, excerpt, blocks[], html, faq[], cta[], word_count }` | | `seo` | SEO title and description, OG, slug, internal links, structured data | the `seo` section | | `images` | Planning and making the images (featured and in-text) | `{ images[] }` | | `validation` | Quality check: accuracy, citations, SEO, structure | the `quality` section | | `translation` | Translating the article into the target language | `{ content, seo }` | | `improvement` | One quality improvement round: rewriting from the quality report and checking again | `{ content, quality }`; in `summary`: `round`, `score_before`, `score_after`, `target_score` | `step.summary` is the step's own summary and its shape depends on the step (e.g. for `images`: `{ "planned": 5, "generated_now": 5, "ready": 5, "failed": 0 }`); use it for display but do not depend on its keys. `step.status`: `running` (in `stage_started`), `succeeded`, `failed`, `paused`; in `details.runs[].steps` you may also see `superseded` (an attempt set aside by a retry). `step.model` is the AI model of that step (or `null`). Not every step runs every time: with `images: "none"` the `images` step does not run; `revise` on a source article only runs `generation`, `seo` and `validation`; `retry` resumes at the failed step. **Failed images:** if an image fails because of a dropped connection or a temporary service error, the article goes ahead with a note in `review_reasons` and that image at `status: "failed"`, and the system tries the image again every 5 minutes (up to 20 attempts, approved articles included). An image the AI provider refuses is tried once more with a calmer, people-free prompt. The moment it is made the article is sent to you **again**: an article `in_review` with `article.review_required` (the new preview), an approved one with `article.updated` — so you may get these events several times for one version (upsert, and take the cover from `content.featured_image`). You can also ask for it yourself: [`POST /articles/{id}/images/generate`](#post-articlesidimagesgenerate). **Every language shows the same pictures.** Images are made once, for the source article; each translation shows exactly those files (only alt text, title and caption are translated). An image made later reaches every language, and each one is sent to you as above. After the last step the article either sends `article.review_required` (waiting for your decision) or goes straight to `article.completed` (when no review is needed). --- ## Webhooks: signing, retries, response Each event is a `POST` with a JSON body: ```json { "id": "evt_01k6c3aa9mq2r4s6t8v0w2x4y6", "type": "article.stage_completed", "api_version": "2026-09-29", "created_at": "2026-10-03T10:12:03+00:00", "data": { "article": {}, "request": {}, "step": {} } } ``` Headers: ``` X-ContentSystem-Event: article.stage_completed X-ContentSystem-Delivery: evt_01k6c3aa9mq2r4s6t8v0w2x4y6 (the same on every retry) Idempotency-Key: evt_01k6c3aa9mq2r4s6t8v0w2x4y6 X-Signature-Timestamp: 1790000000 X-Signature: sha256= Content-Type: application/json User-Agent: ContentSystem-Webhooks/1.0 ``` `X-ContentSystem-Delivery` and `Idempotency-Key` are both the event `id`. The envelope (body) is frozen when the event is created; every retry or redelivery sends **exactly the same bytes** and the same `id` (only `X-Signature-Timestamp` and `X-Signature` are computed afresh). The webhook URL must be `http(s)` and on the public internet; a private network address is only accepted when the content system team has allowed it. `X-Signature` is `HMAC_SHA256(secret, timestamp + "." + rawBody)` in hex. Compute it over the **raw body** (before parsing), reject timestamps older than 5 minutes, and compare in constant time. ```js import crypto from "node:crypto"; export function verify(rawBody, headers, secret) { const ts = headers["x-signature-timestamp"]; const sig = headers["x-signature"] ?? ""; if (!ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false; const expected = "sha256=" + crypto.createHmac("sha256", secret).update(`${ts}.${rawBody}`).digest("hex"); return sig.length === expected.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected)); } ``` ```php $ts = $_SERVER['HTTP_X_SIGNATURE_TIMESTAMP'] ?? ''; $expected = 'sha256='.hash_hmac('sha256', $ts.'.'.file_get_contents('php://input'), $secret); $ok = ctype_digit($ts) && abs(time() - (int) $ts) <= 300 && hash_equals($expected, $_SERVER['HTTP_X_SIGNATURE'] ?? ''); ``` **Your response:** - Any `2xx` means received; answer within **30 seconds** and do heavy work in your own queue. - For `article.completed` / `article.updated`, if you return the address of the published post, the article is recorded as `delivered`: `{ "url": "https://blog.example.com/lisbon", "external_id": "post_8841" }`. Accepted keys: `url` or `published_url` or `post.url`, and `external_id` or `id` or `post.id`. `url` must be a valid URL and only counts when the event is for the current approved version. Answers to other events are not read. - `5xx`, `408`, `409`, `425`, `429` or a network error/timeout → retried automatically: 8 attempts in total, spaced 30 seconds, 2 minutes, 10 minutes, 30 minutes, 1 hour, 3 hours and 6 hours apart (about 11 hours). Other `4xx` (e.g. `401` for a bad signature) are not retried and the delivery stays `failed`. The content system team can resend any event (same `id` and body, one attempt). - If the key is disabled, queued events are no longer sent. - **Deduplicate:** an event may arrive more than once; ignore a repeated event `id` and **upsert** everything on `data.article.id`. - Arrival order is not guaranteed; order steps by `step.started_at` / `step.finished_at`. - The event filter is set on the key; by default all events are sent. --- ## Every event, with examples | Event | When | Extra data | |---|---|---| | `article.stage_started` | A step starts | `step` | | `article.stage_completed` | A step finishes successfully | `step` with `output` | | `article.stage_failed` | A step fails | `step` with `error` and `will_retry` | | `article.review_required` | Waiting for your decision (after generation, after an `edit` without `approve`, or when a missing image has been made) | `article.content` (preview) + `details` | | `article.completed` | First approved version | `article.content` + `details` | | `article.updated` | A later approved version, an approved article sent again when its topic is asked for again, an approved article whose missing image has been made, or one whose image you replaced (`…/images/{plan_id}/accept`, every language) | `article.content` + `details` | | `article.failed` | Production finally failed (after automatic retries); not sent for a cancellation | `article.error` | | `titles.found` | A [title-finder](#finding-titles) run finished or failed, asked for or scheduled | `run` (see [Running it](#running-it)) | | `ping` | `POST /webhook/test`, or a test sent by the content system team | `{ "message", "client" }` | Every article event has `data.article` and `data.request`. `data.request` is a summary: `{ "id", "external_ref", "status", "usage" }`. **`data.article`** (the article object; the same shape as `GET /articles/{id}`): ```json { "id": "art_01k6c2t3c9a2b4c6d8e0f2g4h6", "request_id": "01k6c2t3b8x4n7q9r2s5t8v0wy", "external_ref": "topic-123", "language": "fa", "status": "processing", "stage": "awaiting_source", "title": "Best time to visit Lisbon", "error": null, "published_url": null, "translated_from": "en", "quality": null, "images": "all", "usage": { "input_tokens": 0, "output_tokens": 0, "total_tokens": 0, "images": 0, "cost_usd": 0 }, "created_at": "2026-10-03T10:00:01+00:00", "updated_at": "2026-10-03T10:04:40+00:00" } ``` | Field | Meaning | |---|---| | `id` | The article's stable id (`art_…`); your upsert key | | `request_id` / `external_ref` | The request the article is attached to now (a newer request if the topic is asked for again) | | `language` | Language code | | `status` / `stage` | See [Statuses](#statuses) | | `title` | Current title | | `error` | Only when `failed`: `{ "code", "stage", "message" }` (see [Errors](#errors)) | | `published_url` | Only when `delivered` | | `translated_from` | Source language code for translations, otherwise `null` | | `quality` | Quality summary of the latest version, or `null` (see [details](#the-full-article-record-details)) | | `images` | `all` \| `cover` \| `none` | | `usage` | This article's own AI usage | | `version`, `content_state`, `content` | Only when the content is included (below) | **`data.article` with content**: in `article.review_required`/`completed`/`updated`, `GET /articles/{id}`, `GET /articles?include=content` and the `approve`/`edit` answers, when the article is `in_review`, `ready` or `delivered`, three fields are added: `version` (the version number), `content_state` (`preview` while `in_review`, otherwise `approved`) and `content`: ```json { "content": { "version": 3, "title": "Best time to visit Lisbon", "slug": "best-time-to-visit-lisbon", "language": "en", "hreflang_code": "en", "direction": "ltr", "status": "publish", "excerpt": "…", "content_html": "

…

", "word_count": 1840, "categories": [{ "id": 4, "name": "Travel", "slug": "travel" }], "tags": [{ "name": "Portugal", "slug": "portugal" }], "seo": { "title": "Best Time to Visit Lisbon | Season Guide", "meta_description": "…", "canonical_url": null, "robots": "index,follow", "og": { "title": "…", "description": "…", "image": "https://content.nx.plus/storage/images/…/lisbon-cover-og.jpg", "type": "article", "locale": "en" }, "twitter": { "card": "summary_large_image" }, "primary_keyword": "best time to visit lisbon", "secondary_keywords": ["lisbon weather"], "breadcrumbs": [{ "name": "Home", "url": "https://blog.example.com/" }, { "name": "Travel", "slug": "travel" }, { "name": "Best time to visit Lisbon", "url": null }] }, "hreflang": [{ "lang": "en", "href": "https://blog.example.com/best-time-to-visit-lisbon" }, { "lang": "x-default", "href": "https://blog.example.com/best-time-to-visit-lisbon" }], "structured_data": [{ "@context": "https://schema.org", "@type": "BlogPosting", "headline": "…" }], "featured_image": { "url": "https://content.nx.plus/storage/images/…/lisbon-cover.webp", "width": 1600, "height": 900, "alt": "…", "title": "…", "caption": null, "mime": "image/webp", "placement": null, "variants": [{ "url": "https://content.nx.plus/storage/images/…/lisbon-cover-480w.webp", "path": "images/…/lisbon-cover-480w.webp", "format": "webp", "width": 480, "height": 270 }], "ai_generated": true }, "images": [], "faq": [{ "question": "…", "answer": "…" }], "sources": [{ "url": "https://www.visitportugal.com/…", "title": "…", "publisher": "Visit Portugal" }], "published_at": "2026-10-03T11:02:00+00:00", "updated_at": "2026-10-03T11:02:00+00:00" } } ``` Notes: `content_html` is ready to publish (citations rendered). `images` holds the in-text images in the same shape as `featured_image`; `placement` is the id of the block the image follows. `variants` lists every size and format (WebP/AVIF, plus a 1200×630 JPEG crop for `og` on the cover). `faq` and `sources` are the clean versions for publishing (`sources` only lists cited sources whose link is not broken). `status` is always `"publish"`. Until the article is `delivered`, `published_at` is the time this answer was built, and `updated_at` is always the time this answer was built; use `version` to detect changes. `hreflang` only lists languages that are published (plus this article itself and `x-default`). **`article.stage_completed`** (e.g. the source's research, reported on a translation waiting for it): ```json { "id": "evt_01k6c3aa9mq2r4s6t8v0w2x4y6", "type": "article.stage_completed", "api_version": "2026-09-29", "created_at": "2026-10-03T10:04:40+00:00", "data": { "article": { "id": "art_01k6c2t3c9a2b4c6d8e0f2g4h6", "language": "fa", "status": "processing", "stage": "awaiting_source", "…": "…" }, "request": { "id": "01k6c2t3b8x4n7q9r2s5t8v0wy", "external_ref": "topic-123", "status": "processing", "usage": { "input_tokens": 18400, "output_tokens": 3900, "total_tokens": 22300, "images": 0, "cost_usd": 0.0921 } }, "step": { "stage": "research", "label": "Research", "attempt": 1, "status": "succeeded", "model": "gpt-5.4", "started_at": "2026-10-03T10:01:02+00:00", "finished_at": "2026-10-03T10:04:40+00:00", "duration_ms": 218000, "summary": { "research_mode": "web", "sources": 9, "dead_sources": 1, "facts": 14, "web_search_calls": 6 }, "error": null, "on_source": { "language": "en" }, "output": { "brief": { "search_intent": "informational", "key_facts": ["…"], "user_questions": ["…"] }, "sources": [{ "ref": "S1", "url": "https://www.visitportugal.com/…", "title": "…", "publisher": "Visit Portugal", "type": "official_docs", "language": "en", "authority_score": 0.9, "relevance": "high", "published_date": "2025-04-01", "url_check": "ok", "cited": false }] } } } } ``` `step.on_source` is `null` for the article's own steps. `step.label` is a readable name (`Duplicate check`, `Research`, `Planning`, `Writing`, `SEO`, `Images`, `Quality check`, `Translation`, `Improving quality`). **`article.stage_failed`**: ```json { "step": { "stage": "images", "attempt": 1, "status": "failed", "error": { "code": "IMAGES_PARTIAL", "message": "1 image(s) failed; retrying only those." }, "will_retry": true } } ``` With `will_retry: true` the step runs again automatically (usually up to 3 attempts); with `will_retry: false`, `article.failed` follows. `step.error.code` is the step's internal code (e.g. `IMAGES_PARTIAL`, `UNEXPECTED`) and `message` a technical description; to show users a reason, use `article.error`. **`article.review_required`** / **`article.completed`** / **`article.updated`**: ```json { "id": "evt_01k6c4b2x7y9z1a3b5c7d9e1f3", "type": "article.completed", "api_version": "2026-09-29", "created_at": "2026-10-03T11:02:00+00:00", "data": { "article": { "id": "art_01k6c2t3c9a2b4c6d8e0f2g4h6", "status": "ready", "version": 3, "content_state": "approved", "content": { "title": "…", "content_html": "…", "…": "…" }, "…": "…" }, "request": { "id": "01k6c2t3b8x4n7q9r2s5t8v0wy", "external_ref": "topic-123", "status": "completed", "usage": { "input_tokens": 61230, "output_tokens": 14120, "total_tokens": 75350, "images": 5, "cost_usd": 1.4012 } }, "details": { "schema": "content-system.article-details/1", "version": 3, "…": "…" } } } ``` In `review_required`, `status` is `in_review` and `content_state` is `preview`. `details` is the full record (next section). **`article.failed`**: ```json { "type": "article.failed", "data": { "article": { "id": "art_01k6c2t3c1m5p8r2t6v9x3z7ab", "status": "failed", "stage": null, "error": { "code": "generation_failed", "stage": "generation", "message": "The article could not be produced. Our team has been notified; it may be retried from our side." }, "…": "…" }, "request": { "id": "01k6c2t3b8x4n7q9r2s5t8v0wy", "external_ref": "topic-123", "status": "processing", "usage": { "…": "…" } } } } ``` **`ping`**: ```json { "id": "evt_01k6c5c0aa1bb2cc3dd4ee5ff6gg", "type": "ping", "api_version": "2026-09-29", "created_at": "2026-10-03T09:00:00+00:00", "data": { "message": "Webhook test from the content system.", "client": "Example Blog" } } ``` --- ## The full article record (`details`) The same sections the content system team reviews. It comes as `data.details` in `article.review_required`, `article.completed` and `article.updated`, and can be fetched any time with `GET /articles/{id}/details` (and `?version=N` for an earlier version). It holds no AI cost in dollars and none of the system's prompt templates (only token counts per run, and each image's prompt). Default version: the one waiting for review if the article is `in_review`, otherwise the approved one, otherwise the latest. The record's root: ```json { "schema": "content-system.article-details/1", "version": 3, "version_state": "in_review", "overview": { "…": "…" }, "preview": { "…": "…" }, "content": { "…": "…" }, "seo": { "…": "…" }, "images": [], "sources": { "sources": [], "claims": [] }, "links": [], "structured_data": [], "quality": { "…": "…" }, "research": { "brief": {}, "plan": {} }, "versions": [], "runs": [], "deliveries": [] } ``` `version_state`: `draft`, `in_review`, `approved`, `published`, `rejected` or `superseded`. While the article has no version yet, `version`/`version_state`/`preview`/`content`/`seo`/ `quality`/`research` are `null` and the lists are empty. | Section | Contents | Suggested tab in the blog panel | |---|---|---| | `overview` | `id`, `request_id`, `status`, `stage`, `title`, `topic` (the requested topic), `language`, `language_name`, `direction` (`ltr`/`rtl`), `translated_from`, `slug`, `primary_keyword`, `search_intent`, `content_type`, `funnel_stage`, `cluster_role`, `word_count`, `quality` (summary), `published_url`, `error` (`{ stage, message }`), `created_at`, `updated_at`, `published_at` | Overview | | `preview` | `{ html, title, excerpt }`: the page ready to read | Preview (sanitize the HTML) | | `content` | `title`, `excerpt`, `blocks[]`, `html`, `faq[]` (`question`, `answer`, `source_refs`), `cta[]` (CTA suggestions), `word_count` | Content | | `seo` | `slug`, `seo_title`, `meta_description`, `og_title`, `og_description`, `title_variants[]`, `canonical_url`, `robots` (default `index,follow`), `breadcrumbs[]`, `social_snippets`, `suggested_fixes[]`, `primary_keyword`, `secondary_keywords[]`, `long_tail_keywords[]`, `semantic_entities[]`, `hreflang[]`, `checks[]` | SEO | | `images[]` | `id` (the image's id in the plan, e.g. `cover`), `role` (`featured`/`inline`), `placement_block_id`, `status` (`planned`, `generating`, `ready`, `failed`), `url` and `variants[]` (`name`, `url`, `width`, `height`, `format`; only when `ready`), `filename`, `alt_text`, `title`, `caption`, `description`, `purpose`, `image_type`, `prompt`, `width`, `height`, `aspect_ratio`, `format`, `ai_generated`, `model`, `generated_at`, `error` (only when `failed`) | Images | | `sources` | `sources[]` (`ref`, `url`, `title`, `publisher`, `type`, `language`, `authority_score`, `relevance`, `published_date`, `url_check`: `ok`/`redirect`/`blocked`/`not_found`/`null`, `cited`) and `claims[]` (`claim`, `type`, `value`, `as_of`, `source_refs[]`, `confidence`, `verification` such as `unverified`/`partially_verified`, `note`) | Sources | | `links[]` | Internal links: `target` (one of our articles: `id` = `art_…`, `title`, `url`; one of your posts: `id` = `null`, `title`, `url` = its root-relative path, `language`), `marker` (the id in `[[link:…]]`, e.g. `p45`), `anchor_text`, `block_id`, `reason`, `status` (e.g. `suggested`) | Links | | `structured_data` | Array of ready JSON-LD (`BlogPosting` or `Article`, `BreadcrumbList`, `FAQPage`, `HowTo`) | Structured data | | `quality` | Summary (below) + `checks[]` + `seo_checks[]` + `unsupported_claims[]` + `validated_at` | Quality | | `research` | `brief` (research findings: `search_intent`, `key_facts`, `user_questions`, …) and `plan` (structure, keywords, `funnel_stage`, `cluster_role`, image plan) | Research & plan | | `versions[]` | The last 30 versions, newest first: `version`, `origin` (`generation`, `regeneration`, `translation`, `manual_edit`), `state`, `title`, `word_count`, `quality_score`, `created_at`, `approved_at` | Versions | | `runs[]` | The last 10 runs: `trigger` (e.g. `api`, `retry`, `source_completed`), `status`, `version`, `stages[]`, `started_at`, `finished_at`, `tokens` (`{ input, output }`), `steps[]` (the same shape as `step` in events) | Runs | | `deliveries[]` | The last 30 webhooks for this article: `event_id`, `event`, `status` (`pending`, `sending`, `succeeded`, `failed`), `attempts`, `http_status`, `created_at`, `delivered_at` | Deliveries | **Quality summary** (`quality` on the article object and `overview.quality`; `details.quality` is the same plus the details): ```json { "score": 88, "verdict": "good", "requires_review": false, "bar": 75, "target": 85, "below_bar": false, "issues": [{ "severity": "major", "check": "unsupported_claims", "message": "1 claim(s) are not supported by the recorded sources.", "from_source": null, "block_ids": ["p-12"] }], "checked_score": 88, "fixed_points": 0, "resolved": [{ "check": "external_references", "from_source": null, "severity": "major", "message": "No verified external sources.", "kind": "accepted", "note": "Personal travel notes; no source needed.", "by": "Sara", "at": "2026-10-06T09:00:00+00:00" }], "translation": null, "review_reasons": [] } ``` `issues` holds at most 8 entries and `review_reasons` (why the article must be looked at) at most 5. `bar` is the lowest acceptable score, `target` the score the improvement rounds aim for, and `below_bar` means the article is still under `bar` after every round (see "Quality gate" below). `resolved` lists the issues you marked "fixed" or "OK as is" on this version ([Decisions on checks](#decisions-on-checks)); they are left out of `issues` and of the `verdict`. **"Fixed" raises `score`** by what the finding cost, **"OK as is" leaves it as it was**: a failure gives back 10 (critical), 6 (major) or 3 (minor) points, a warning 5, 3 or 2; at most 100. `checked_score` is the score as checked and `fixed_points` what was added (`score = checked_score + fixed_points`); undoing a "fixed" takes its points back. In `details.quality`, each entry of `checks[]` and `seo_checks[]` carries `resolution`: `{ kind, note, by, at }` or `null`. **Blocks** (`content.blocks[]`): `{ id, type, level, text, items, table, term, image_id, cta_id }`. `type` is one of `heading`, `paragraph`, `list`, `ordered_list`, `steps`, `table`, `definition`, `quote`, `callout`, `image_slot`, `cta`. In the text, `[[src:REF]]` cites `sources` and `[[link:ID|anchor]]` is an internal link (`ID` a number for one of our articles, `p` + a number for one of your posts); `html` has all of these rendered. **`verdict` values:** | `verdict` | Meaning | |---|---| | `good` | Ready to publish | | `needs_attention` | Publishable after looking at `issues` | | `poor` | Has a fundamental problem; ask for changes before publishing | | `pending` | Not checked yet | `issues` only lists `critical` and `major` items; every detail is in `quality.checks` and `quality.seo_checks`. **Taking an editor to the problem:** each issue, and each item of `quality.checks`, has `check` (in `checks`: `name`) — what was checked — and `block_ids`, the blocks of `content.blocks` it concerns (empty when it is about the whole article or its metadata). Use them to open the right place in your editor: the block's text for content and language issues; the SEO fields for `metadata`, `keyword_usage` and `seo_requirements`; the cover and image texts for `images` and `image_metadata`; the structured data and FAQ for `structured_data`; your internal-link tool for `internal_links`. **Quality of translations:** the content (accuracy of claims, sources, search intent, originality, structured data, marketing) is checked **once**, on the source article, and the same result reaches every translation unchanged, so a content issue shows the same in every language. Those items carry `from_source` (the source language code, e.g. `"en"`) in `checks[]` and `issues[]`, and `unsupported_claims` is the source's list. The translation itself is checked separately: fidelity to the source (`fidelity`), numbers and names (`numbers_and_names`), citation markers (`markers`), language quality (`language_quality`), keyword localisation (`keyword_localisation`) and metadata (`metadata`). Deterministic SEO checks (title length, keyword placement, …) run for each language, since each language's text differs. ```json { "quality": { "score": 68, "translation": { "source_language": "en", "source_score": 68, "translation_score": 91 } } } ``` A translation's `score` is the lower of the two: no translation is better than its source content, and if the translation itself has problems it goes lower. For an article that is not a translation, `translation` is `null`. **Quality gate:** two numbers are set by the content system team: the **target** (`target`, default **85**) and the **acceptable bar** (`bar`, default **75**), plus the number of improvement rounds (default 3). - After each quality check, if the score is below the **target**, the system improves the article itself from the quality report (unsupported claims backed by a source or removed, SEO and language issues fixed) and checks again, until the rounds run out. Each round is an `improvement` step, reported with `article.stage_started` / `article.stage_completed` like the other steps. - After the last round, if the score is **at least the bar**, the article is delivered as usual. - If it is still **below the bar**, the article is still delivered (it does not fail), but with `quality.below_bar: true`, `requires_review: true` and a reason in `review_reasons`; it always arrives with `article.review_required` and is never approved automatically. **The blog decides:** we suggest not adding it to your posts yet, showing a gentle warning with the score and issues on the card, and only calling `POST /articles/{id}/approve` once the user confirms "use it anyway" (or asking for changes / rejecting). For a translation only the **translation score** is compared with the target and the bar, and improving means translating again with the review's findings; the content was already checked on the source. ```json { "quality": { "score": 70, "verdict": "needs_attention", "bar": 75, "target": 85, "below_bar": true, "requires_review": true, "issues": [], "review_reasons": ["The quality score is 70, below 75, after 2 improvement round(s). Read it before using it."] } } ``` **Score colour (suggested):** green from `bar` up, yellow from 60 to below `bar`, red below 60. **Images:** the URLs are public; download them into your own media library rather than linking to them — the cover (`content.featured_image`) **and the in-text images** (every `` in `content.content_html`, also listed in `content.images`): replace each `src` with your copy and drop its `srcset`, which points at our variants. Your posts then never depend on our server. The same URL always holds the same picture, so a URL you have already copied can be reused instead of downloaded again. The images are AI-generated (`ai_generated: true`) and carry the matching IPTC metadata (digital source type "trained algorithmic media"); do not strip it. **Cover:** an article with `images` set to `all` or `cover` has a cover image (`content.featured_image`, and `role: "featured"` in `details.images`; with `none`, or until it has been made, `featured_image` is `null`): one clear scene that represents the whole article, 16:9 and in the same style as the in-text images, composed so the 1200×630 social crop also works. If the AI image plan has no cover, the system makes one from the title and the brand's visual style. Translations share the same cover. Use it as the post's featured image (above the title, on list cards, `og:image`). --- ## Review: approve, reject, request changes, edit Answer an `in_review` article with one of these: | Call | Result | |---|---| | `POST /articles/{id}/approve` (no body) | Approved; the answer `200` is the article object with the approved content (`content_state: "approved"`), and `article.completed` (or `article.updated` if it had an approved version before) is sent too. Only for `in_review`, otherwise `409 not_in_review`. | | `POST /articles/{id}/reject` with `{ "reason": "…" }` (optional, max 2000) | Rejected; the answer is the article object without content with `status: "rejected"` (or, if it had an approved version before, `ready`/`delivered` with that version). Nothing is delivered and no event is sent. Only for `in_review`. | | `POST /articles/{id}/revise` with `{ "instructions": "…" }` (required, 3 to 5000) | Written again with your instructions (source article: the instructions are added to the topic's notes and only writing, SEO and the quality check run again; research, plan and images are kept; translation: translated again with these instructions). The answer is the article object with `status: "processing"`; the steps are reported again and it ends `in_review` (or is approved automatically if the key does not require review). For `in_review`, `rejected`, `ready`, `delivered`; otherwise `409 not_revisable`. | | `POST /articles/{id}/edit` | Your own edits, as a new version (below). | **Retrying a failed article** (`status: failed`): ``` POST /api/public/v1/articles/{id}/retry ``` - It resumes at **the step that failed**; earlier steps are not repeated (no extra cost). - A translation whose source failed starts the source again and is then translated. - A cancelled article is written anew. - The steps are reported again with `article.stage_*`; at the end, `article.review_required` or `article.completed`. - If nothing is left to resume, the article is written anew. - No body; the answer `200` is the article object (usually `status: "processing"`). - The monthly token limit applies (`429 token_limit_reached`); an article that has not failed → `409 not_failed`. - Suggested panel: on each `failed` article's card, the reason (`error.message` and the step) and a "Retry" button. `revise` and `edit` also work on `rejected`, `ready` and `delivered` articles; the next approved version arrives with `article.updated`. **Editing from the blog's panel:** ``` POST /api/public/v1/articles/{id}/edit ``` ```json { "title": "…", "excerpt": "…", "slug": "…", "primary_keyword": "…", "secondary_keywords": ["…"], "blocks": [ { "id": "p0", "type": "paragraph", "text": "…" } ], "faq": [ { "question": "…", "answer": "…" } ], "seo": { "seo_title": "…", "meta_description": "…", "og_title": "…", "og_description": "…" }, "approve": true } ``` Every field is optional (at least one; a body with nothing to change → `422 invalid_request`). Limits: | Field | Rule | |---|---| | `title` | 3 to 500 | | `excerpt` | max 5000 | | `slug` | max 191; turned into slug form and made unique if taken. If the article was already published, the published slug is kept on approval | | `primary_keyword` | max 191, or `null` | | `secondary_keywords` | array, at most 50 × 191 | | `blocks` | 1 to 400 blocks; `id` (max 40) and `type` required; only the keys `id`, `type`, `level`, `text`, `items`, `table`, `term`, `image_id`, `cta_id` are kept | | `faq` | at most 50; `question` (max 1000) and `answer` (max 5000) required, `source_refs` optional | | `seo` | `seo_title` and `og_title` (max 255), `meta_description` and `og_description` (max 500); merged with the previous values | | `approve` | boolean | Take `blocks` from `details.content.blocks`, edit them and send them back **complete** (they replace all blocks). The new version (`origin: manual_edit`) is rendered, and its structured data and SEO checks are rebuilt; the AI quality check does **not** run again. With `approve: true` it is approved at once (`article.completed`/`updated`); otherwise the article becomes `in_review`, even if it was `ready` or `delivered`, and `article.review_required` arrives with the new preview (even if the key does not require review). The answer `200` is the article object with content. Only for `in_review`, `rejected`, `ready`, `delivered`; otherwise `409 not_editable`. When the source article changes, translations that are not approved yet are re-translated automatically from the new version; an approved translation only changes through `revise`. ### Decisions on checks When your editor deals with a warning, tell us. We learn which checks are noise and which find real problems, and tune them. ``` POST /api/public/v1/articles/{id}/checks/{name}/resolution { "kind": "accepted", "from_source": null, "finding_hash": "1x8k2p", "note": "Fine as it is.", "by": "Sara" } ``` | Field | Rule | Meaning | |---|---|---| | `kind` | **required**: `fixed`, `accepted` or `null` | `fixed`: the editor corrected it; `accepted`: it needs no change; `null`: undo | | `from_source` | language code or `null` | For a translation's checks inherited from its source (the `from_source` of the issue) | | `finding_hash` | max 64 | Your fingerprint of what the check said (stored as is) | | `note` | max 2000 | Why, in the editor's words | | `by` | max 191 | Who decided (shown as given) | - `{name}` is the check's `name` (or the issue's `check`), e.g. `external_references`, `internal_links`, `unsupported_claims`. It must have warned or failed on the version you see (the preview while `in_review`, otherwise the approved one): otherwise `404 unknown_check`; an article not checked yet → `409 not_checked`. - One decision per check and version; sending again replaces it. A new version starts clean. - It applies to **this language only**, also for checks inherited from the source: each language's editor decides on their own text. - Answer `200`: `{ "data": { "check", "from_source", "version", "resolution": { kind, note, by, at } | null, "quality": } }`. **Edited on your side.** When an editor changes the text of an approved article in your panel, say so (best effort, once is enough; repeats are ignored): ``` POST /api/public/v1/articles/{id}/edited { "block_ids": ["p4"] } ``` `block_ids` is optional (the blocks you know changed). Answer `200`: `{ "data": { "version", "edited_at", "first" } }`; an article without an approved version → `409 not_approved`. Nothing changes on our side; the text you have stays yours. --- ## A new version of one image When an editor dislikes one picture (the wrong landmark, people in it, the wrong season), ask for a new version with a short instruction. The image's own prompt is adjusted to the instruction by a small AI step that keeps the house style, the picture's shape and the rules every image follows (no text in the image; no recognisable people unless the content system allows them). The instruction is never used as the prompt on its own. Without an instruction the same prompt is drawn again. ``` POST /api/public/v1/articles/{id}/images/{plan_id}/regenerate { "instruction": "at sunset, no people" } ``` `plan_id` is the image's `id` in `details.images` (for example `f1`; the cover's `role` is `featured`). `instruction` is optional, up to 300 characters. The new picture is a **candidate**: it has its own files (a new address, so nothing cached under the old one shows it) and **nothing changes** until you accept it. It works on approved and delivered articles too. A translation's pictures are its source's, so a candidate made from any language serves every language. Answer `202`: ```json { "data": { "id": "imgc_01J…", "plan_id": "f1", "kind": "regenerated", "status": "generating", "instruction": "at sunset, no people", "url": null, "width": null, "height": null, "ai_generated": true, "error": null, "created_at": "…", "accepted_at": null }, "limits": { "per_day": 3, "used_today": 1, "left_today": 2 } } ``` Follow it until `status` is `ready` (usually within a minute or two; there is no webhook for candidates): ``` GET /api/public/v1/articles/{id}/images/{plan_id}/candidates → { "data": { "image": { "plan_id", "role", "status", "url", "alt_text", "width", "height" }, "candidates": [, …], "limits": { "per_day", "used_today", "left_today" } } } ``` `candidates` are newest first, up to 30. | Candidate `status` | Meaning | |---|---| | `generating` | Being made | | `ready` | Made; can be used | | `failed` | Not made: `error: { code, message }`. `policy_refused`: the image service refused the picture; ask again with a different instruction | | `in_use` | The article shows it now | `kind`: `regenerated` (made on request) or `previous` (a picture the article showed before). **Use one:** ``` POST /api/public/v1/articles/{id}/images/{plan_id}/accept { "candidate_id": "imgc_01J…" } ``` It becomes the article's picture **in every language**: the HTML is rendered again and each language is sent to you again (`article.updated` for an approved article, `article.review_required` for a preview) with the new `featured_image` or in-text image address. The answer (`200`) is the article with its content, plus `image` (as from `…/candidates`), so you can update the post at once. The picture it replaced stays a candidate (`kind: previous`, `status: ready`): accept it the same way to restore it. Images stay marked as AI-generated (IPTC digital source type in the file); nothing removes it. **Limits and errors.** Up to **3 new versions per image per day** (set for your key by the content system team, `tools.image_versions.per_image_per_day`; a refused one counts), then `429 regeneration_limit` (`limit`, `used`, `resets_at`). New versions can be turned off for your key: then `403 tool_disabled` (`tools.image_versions.enabled: false`). Each counts like any image against the key's monthly budget (`429 budget_reached`, `budget_insufficient`) and token limit. `404 unknown_image` (no such `plan_id`), `409 not_ready` (the article has no content yet), `409 image_not_ready` (the image was never made: use `POST /articles/{id}/images/generate`), `409 regeneration_in_progress` (one is being made for this image; `candidate_id`), `409 candidate_not_ready` (accepting one that is still being made, or failed). --- ## Without a webhook (pull) If no webhook is set, nothing is pushed: no event at all (not even `article.stage_*`) is sent, and a page with live updates sees no change until it asks. For live updates, set a webhook URL on the API key; `GET /me` shows in `client.webhook.url` whether one is set (`null` means pull mode). In pull mode, ask yourself: ``` GET /api/public/v1/articles?status=ready&include=content&updated_since=2026-10-03T10:00:00Z GET /api/public/v1/articles/{id}/details POST /api/public/v1/articles/{id}/acknowledge { "url": "…", "external_id": "…", "version": 1 } ``` Sorted by `updated_at` ascending (then by id); `updated_since` only returns items updated **after** that time, so keep the last item's `updated_at` for next time, and since times have one-second precision, ask a few seconds earlier for safety and skip duplicates by `id`. Page with `page` until `meta.has_more` is `false` (at most 20 per page with `include=content`). In this mode the steps are visible in `details.runs[].steps`. Suggested interval: every 1 to 5 minutes. `acknowledge` reports where you published the article: `url` required (`http(s)`, max 1000), `external_id` optional (max 191), `version` optional (the version number you published). The article becomes `delivered` and the answer is the article object. Only for `ready`/`delivered` (otherwise `409 not_ready`); if `version` is not the current approved version → `409 stale_version` (fetch the article again). Calling it again updates the address. With a webhook you may also use it instead of answering the webhook with a URL. ## Your search data: Search Console and Analytics Connect the Google account that owns your site in Search Console (and, optionally, Google Analytics 4). Access is read-only. From then on: - **Your articles are written for what people really search.** Research, planning and writing get the real queries people use for each article's subject on your site (with impressions and your position), your pages already ranking for them (the new article takes its own angle and links to them instead of competing), and your pages that keep readers best. Nothing of this appears in the article text. - **You get insights:** what the figures say is worth doing, each with the clicks a month it is likely worth, best first. The figures cover the last two 28-day periods (ending three days ago, as Google's figures settle) and are pulled again every night; only pages under your site's address count. Search data and [title finding](#finding-titles) are about your site, which is set up with your first request. To use them before that, set it up yourself (safe to call again): `POST /site` with `{ "url": "https://yourblog.com", "name": "…", "description": "…", "language": "fa" }` → `{ "data": { "id", "name", "base_url", "language" } }` (`language`: your main language, used when the site has none yet). Without it they answer `404 no_website`. ### Connecting ``` POST /api/public/v1/google/connect { "return_to": "https://yourblog.com/admin/insights" } → 200 { "url": "https://accounts.google.com/o/oauth2/v2/auth?…" } ``` Send the person to `url`. After Google's sign-in they come back to `return_to` with `?google=connected` (ready; the first figures arrive within a minute or two), `choose` (signed in, but none of the account's Search Console properties covers your site: let them pick one), `denied` (they did not allow access) or `error` (with `&message=…`). The link is good for 20 minutes. Connecting again replaces the account. **Or with a service account** (no sign-in): a Google service account reads what it was added to as a user, so the person adds its email in Search Console (Settings → Users and permissions, *Restricted* is enough) and in Analytics (Admin → Property access management, *Viewer*). ``` POST /api/public/v1/google/service-account { "key": { "type": "service_account", "client_email": "…", "private_key": "…", … } } → 200 { "result": "connected", "data": { …as GET /google… } } ``` - With `key` (the service account's JSON key file, as an object or a string): your site's own service account. The key is stored encrypted and never returned. `422 invalid_key` when it is not a service account key. - Without it: this service's shared service account, whose email is `GET /google` → `data.service_account.email` (`422 google_not_configured` when `data.service_account.available` is `false`). `result` is `connected`, or `choose` when Google shows it no Search Console property for your site yet: `last_error` then says what to add. Once the email is added, `POST /google/sync` finds the properties again. Connecting again (either way) replaces the previous connection. `GET /google` → `data`: | Field | Meaning | |---|---| | `configured` | `false`: this service has no Google sign-in set up yet; `POST /google/connect` answers `422 google_not_configured` | | `service_account` | `{ available, email }`: whether this service has a shared service account, and its email (what to add to your properties) | | `connected` | Whether an account is connected | | `method` | `oauth` (signed in) or `service_account`; `null` when not connected | | `own_key` | With a service account: `true` when it is your own key, `false` for the shared one | | `account_email` | The Google account, or the service account's email | | `status` | `connected`, `error` (see `last_error`) or `revoked` (access withdrawn or expired: connect again) | | `search_console` | `{ property, choices[] }`: the property used (`sc-domain:example.com` or a URL prefix), and those the account can read | | `analytics` | `{ property, choices[{id, name, uri}], granted }`: the GA4 property used (`properties/123`), those the account can read with their stream address, and whether Analytics access was granted | | `last_synced_at` | When the figures were last pulled (ISO 8601), `null` before the first time | | `last_error` | Why the last pull failed, if it did | `PATCH /google` with `{ "search_console": "…", "analytics": "…" }` (either; `null` clears it) chooses the properties from `choices` (`422 unknown_property` for another one) and pulls the figures again. `POST /google/sync` finds the properties again and pulls the figures now (`{ "queued": true, "data": { …as GET /google… } }`; `422 not_connected` without a working connection). `DELETE /google` disconnects and deletes the figures and the insights. ### Insights `GET /insights?type=…&status=new&page=1` → 30 a page, best first: ```json { "counts": { "gap": { "count": 2, "worth": 121 }, "striking": { "count": 1, "worth": 239 } }, "data": [ { "id": 41, "type": "striking", "title": "Diving in Kish", "score": 239.3, "status": "new", "article_id": 12, "updated_at": "2026-10-18T04:31:12+00:00", "detail": { "page": "https://yourblog.com/kish-diving", "article": { "id": 12, "title": "Diving in Kish" }, "impressions": 2300, "clicks": 14, "position": 11.4, "ctr": 0.0061, "queries": [{ "query": "kish diving spots", "impressions": 2300 }] } } ], "meta": { "current_page": 1, "last_page": 1, "total": 1 } } ``` `score` is the clicks a month the insight is likely worth; `counts` totals the open ones by type. `article_id` and `detail.article` are our article for that page, when there is one. | `type` | What it says | What to do | `detail` | |---|---|---|---| | `gap` | People search for it (on your subject), nothing of yours ranks well | Write an article for it (`title` is the query) | `query`, `impressions`, `position`, `before`, `related[]` | | `rising` | Searches for it at least doubled (`before: 0`: new) | Write or update it while it grows | `query`, `impressions`, `before`, `position`, `pages[]` | | `striking` | A page ranks just off page one (positions 8–20 by default) | Strengthen it | `page`, `article`, `impressions`, `clicks`, `position`, `ctr`, `queries[]` | | `ctr` | A page ranks well but few click | Rewrite its title and description | the same, and `expected_ctr` | | `decay` | A page lost a share of its clicks against the 28 days before | Refresh it | the same, and `clicks_before` | | `cannibal` | Several of your pages split one query | Merge them, or give each its own angle | `query`, `impressions`, `pages[]` | | `engagement` | Visitors arrive but leave quickly (Analytics) | Improve the opening and structure | `path`, `article`, `sessions`, `views`, `engaged_rate`, `seconds_per_session`, `key_events` | `PATCH /insights/{id}` with `{ "status": "done" | "dismissed" | "new" }` records your decision. A done or dismissed insight leaves the list and comes back only when it is worth twice as much as when you decided; `status=done` or `status=dismissed` lists them, `new` puts one back. To act on a `gap` or `rising` insight, send it as a request: its `title` as the title and its queries (`detail.query`, `detail.related[].query`) as `keywords`. `GET /search-pages` → `data`: `totals` (`clicks`, `clicks_before`, `impressions`, `impressions_before`, `sessions`) and `pages[]` (up to 50, most clicks first: `page`, `article`, `clicks`, `clicks_before`, `impressions`, `position`, `sessions`, `engaged_rate`, `seconds_per_session`, `key_events`; the Analytics fields are `null` without Analytics). ## Finding titles The title finder suggests titles worth writing for your site now. It looks at what people are searching for, reading and talking about, from the trend sources your policy turns on: | `source` | What it gives | |---|---| | `search_console` | Searches already reaching your site that nothing answers yet, or that grow fastest ([your search data](#your-search-data-search-console-and-analytics)). Google's own data: weighed most | | `dataforseo` | Searches around each seed topic with their real monthly volume and trend (Google Ads data), with your own DataForSEO account. Every suggested title then gets its keywords' volume, trend, competition and cost per click | | `google_trends` | Today's fastest-rising searches in your country (Google Trends), with their volume and the news behind them | | `autocomplete` | What people type after each seed topic (Google's search suggestions), in your language | | `serpapi_trends` | Rising searches related to each seed topic this week, with how much, with your own SerpApi key | | `news` | This week's news headlines about the seed topics | | `wikipedia` | Yesterday's most-read Wikipedia articles in your language | The paid sources use your own accounts (`keys` in your policy); you pay their providers for your use. Without one, a source is `available: false` (unless this service offers its own). Persian has no country of its own in Google Ads data: it is looked up worldwide, in Persian. The model keeps only what fits your site, follows your policy, checks with web search that a trend is real, and never suggests a title you already have or were already suggested. ### Your policy `GET /title-policy` → `data`; `PUT /title-policy` sets any of these (the others are kept): | Field | Meaning | |---|---| | `instructions` | Your standing instructions: tone, audience, what fits your brand, what titles should and should not be (max 5000) | | `seeds` | Topics to look into (up to 30, each max 100). Empty: your site's own keywords | | `avoid` | Topics never to suggest (up to 50) | | `language` | The default language code of the titles (each run can choose another); `null`: your site's default. Keep `instructions` free of a language: titles follow the run's language | | `market_from_instructions` | `true`: `language` and `geo` are read from `instructions` by the AI each time the policy is saved (what they say about the titles' language and the readers' country; places that are only subjects do not count), `null` when they do not say. The answer to that `PUT` then has `market_read: { language, geo, cost_usd, priced }` (with `error` when they could not be read: the policy is saved and its language and country stay as they were) | | `explain_language` | Language code the reasons, `angle` and `why` are written in (for the people choosing titles); `null`: the titles' language | | `geo` | Country, two letters (`IR`, `US`…); `null`: one for the language | | `sources` | The `source` keys to use; `null`: all available | | `count` | Titles a run suggests (3–30); `null`: 10 | | `paused` | `true`: scheduled runs stop (runs you ask for still work). For example while your own customer cannot pay for them | | `max_difficulty` | 0–100 or `null` (no limit). With `dataforseo`, each title's main keyword is looked up for how hard it is to reach Google's first page (DataForSEO keyword difficulty, from the pages already ranking); titles harder than this are not kept. For a new site with little authority, 20–30. Keywords without data (often very specific ones) are kept. Not available for Persian or without a country | | `schedule` | `off`, `daily` (every morning) or `weekly` (Mondays) | | `keys` | Your accounts for the paid sources: `{ "dataforseo": { "login": "…", "password": "…" }, "serpapi": { "api_key": "…" } }`. Stored encrypted and never shown again; an empty secret keeps the stored one; `null` for a provider removes it | The answer also has `effective` (the language, country, seeds and count a run uses now), `available_sources[{key, label, description, available}]`, `keys` (per provider `{set, origin: "website" | "platform" | null, login}`: never a secret), `running`, `last_run_at` and `last_run` (`run_id`, `cost_usd`, `scheduled`, `signals`, `suggested`, `kept`, `duplicates`, `too_hard` (left out by `max_difficulty`), `weak` (left out for too few backed reasons), `difficulty_error` if that lookup failed, and per source `{signals}` or `{error}`; one source failing does not stop a run). ### Setting the policy up in a conversation Instead of a form, you can let your user set the policy up by talking with an AI assistant. It looks at your site, asks a few questions (what you sell, to whom, where, what to avoid, how strong the site is) and fills a draft policy as it learns. ``` POST /api/public/v1/title-policy/assistant { "messages": [{ "role": "assistant", "content": "…" }, { "role": "user", "content": "…" }], "draft": { …the last draft… }, "blog_url": "https://yourblog.com/blog" } → 200 { "data": { "reply": "…", "ready": false, "suggestions": ["…"], "draft": { "instructions", "seeds", "avoid", "language", "explain_language", "geo", "max_difficulty", "count", "schedule" }, "cost_usd": 0.0123 } } ``` - Start with `messages: []`: the assistant introduces what it saw of your site and asks its first question. Then send the whole conversation each turn (its replies as `assistant`, your user's answers as `user`, up to 40), and the `draft` of the previous turn. - It replies in the language your user writes in. `suggestions`: up to four short answers to offer as buttons. `ready: true`: the draft is complete; show it and let your user save it or ask for changes. - Nothing is saved: `PUT /title-policy` with the `draft` saves it (it always passes the policy's rules). `cost_usd` is what the turn cost, if you charge your users for it (`priced: false`: no price for the model, so it reads 0). - A turn takes up to a minute (the assistant looks at your site). `502 assistant_failed`: try again. ### A help assistant for your users `POST /assistant` puts an assistant in your admin that answers your users' questions about these tools and guides them through setting things up (Google, DataForSEO, SerpApi, the policy), from your site's real state. It does nothing itself: it offers the next steps as actions, which you carry out with the matching endpoints when your user clicks them. ``` POST /api/public/v1/assistant { "messages": [{ "role": "user", "content": "How do I connect Search Console?" }], "client": { "app": "My CMS", "actions": ["connect_google_shared", "check_google", "set_dataforseo", "update_policy", "navigate"], "navigation": [{ "key": "ideas", "label": "Ideas" }], "user_role": "admin", "page": "ideas", "wallet_usd": 12.5 } } → 200 { "data": { "reply": "…", "actions": [{ "type": "connect_google_shared", "label": "Connect" }], "suggestions": ["…"], "cost_usd": 0.004 } } ``` - `messages`: the whole conversation, ending with your user's message (up to 40). It replies in their language. - `client` (all optional): `actions` you can carry out (only those are offered; default all), `navigation` pages you can send them to, and anything that helps it answer (`app`, `user_role`, `page`, `wallet_usd`, `notes`). Give it `guide` (your app's own user guide, up to 40,000 characters: how your pages and buttons work) and `blog` (facts about the blog: name, address, languages, recent posts, categories...) and it answers how-to questions about your app and gives advice about the blog itself. It is a content and SEO advisor too: it talks about anything that helps the blog, and uses web search for current facts. - Actions and what to do for each: `connect_google_shared` → `POST /google/service-account`; `connect_google_own_key` → ask for the JSON key in your own secure field, then `POST /google/service-account` with `key`; `google_sign_in` → `POST /google/connect`; `check_google` → `POST /google/sync`; `choose_google_property` (`search_console`, `analytics`) → `PATCH /google`; `set_dataforseo` / `set_serpapi` → ask for the secret in your own field, then `PUT /title-policy` with `keys`; `remove_key` (`provider`) → `PUT /title-policy` with `keys: { provider: null }`; `update_policy` (`policy`: only the fields to change) → `PUT /title-policy`; `draft_policy` → draft the whole policy in a conversation (`POST /title-policy/assistant`); `run_titles` (`run_instructions`, and `policy` with what this run changes) → `POST /title-runs` with `instructions` and those fields; `navigate` (`to`). Offered actions are checked against the current state (for example a property must be one the account can read). - Secrets never go through the assistant: it is told to offer the action instead of asking for them. - `cost_usd`: what the turn cost; `priced: false` when this service has no price for the model used, so `cost_usd` is 0 although the AI answered. `502 assistant_failed`: try again. ### Running it `POST /title-runs` with `{ "instructions": "…" }` (optional, max 5000: this run only, on top of the policy) → `202 { "queued": true }`. The titles arrive in a minute or two; `running` in `GET /title-suggestions` or `GET /title-policy` says when it is still going. One run at a time: another answers `409 already_running`. A run can also differ from the policy, this time only (nothing is saved): add any of `count` (3–30), `language`, `explain_language`, `geo`, `seeds`, `avoid` and `max_difficulty`, with the policy's own rules; for example `{ "count": 5, "language": "ar", "seeds": ["ramadan trips"] }`. They show in `last_run.overrides`. Every run, scheduled ones and failed ones included, is announced with the `titles.found` webhook: ```json { "type": "titles.found", "data": { "run": { "id": 42, "scheduled": true, "cost_usd": 0.0381, "kept": 9, "error": null, "at": "2026-10-19T05:02:11+00:00" } } } ``` `cost_usd` is what the run cost this service (`priced: false`: no price for the model, so it reads 0; the AI, and DataForSEO when this service's own account was used; your own DataForSEO or SerpApi account bills you directly). If you charge your users for runs, charge it once per `run.id`. Scheduled runs stop while your client is switched off, or while the policy is `paused`. ### Suggestions `GET /title-suggestions?status=new&page=1` → 30 a page, best first: ```json { "counts": { "new": 8, "accepted": 1 }, "data": [ { "id": 7, "title": "Kish Island Winter Festival: Dates, Events and Where to Stay", "language": "en", "angle": "A practical guide to the festival week.", "why": "Searches jumped to 20K+ today.", "reasons": [{ "text": "Kish island festival is rising with 20K+ searches today.", "basis": "signal", "source": "google_trends", "url": "https://…" }, { "text": "The festival runs December 1–20.", "basis": "web", "source": "kish.ir", "url": "https://kish.ir/…" }, { "text": "“kish island festival” is searched about 12,000 times a month on Google.", "basis": "data", "source": "dataforseo", "url": null }, …], "keywords": ["kish winter festival"], "ai_queries": ["when is the kish winter festival this year", "is kish worth visiting in december"], "content_type": "guide", "kind": "trending", "priority": 5, "score": 130, "signals": [{ "source": "google_trends", "term": "kish island festival", "value": "20K+ searches", "url": "https://…" }], "metrics": { "volume": 12000, "trend": 1.4, "keywords": [{ "keyword": "kish winter festival", "volume": 12000, "trend": 1.4, "competition": "LOW", "cpc": 0.42 }] }, "status": "new", "created_at": "2026-10-18T05:02:11+00:00" } ], "meta": { "current_page": 1, "last_page": 1, "total": 8 }, "running": false } ``` `ai_queries`: what people ask AI assistants about it and the searches those run, in the titles' language; they fit straight into `POST /requests` (`ai_queries`). `reasons`: why the title was chosen, in `explain_language`: at least 5, at least 3 of them backed by evidence. `basis`: `signal` (a signal it came from: `source` and `url` are the signal's), `web` (a page found while researching: `url`), `data` (the keywords' real figures from DataForSEO, stated from the data), `policy`, `audience`, `gap` (what your posts do not cover yet) or `season`. Titles without enough backed reasons are not kept (`last_run.weak`). `kind`: `trending` (rides something rising now), `seasonal` (a date or season) or `evergreen`. `priority` 1–5 (5: write it first). `signals`: what the title came from. `metrics` (with `dataforseo`, else `null`): each keyword's monthly search `volume`, `trend` (the last three months against the year: `1.4` = 40% above usual), `competition` (Google Ads advertisers, not organic difficulty), `cpc` and, with `max_difficulty` set, `difficulty` (0–100); the title's `volume` and `trend` are those of its most searched keyword, its `difficulty` that of its main keyword. Titles are ordered by `score`: the model's priority, the signals behind them, your own search data, their search volume and how easy they are to rank for. `content_type` and `keywords` fit straight into `POST /requests`. `PATCH /title-suggestions/{id}` with `{ "status": "accepted" | "used" | "dismissed" | "new" }` records your decision (`used`: you wrote it). To write one, send it as a request: its `title`, its `keywords`, its `content_type`. --- ## All endpoints Base: `https://content.nx.plus/api/public/v1` (get the real address from the Keys & webhook tab). All require the API key; all count against the key's rate limit. | Method and path | Purpose | |---|---| | `GET /me` | Key, settings, quota, in-progress limit and token usage | | `GET /languages` and `GET /content-types` | Languages and content types | | `POST /requests/estimate` | What a request would cost, and whether it fits this month's budget | | `POST /requests` | Send a topic and languages | | `GET /requests` and `GET /requests/{id}` | List and status of requests | | `POST /requests/{id}/cancel` | Cancel the articles still in progress | | `POST /requests/{id}/languages` | Add languages to the same topic (translations of the same article), even mid-production | | `POST /translations` | Translate one of your own posts (text only; markup, links and images kept) | | `POST /images` and `GET /images/{id}` | A cover or in-text picture for one of your own posts, and new versions of it | | `GET /articles` | List articles (`status`, `language`, `updated_since`, `include=content`) | | `GET /articles/{id}` | Summary + content (preview or approved) | | `GET /articles/{id}/details` | Full record (`?version=N`) | | `POST /articles/{id}/approve`, `reject`, `revise`, `edit` | Review | | `POST /articles/{id}/retry` | Retry a failed article | | `POST /articles/{id}/checks/{name}/resolution` | Your decision on a quality check: fixed, OK as is, or undo | | `POST /articles/{id}/edited` | Your editor changed the approved text | | `POST /articles/{id}/images/generate` | Your post has no picture: get the ones made, generate the missing ones | | `POST /articles/{id}/images/{plan_id}/regenerate` | A new version of one image, with an instruction (a candidate) | | `GET /articles/{id}/images/{plan_id}/candidates` | The image now and its other versions | | `POST /articles/{id}/images/{plan_id}/accept` | Use one version, in every language (also to restore the previous one) | | `POST /articles/{id}/acknowledge` | Report the published address (pull) | | `POST /webhook/test` | Send a `ping` | | `POST /site` | Set up your site before your first request (url, name, main language) | | `GET /google`, `PATCH /google`, `DELETE /google` | Your Search Console and Analytics connection: see it, choose its properties, disconnect | | `POST /google/connect` | Where to sign in to Google (`return_to`: your page to come back to) | | `POST /google/service-account` | Read through a service account instead: your own `key`, or the shared one | | `POST /google/sync` | Pull the search figures now | | `GET /insights`, `PATCH /insights/{id}` | What your search data says is worth doing; done or dismissed | | `GET /search-pages` | Your pages by search clicks, with Analytics figures | | `GET /title-policy`, `PUT /title-policy` | Your title finder policy: instructions, seed topics, topics to avoid, market, sources, schedule | | `POST /assistant` | The help assistant: answers your users and offers set-up actions from your site's state | | `POST /title-policy/assistant` | One turn of setting the policy up in a conversation with an AI assistant | | `POST /title-runs` | Find titles now (optional one-off `instructions`) | | `GET /title-suggestions`, `PATCH /title-suggestions/{id}` | Titles worth writing, with why and the trends behind them; accept, mark written, dismiss | **Pagination** (`GET /requests` and `GET /articles`): `?page=1&per_page=20` (default 20, max 100; `GET /articles?include=content` max 20). Answer: `{ "data": [...], "meta": { "page": 1, "per_page": 20, "total": 57, "has_more": true } }`. ### `GET /languages` The active languages this key may request: `{ "data": [{ "code": "fa", "name": "Persian", "native_name": "فارسی", "direction": "rtl" }] }`. ### `GET /content-types` `{ "data": ["guide", "how_to", "comparison", "listicle", "explainer", "review_roundup", "definition", "news_analysis", "landing_support"] }` ### `POST /requests/estimate` The same body as `POST /requests`; only `languages` and `images` matter. Nothing is created. ```json { "data": { "currency": "USD", "articles": 3, "translations": 2, "images": 1, "estimated_cost": 0.66, "budget": { "monthly_usd": 50, "used_usd": 10.73, "remaining_usd": 39.27, "percent": 21, "resets_at": "2026-11-01T00:00:00+00:00" }, "fits_budget": true } } ``` `estimated_cost` is `null` while there is no history to estimate from; `budget` and `fits_budget` are `null` when the key has no budget. Unsupported languages → `422` as for a real request. ### `POST /requests` Body: the table under [Creating a request](#creating-a-request). Optional `Idempotency-Key` header. Answer `202` (created) or `200` (that `external_ref` existed): `{ "data": }`. **Request object:** | Field | Meaning | |---|---| | `id` | Request id (ULID, no prefix) | | `kind` | `article` (a topic we write) or `translation` (one of your posts, `POST /translations`) | | `external_ref` | Your id, or `null` | | `status` | `processing`, `completed`, `partially_failed`, `failed`, `cancelled` | | `title` | Topic | | `languages` | The request's languages (updated when languages are added) | | `site` | `{ name, url }` | | `options` | Options sent (`images` always present; for a translation also `post_ref` and `source_language`) | | `errors` | Languages that could not be created: `[{ language, error }]` | | `usage` | Everything this topic cost, the source and its translations together | | `articles` | Article objects (without content), requested languages only | | `created_at` | When it was created | ### `POST /translations` Body and answers: see [Translating your own posts](#translating-your-own-posts). Answer `202` (created) or `200` (that `external_ref` existed): `{ "data": }` with `kind: "translation"`. ### `GET /requests` This key's requests, newest first; filter `?external_ref=…`. Paginated as above. ### `GET /requests/{id}`, `POST /requests/{id}/cancel`, `POST /requests/{id}/languages` `{ "data": }`; adding languages: `202` and `{ "data": , "added": ["it"] }` (body: `languages`, an array of 1 to 20 codes). ### `GET /articles` | Parameter | Value | |---|---| | `status` | `processing`, `in_review`, `ready`, `delivered`, `failed`, `rejected` | | `language` | Language code | | `updated_since` | Date/time; only items updated after it | | `include` | `content` = include the content (for `in_review`/`ready`/`delivered`) | | `page`, `per_page` | Pagination | Only articles in requested languages (older requests may have an internal English source; it never appears), ordered by `updated_at` ascending. ### `GET /articles/{id}` `{ "data":
}` (content only for `in_review`/`ready`/`delivered`). ### `GET /articles/{id}/details?version=N` `{ "data": }`; a version that does not exist → `404 not_found`. ### `POST /articles/{id}/approve | reject | revise | edit | retry | acknowledge` See [Review](#review-approve-reject-request-changes-edit) and [Without a webhook](#without-a-webhook-pull). `approve` and `edit` return the article object **with** content; the others without. ### `POST /articles/{id}/checks/{name}/resolution`, `POST /articles/{id}/edited` See [Decisions on checks](#decisions-on-checks). ### `POST /articles/{id}/images/generate` For a "Generate cover" button: your post has no picture (or lost one). No body. - **Every image is ready here** → `200`, with the article and its content, so you can take `content.featured_image` (and `content.content_html` with the in-text images) right away. - **Some are missing** → `202`. They are generated now — for a translation, on its source, so every language gets the same picture — and the article reaches you by webhook the moment they are made: `article.updated` (approved) or `article.review_required` (preview). Calling again while they are being made does not make them twice. ```json { "data": { "id": "art_01J…", "status": "ready", "content": { "featured_image": { "url": "https://content.nx.plus/storage/images/…/cover.webp", "alt": "…" }, "…": "…" } }, "images": { "total": 3, "ready": 3, "pending": 0, "complete": true } } ``` `images`: `total` planned images, `ready` now, `pending` on their way, `complete` = all ready. Errors: `409 not_ready` (the article has no content yet; images are made with it), `409 no_images` (requested with `images: "none"`). Image generation is not counted against the key's token limit. ### `POST /articles/{id}/images/{plan_id}/regenerate`, `GET …/candidates`, `POST …/accept` See [A new version of one image](#a-new-version-of-one-image). `regenerate`: body `{ "instruction"? }`, answer `202` `{ "data": , "limits" }`. `candidates`: `200` `{ "data": { image, candidates, limits } }`. `accept`: body `{ "candidate_id" }`, answer `200` `{ "data":
, "image": { image, candidates, limits } }`. ### `POST /webhook/test` Sends a `ping` to the key's webhook right away (synchronously, one attempt): `{ "data": { "event_id": "evt_…", "status": "succeeded", "http_status": 200, "error": null } }` (`status` is `succeeded` or `failed`). Without a webhook URL → `422 no_webhook`. --- ## Errors ```json { "error": { "code": "invalid_request", "message": "…", "fields": { "title": ["…"] } } } ``` | Status | `code` | Meaning | Retry? | |---|---|---|---| | `401` | `unauthorized` | Key missing or invalid | No | | `403` | `client_disabled` or `language_not_allowed` | Key disabled, or a language not allowed | No | | `403` | `tool_disabled` | Translating your own posts, pictures for them, or new versions of our images is off for your key (`GET /me` → `tools`) | No | | `404` | `not_found` | No such id (or it belongs to another key) | No | | `404` | `unknown_check` | The check did not warn or fail on the version you see | No | | `404` | `unknown_image` | The article has no image with this `plan_id` | No | | `409` | `not_in_review`, `not_revisable`, `not_editable`, `not_ready`, `stale_version`, `not_failed`, `no_images`, `not_checked`, `not_approved` | The article is not in a state that allows this | No | | `409` | `request_cancelled` | Languages cannot be added to a cancelled request | No; send a new request | | `409` | `not_supported` | Adding languages to a translation of your post: send a new `POST /translations` | No | | `409` | `translation_exists` | This post (`post_ref`) is being translated into, or already has, one of these languages; `languages: { code: status }` | When it finishes, or with `retranslate: true` for a finished one | | `409` | `image_not_ready`, `regeneration_in_progress`, `candidate_not_ready` | The image was never made; a new version is being made (`candidate_id`); the version is not ready | Once it is made | | `422` | `no_new_languages` | The request already has all these languages | No | | `422` | `invalid_request` | Invalid input; `fields` has each field's errors | No | | `422` | `unsupported_language` | Unknown or inactive language | No | | `404` | `no_website` | Search data before your first request (your website is set up with it) | After a request | | `409` | `already_running` | Titles are already being found for your site | When `running` is `false` | | `422` | `google_not_configured` | This service has no Google sign-in (or, without `key`, no shared service account) set up yet | No; ask the service's operator | | `422` | `not_connected` | No working Google connection (connect, or connect again when `status` is `revoked`) | After connecting | | `502` | `assistant_failed` | The policy or help assistant could not answer | Yes, a moment later | | `422` | `invalid_key` | The service account key is not one (or its private key cannot be read) | No; fix the key | | `422` | `unknown_property` | That Search Console or Analytics property is not among the account's `choices` | No | | `422` | `content_required` | `POST /images` without a `description` and with fewer than 30 words of the post's `content`; `words`, `min_words` | After the post is written | | `422` | `same_language`, `empty_content` | `POST /translations`: the post's own language was asked for; the post has no text | No | | `422` | `site_required` | No `site.url` and the key has no default site | No | | `422` | `no_articles_created` | No language could be created; `errors: [{ language, error }]` | No | | `422` | `no_webhook` | `POST /webhook/test` without a webhook URL | No | | `429` | `rate_limited` | Too many requests per minute | After `Retry-After` | | `429` | `quota_exceeded` | The request (or the added languages) would go over the daily article quota; nothing is created. `quota`, `used`, `available` (how many more fit today), `requested`, `resets_at` | With at most `available` languages, or after `resets_at` | | `429` | `token_limit_reached` | Monthly token limit; `limit`, `used`, `resets_at` (start of next month) | After `resets_at` | | `429` | `budget_reached` | This month's AI budget is used up; `budget`, `used`, `remaining`, `resets_at` | After `resets_at`, or when the budget is raised | | `429` | `budget_insufficient` | The request's estimate does not fit in what is left; `estimated_cost`, `budget`, `used`, `remaining`, `resets_at` | With fewer languages or images, or when the budget is raised | | `429` | `image_limit` | Today's pictures for your own posts are used up; `limit`, `used`, `resets_at` | After `resets_at` | | `429` | `regeneration_limit` | This image had its new versions for today; `limit`, `used`, `resets_at` | After `resets_at` | | `429` | `too_many_in_progress` | The blog reached its limit of articles in progress (`in_progress`, `max_in_progress`, `available`) | After some articles finish, or with fewer languages (at most `available`) | | `5xx` | — | Transient error | Yes, with growing backoff | A `429 quota_exceeded` example: ```json { "error": { "code": "quota_exceeded", "message": "Only 2 more article(s) can be requested today (daily limit 20, 18 used); this asks for 3. Choose at most 2 language(s), or wait until tomorrow.", "quota": 20, "used": 18, "available": 2, "requested": 3, "resets_at": "2026-10-04T00:00:00+00:00" } } ``` An unknown path, a wrong method or an internal server error may be answered in the default shape `{ "message": "…" }` (without `error.code`); your code should cope with both shapes. **Article error** (`article.error` when `failed`): `{ "code", "stage", "message" }`. `stage` is the step that failed (or `cancelled` for a cancellation, `translation_source` when a translation's source failed). Common codes: `cancelled`, `duplicate`, `source_failed`, `ai_no_credit`, `stalled`, and the steps' technical codes (e.g. `unexpected`, `images_partial`); without a code, `generation_failed`. `stalled`: the article stopped making progress (for example its work was interrupted on our side); it is resumed automatically, twice, and fails with this code only if it still does not move — `POST /articles/{id}/retry` then starts it again. The list is not closed. `message` is written for users and has no internal detail. If the code is `ai_no_credit`, **the content system's AI service account has run out of credit** (not your limit and not a CMS error). Tell the user to contact the content system team; once it is topped up, `POST /articles/{id}/retry` resumes from the same step. --- ## AI cost and usage Every article is written by an AI service that charges per use, and that cost is recorded against the blog's API key. Two things cost money: - **Tokens**: the text the AI reads and writes (research, writing, SEO, quality control, translation). - **Images**: each image made. **The most expensive part**; one image usually costs more than an article's whole text. More languages add little: the article is written once (in its source language) and translated, and translations reuse the same images. All amounts are in **US dollars** and are **estimates** (from the prices the content system team set for each model), not the provider's exact bill. **Spend shape** (`Spend`), the same everywhere: ```json { "input_tokens": 41230, "output_tokens": 9120, "total_tokens": 50350, "images": 4, "cost_usd": 1.0731 } ``` | Where | What | |---|---| | `GET /me` → `usage.today` / `usage.month` / `usage.all_time` | These fields + `articles`; the key's whole usage in that period | | `GET /me` → `usage.currency` | `"USD"` | | `GET /me` → `usage.pricing_configured` | `false` means some models have no price, so amounts read low (zero); tell the user | | Article (`data.article.usage` in every event, `GET /articles/{id}`) | The usage of **that article itself**: for the source, research, writing and images; for a translation, its translation and review | | Article → `images` | `all` / `cover` / `none`, the choice made for this article | | Request (`data.request.usage` in every event, `GET /requests/{id}`) | The **whole** cost of the topic: the source and every translation | | `details.runs[].tokens` | Tokens per run (no dollars) | **Estimate before sending**: `GET /me` → `estimates` (averages over the last 90 days of real work): ```json { "estimates": { "currency": "USD", "article_text": 0.31, "translation": 0.05, "image": 0.25, "images_per_article": 4.0 } } ``` | Field | Meaning | |---|---| | `article_text` | One full article without images (research, writing, SEO, quality control) | | `translation` | One translation with its review | | `image` | One image | | `images_per_article` | Average number of images of an article with `images: "all"` (4.0 when there is no history) | `article_text` and `translation` are `null` while there is no history (show no estimate); `image` falls back to the configured list price, and is `null` only when there is none. Estimating one request: ``` translations = number of requested languages − 1 (one is written, the others translated from it) images = all → image × images_per_article · cover → image · none → 0 estimate = article_text + translations × translation + images ``` `POST /requests/estimate` does this sum for you, and also says whether it fits the budget. ### Monthly budget A key can have a monthly AI budget in US dollars (`client.monthly_budget_usd`, set by the content system team). `GET /me` → `budget` says where it stands. While it lasts, everything works as usual; then: - when this month's spend has reached the budget, nothing new starts — a new request, added languages, a retry or generating a missing image answer `429 budget_reached`; articles already being written finish; - a new request (or added languages) whose estimate is more than what is left answers `429 budget_insufficient` with `estimated_cost`; - on the first of the month it starts again from zero (`resets_at`). Show the budget next to the request form (spent, left, a bar) and the estimate against what is left, so the user is not surprised by a refusal. --- ## Building it into a blog panel, end to end **Adding a language to a topic (suggested):** - At the top of each topic's page, under the delete button, an "Add language" dropdown with the languages from `GET /languages` that the topic does not have yet. Do not offer a language the user removed on your side (it comes back from "Removed"; on the content system side it is still part of the request and you would get `no_new_languages`). - When a language is chosen, show a short confirmation ("a translation of this same article, with the same quality check; about `estimates.translation` dollars"), then call `POST /requests/{id}/languages`. - Build the new card from the answer's `data.articles` (upsert by `id`); the rest arrives by webhook. - If the blog is at its in-progress limit (`in_progress >= max_in_progress`), disable the dropdown and say to wait; also show a `429 too_many_in_progress` error next to it. - Hide the dropdown for a cancelled request. **The in-progress limit (must implement):** - When the new-request form opens, read `GET /me`. If `client.max_in_progress` is above zero, compute `available = max_in_progress - in_progress` and write next to the submit button: "8 of 10 articles are being written now; you can ask for up to 2 more (each language is one article)". - If more languages are selected than `available`, turn the message red ("choose at most 2 languages or wait for some articles to finish") and **disable the submit button**; if `available` is zero, say to wait. - The number can change between reading and sending, so also handle a `429 too_many_in_progress` answer and show its `message` (or your own text with `available`) next to the form. Do not clear the form's inputs. - Do not hard-code the limit in the CMS; the content system team can change it at any time. **Cost and images (must implement):** - **New request form**: an image choice with three options ("cover + in-text images", "cover only", "no images") and, when images are chosen, a **warning**: "images use most of the budget; one image costs about `estimates.image` dollars…; to save, choose cover only or no images". Next to the submit button, show a **cost estimate** with the formula in [AI cost and usage](#ai-cost-and-usage), updated with every change of languages or image option. Send the value as `images`. - **AI content page**: show "cost this month" (`usage.month.cost_usd`) and "tokens this month" (`usage.month.total_tokens`, and the image count) next to the counters, with a short note: the cost is for tokens and images, images are the most expensive, more languages cost little. If `usage.pricing_configured` is false, say the amounts may read low. - **Each topic**: `request.usage` (from events), e.g. "AI cost $1.07 · 50k tokens · 4 images". - **Each article card**: `article.usage`, the cost and tokens of that article (for a translation only the translation and its review; the source's writing and images count on the topic). - **`ai_no_credit` error**: say clearly that the AI service has run out of credit and to try again once it is topped up. **Translating a post written in the blog (suggested):** - On the post editor, next to "Add translation", a "Translate with AI" button (editors and up). It offers the languages from `GET /languages` that the post has no version in yet, and an optional note for the translator. - Send `POST /translations` with the post's HTML exactly as stored, its SEO fields and FAQ, `post_ref` = the post id, `external_ref` = a row you create first, and `link_map` built from the links in the post to your other posts (their versions in the target languages). - Show each language's progress on the post page; on `article.review_required` create a **draft** post in the same translation group as the original, with the original's cover, category and tags, and the translated slug and SEO fields. Never change the original. - Remember a hash of the original's text when you sent it. When it differs later, show "the original changed since" on the translation with a "Re-translate" action (`retranslate: true`), and write the new text into that same post once approved. **Pictures for posts written in the blog (suggested):** - A "Generate cover" button always in the post editor, whatever the post: it sends the post's current title, excerpt and text as `content` and checks first that the post has text (say "write the post first" otherwise). In your media library, beside Upload, "Generate with AI": a description (empty: picture the post) and a cover or in-text choice from where it was opened. Show the warning that it costs the blog's AI budget, `estimates.image` and the budget left (`GET /me`), and `tools.images.left_today`. - Send `POST /images`, poll `GET /images/{id}`, show the versions with "Use this picture" and an instruction field for a new version (`from`). On "Use this picture" copy it into the media library and remember its `id`, so the post can later offer "New version…" for it. **A new version of one image (suggested):** - Next to the cover and each in-text image of a post that came from us, and on the article's images: "New version…" opens a small dialog with an instruction field and today's `limits.left_today`. - Send `…/images/{plan_id}/regenerate`, then poll `…/candidates` every few seconds until the candidate is `ready` or `failed` (show `error.message`; for `policy_refused` suggest another instruction). - Show the candidate beside the current picture with "Use this one" and "Keep current". On "Use this one" call `…/accept`, copy the new picture into your media library (its address is new) and put it on the post; the other languages' posts get theirs from `article.updated`. List `kind: previous` candidates so the old picture can be restored. **1. Connecting (once per blog)** - The content system team creates an API client for the blog and enters that blog's own webhook URL (e.g. `https://blog.example.com/api/content-system/webhook/{blogId}`), then sends you the API key, the webhook secret and the content system address (see [What you receive](#what-you-receive)). - Store three values in the blog's server-side settings (encrypted): the content system address, the API key and the webhook secret. Test the connection with `GET /me`, and the webhook with `POST /webhook/test`. **2. The "request content" page** - Form: topic, languages (from `GET /languages`), keywords, content type, instructions, images, and whether to keep it as a draft or publish after approval. - `POST /requests` with that blog's `site.url` and a unique `external_ref` (e.g. the id of a row you create first in your own database). Store the answer: the request id (`data.id`) and each language's `art_…`. - Send `link_targets`: the blog's published posts in the requested languages (path, title, language, excerpt, focus keyword, your translation group, and `article_id` for posts that came from us), so the articles arrive with internal links. Keep the links root-relative when you store the post. - Show the user the languages listed in `errors`, with their reasons. **3. The webhook endpoint** - Check the signature over the raw body; invalid → `401`. - A repeated event (same `id`) → `200` and do nothing. - Upsert everything by `data.article.id` in a "content system articles" table: language, status, current step, quality summary, and two large columns: the **record** (`details`) and the **timeline** (an array of steps). - `article.stage_*` → add a row to the timeline (`stage`, `label`, `status`, times, duration, `summary`, `output`, `error`, `on_source`). - `article.review_required` → store the record; suggestion: create the content as a **draft** so the editor reads it in your own editor. - `article.completed` and `article.updated` → store the record and create or update the post (with `external_id = data.article.id`), take the featured image from `content.featured_image.url`, and if it was published answer `200 {"url", "external_id"}`. - If the editor edited the post in your panel, do not overwrite their text on `article.completed` (e.g. keep a hash of the text you last wrote and compare), or send the edits to the content system too with `POST /articles/{id}/edit` so both sides stay the same. - `article.failed` → show the status, step and reason, and a "Retry" button (`POST /articles/{id}/retry`). **4. Live updates (no Refresh button)** - Webhooks update your database moment by moment; the panel page should show it at once. - The simplest reliable way: poll a "change stamp" (e.g. the largest `updated_at` of the articles and requests tables) every few seconds with a light request and re-render when it changes; do not poll while the tab is hidden. It works with several servers too. (Other ways: SSE or WebSocket, messaged by the webhook endpoint after saving.) - `GET /articles/{id}/details` is only for when an event was lost or the article was created before your implementation; the user should never have to press a button. **5. Removing and restoring on the blog's side** - Removing a topic or a language only affects **your own** list; the article stays in the content system. - Suggestion: do not delete removed items, mark them (soft delete) so they can be seen and restored under "Removed"; answer `200` to later events of a removed topic or article and ignore them (so the system does not retry). - If you remove a topic that is still in progress, call `POST /requests/{id}/cancel` so no more money is spent. Only that request is cancelled; never cancel several topics at once. - If the user later asks for the same topic again, the same articles come back (see "Same topic again" under [Creating a request](#creating-a-request)). **6. Each article's page in the blog panel** - Header: title, language, status, current step, quality summary, "translated from …". - Tabs: Overview, **Progress** (the step-by-step timeline from the first analysis, with each step's output), Preview, Content, SEO, Images, Sources, Links, Structured data, Quality, Research & plan, Versions, Runs, Deliveries; each from the record section of the same name. - The page updates itself from events (item 4). **7. Review** - For an `in_review` article: **Approve**, **Request changes** (with text), **Reject** (with a reason), and **Edit** (an editor on `details.content` → `POST /edit`) buttons. - After each action, update the status from the answer; later events arrive by themselves. - Next to each warning, **Fixed** and **OK as is** (and Undo): keep the decision on your side and send it with `POST /articles/{id}/checks/{name}/resolution`; if that call fails, keep the decision and say so quietly. **8. After publishing** - Return the post's address in the webhook answer (or call `acknowledge`). - For later changes use `revise` or `edit`; the next approved version arrives with `article.updated`. - When an editor saves a different text for a post from us, call `POST /articles/{id}/edited` (in the background). **In Sky CMS** all of this is implemented: the connection is under **Console → Sites → the blog → Content system**; in the blog admin's **AI content**: a "New request" tab (the form draft is kept in the browser), one tab per topic with a card per language (quality, warnings, progress, review buttons), a "Removed" tab with restore, and the month's figures (all / present / removed / tokens); each article's page with every tab; all without a Refresh button and with live updates. --- # Building the integration with an AI assistant These docs are written so that an AI coding assistant (Claude, ChatGPT, Cursor and others) can read all of them and build the integration. Every page is also served as plain Markdown, and the whole set is one file. ## The links to give it | What | Link | |---|---| | Everything in one plain-text file (best for AI) | `https://content.nx.plus/docs/llms-full.txt` | | Index of the docs ([llms.txt](https://llmstxt.org) format) | `https://content.nx.plus/docs/llms.txt` | | The Integration API guide as Markdown | `https://content.nx.plus/docs/integration.md` | | The same guide as a web page, for people | `https://content.nx.plus/docs/integration` | Any page's Markdown is its address plus `.md`. ## Coding assistants with a terminal (Claude Code, Cursor, Codex) Download the file first, then point the assistant at it. A web fetch tool may shorten a long page before the model reads it; a downloaded file is read in full. ```bash curl -sL https://content.nx.plus/docs/llms-full.txt -o content-system-api.md ``` Then give it a prompt like this one, adapted to your stack: ```text Read content-system-api.md completely before writing any code. It is the full reference for the Content System Integration API. Build our blog's integration with it: 1. A settings screen that stores the content system address, API key and webhook secret (server side, encrypted); a "Test connection" button that calls GET /me. 2. A "New request" form: title, languages (from GET /languages), content type (from GET /content-types), optional keywords; it calls POST /requests. 3. A webhook endpoint that verifies the signature exactly as the docs describe, ignores duplicate event ids, answers within the time limit, and handles every event type. 4. A list of requests and articles with their live stage and status. 5. An article review page built from `details`: preview, SEO, images, sources, quality; with approve, reject, request changes and edit. 6. Publishing an approved article on our blog, then reporting the published URL. 7. A pull fallback (GET /articles?updated_since=…) for when webhooks are not reachable. Read the key from CONTENT_SYSTEM_API_KEY and the webhook secret from CONTENT_SYSTEM_WEBHOOK_SECRET; never hard-code them. Follow the docs exactly for field names, statuses, errors and retries; do not invent fields that are not in the docs. When something is unclear, quote the part of the docs you are unsure about and ask. ``` ## Chat assistants without a terminal Paste the link `https://content.nx.plus/docs/llms-full.txt` and ask it to read the whole file before answering. If it cannot open links, open the link yourself, save the page, and attach the file to the chat. ## Before you start - Get your API key, webhook secret and base URL from the content system team (see [What you receive](https://content.nx.plus/docs/integration.md#what-you-receive)). - Do not paste the API key or webhook secret into an AI chat. Put them in environment variables and tell the assistant the variable names. - When the integration is built, send `POST /webhook/test` to check that your webhook endpoint receives and verifies a signed event.