Content admin API¶
Shared admin content contract for cms-admin / cms-client UI and
cms-ai-forge (CmsPublisher). Both use the same /admin/v1/content*
surface behind an admin JWT (human editor or forge service account). This page
documents the editor payload, status machine, block vocabulary, and
lookups — not the forge action-registry recipes (see
Action registry).
content_blocks is validated server-side against a JSON Schema stored per
content type (AISD-205). The vocabulary below is that schema; see
Block schemas for the full document and how to change it.
Shared clients¶
| Client | Auth | Typical use |
|---|---|---|
| cms-admin / cms-client | admin JWT from /admin/v1/auth/login |
list + WYSIWYG editor, SEO, flags, publish |
| cms-ai-forge | forge service-account JWT (role=forge) |
upsert / publish generated articles |
Do not invent forge-only content write paths. Forge already posts the same
ContentCreate / ContentUpdate shapes (including {type, data} blocks,
media_path strings, and provenance fields). UI should display provenance when
present; humans usually leave those fields unset.
Auth¶
All routes below require Authorization: Bearer <admin JWT> (mount-level
validate_admin). See Auth flow.
Endpoints¶
| Method | Path | Purpose |
|---|---|---|
| GET | /admin/v1/content |
List with filters (see below) |
| POST | /admin/v1/content |
Create draft (created_by_user from JWT) |
| GET | /admin/v1/content/{id} |
Get one |
| PATCH | /admin/v1/content/{id} |
Update fields / status / flags / blocks |
| POST | /admin/v1/content/{id}/duplicate |
Duplicate |
| GET | /admin/v1/content/{id}/children |
Child lineage |
| GET | /admin/v1/sites/{site_id}/content/slug-available |
Slug check |
| GET | /admin/v1/content-types |
Lookup names for create/edit dropdowns |
| GET | /admin/v1/content-types/{name}/schema |
Stored content_blocks JSON Schema (name or id) |
| GET | /admin/v1/sites/{site_id}/authors |
Authors |
| GET | /admin/v1/sites/{site_id}/categories |
Categories |
| POST | /admin/v1/media |
Presign upload → store media_path |
| POST | /admin/v1/content/bulk |
Bulk publish / trash / set_status (see below) |
OpenAPI: openapi-admin.yaml. Postman: Content /
Content Types folders in the API collection.
Bulk actions¶
POST /admin/v1/content/bulk takes {ids, action, ...} and returns a
BulkActionResult. action is one of publish, trash, set_status; anything
else is a 400, as is a request over 100 ids -- the cap is per request, so a
larger selection is chunked by the client. edited_by is derived from the JWT.
The same shape exists on the sibling resources, each capped at 100 ids:
| Path | Actions |
|---|---|
POST /admin/v1/content/bulk |
publish · trash · set_status |
POST /admin/v1/authors/bulk |
activate / deactivate |
POST /admin/v1/sites/{site_ref}/categories/bulk |
delete / reorder |
POST /admin/v1/scripts/bulk |
activate / deactivate |
Lookup registries (AISD-232)¶
Cursor-paginated global registries that back create/edit pickers, separate from a site's own enabled taxonomy:
| Method | Path | Returns |
|---|---|---|
| GET | /admin/v1/languages |
languages, sorted code:asc |
| GET | /admin/v1/categories |
the global categories registry, sorted name:asc |
Note the distinction: /admin/v1/categories is the global registry, while
/admin/v1/sites/{site_ref}/categories is the set a given site has enabled.
Site-level operations¶
| Method | Path | Purpose |
|---|---|---|
| POST | /admin/v1/sites/{site_ref}/users/associate-all |
Associate every active CMS user to the site; idempotent (AISD-203). |
| POST | /admin/v1/sites/{site_ref}/wipe |
Delete a site's content, taxonomy and media so it can be re-imported (AISD-257). |
wipe is the only irreversible operation in the admin API
It is guarded by a double echo: the body must restate both
confirm_site_ref and confirm_environment. The site echo catches a
mis-scoped call; the environment echo matters because the S3 bucket is
resolved from the running service's environment and the same media folder
name exists in the stage and prod buckets -- getting the environment wrong
deletes production media with no undo. Pass dry_run: true to get the same
SiteWipeResult counts without deleting anything, and do that first.
List filters¶
GET /admin/v1/content accepts:
| Query | Notes |
|---|---|
site_id |
Optional site scope |
status |
draft | published | unpublished |
content_type |
Lookup name (e.g. homepage_article) |
include_hidden |
Default false — only visible_in_ui=true; set true for editor-hidden rows |
q |
Case-insensitive substring on title, description, slug |
updated_before |
ISO-8601 instant; rows whose updated_at is strictly before it (exclusive) |
updated_after |
ISO-8601 instant; rows whose updated_at is at or after it (inclusive) |
is_auto_generated |
true = AI-generated only, false = human-authored only, absent = both |
generation_job_id |
Exact match on the forge job id that produced the row; unknown id → empty page |
sort |
Allowlist: id, published_at, slug, title, updated_at × asc/desc (default id:asc) |
limit / cursor |
Cursor pagination (1..100) |
updated_before / updated_after accept an offset (...Z, +03:00) and are
converted to UTC; a value without one is read as UTC, matching the naive
DATETIME columns. The response carries created_at / updated_at so a client
can read the value it filtered on.
Selecting regeneration candidates (AISD-291) -- what cms-ai-forge's scheduler asks for: the site's auto-generated rows untouched since a cutoff, oldest first.
GET /admin/v1/content?site_id=207&is_auto_generated=true
&updated_before=2026-05-01T00:00:00Z&sort=updated_at:asc&limit=10
Content-types lookup¶
GET /admin/v1/content-types returns active rows from the content_types
table (id, name, description, is_active). Seeded names include
homepage_article, quiz, and trending. Pass name as
ContentCreate.content_type / filter content_type.
The list response deliberately carries no block_schema — a seeded schema is
roughly 2 KB per row and the list feeds dropdowns. Fetch a schema on demand from
GET /admin/v1/content-types/{name}/schema, which accepts the lookup name or
its numeric id and returns content_type_id, name, description,
is_active, and block_schema. Unknown ref → 404 resource_not_found.
Taxonomy context: Content-type taxonomy.
Tags¶
Tags are free-string lists on content (tags: string[] on create/update).
There is no site-scoped tag CRUD or picker API — unlike categories.
Status machine¶
Allowed values (server-enforced): draft → published → unpublished.
- Create always starts as
draft. PATCHwithstatus=publishedstampspublished_at.- Invalid status →
400. - There is no hard DELETE; retire via status /
is_active.
Forge uses the same PATCH transition when publishing.
Create / update payload (highlights)¶
Required on create: site_id, content_type, language, slug, title,
author_id, content_blocks.
Useful optional fields:
| Field | Role |
|---|---|
seo_title, seo_description |
SEO |
og_title, og_description, og_image |
Open Graph (og_image = media_path) |
canonical_url, noindex, schema_type |
SEO / schema |
featured_image |
Hero image media_path |
is_featured, is_trending, show_in_homepage, visible_in_ui |
Flags |
categories, tags |
String lists |
is_auto_generated, generation_job_id, creator_source |
Forge provenance (UI display) |
created_by_user is set from the JWT on create. Legacy rows with
created_by_user=NULL can fail Pydantic serialization on list/get until
backfilled (or the Out schema is optionalized).
Canonical content_blocks vocabulary (schema-backed)¶
Blocks are an ordered JSON array of Editor.js-style objects:
type |
Typical data |
Notes |
|---|---|---|
paragraph / text |
{ "text": "..." } |
Body copy |
heading / header |
{ "text": "..." } |
Section title (heading preferred) |
image |
{ "src": "/cmp-media/...", "alt": "..." } |
Use an uploaded media_path; the worker also reads data.url / data.file.url |
list |
{ "items": ["..."], "style": "unordered" } |
|
quote / blockquote |
{ "text": "...", "caption": "..." } |
|
delimiter |
{} |
Visual break |
checklist_item |
{ "page": 1, "title": "...", "text": "...", "image": "..." } |
Listicle slide (wp_import) |
raw |
{ "html": "..." } or top-level html |
Escape hatch |
richtext |
unconstrained | Legacy WYSIWYG copy; added to the enum from the stage audit, shape not yet standardized |
Forge / worker prompts emit paragraph and heading with text under
data.text. This vocabulary is enforced: it is the frozen type enum in the
schema stored on each content type. See Block schemas for
the full document, the deliberate leniencies, and how to change a schema.
Block validation and the 422 body¶
content_blocks is validated against the resolved content type's stored schema
on:
POST /admin/v1/content— always.PATCH /admin/v1/content/{id}— only when the payload carriescontent_blocks. The type is the payload'scontent_typewhen it is being changed, otherwise the stored row's. A status-only or SEO-only PATCH on a row with legacy blocks is never validated.
POST /admin/v1/content/{id}/duplicate is not validated: it copies
already-stored blocks, so failing a duplicate of a legacy row would be a
regression.
A mismatch is a 422 in the standard error envelope (same family as
invalid_media_scope):
{
"error": {
"code": "content_blocks_invalid",
"message": "content_blocks does not match the schema for content_type 'homepage_article'",
"details": {
"content_type": "homepage_article",
"error_count": 1,
"errors": [
{
"path": "content_blocks[2].data.text",
"message": "3 is not of type 'string'",
"schema_path": "items.allOf[0].then.properties.data.properties.text.type"
}
]
}
}
}
errors is capped at 20 entries ordered by block index; error_count keeps the
true total. FastAPI's own request-model 422 ({"detail": [...]}) is unchanged
and stays distinct — check for error.code to tell them apart.
A content type with no stored schema ({}) accepts any blocks, which is the
documented soft-migration behaviour rather than a silent skip.
content_blocks: null is a 422 for any content type with a seeded schema
(homepage_article, trending, quiz, and any future seeded type), on both
POST and PATCH: every seeded schema requires content_blocks to be a JSON
array, null is not an array, and the column is NOT NULL in the database
anyway, so there is no code path where null could ever be persisted. This is
deliberate, not an oversight — see test_create_with_null_content_blocks_returns_422
and test_update_with_null_content_blocks_returns_422 in
tests/admin/test_block_schemas.py. A content type with no seeded schema
({}, accept-anything) is unaffected and still accepts null. If you need to
leave content_blocks untouched on a PATCH, omit the field entirely rather
than sending null — an omitted field never enters model_fields_set and
skips validation, per the "only when the payload carries content_blocks"
rule above.
Attaching media¶
POST /admin/v1/media→media_path(see Media upload).- Store that path on
featured_image,og_image, or animageblock’s URL field — never a temporary S3 PUT URL.
Example: draft → publish¶
# Lookup types for the dropdown
curl -sS "$BASE/admin/v1/content-types" -H "Authorization: Bearer $TOKEN"
# Create draft
curl -sS -X POST "$BASE/admin/v1/content" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"site_id": 207,
"content_type": "homepage_article",
"language": "en",
"slug": "hello-world",
"title": "Hello world",
"author_id": 1,
"content_blocks": [
{"type": "heading", "data": {"text": "Hello"}},
{"type": "paragraph", "data": {"text": "Body copy."}}
],
"seo_title": "Hello world",
"tags": ["intro"]
}'
# Publish
curl -sS -X PATCH "$BASE/admin/v1/content/$CONTENT_ID" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"status": "published"}'
Related¶
- Block schemas
- Media upload
- Action registry (forge recipes — out of scope for this page)
- Content-type taxonomy