Files
RenewCMS/docs/llm/recipe-articles.md
T

3.7 KiB

Recipe: create, edit and publish an article

Create a draft, replace its body, check its SEO, publish it and read it back, with an API key.

Set the key once. Every request below is real output from a running instance; ids and timestamps differ on yours.

export RENEWCMS_API_KEY=rcms_...

1. Create a draft

Titles are 3 to 200 characters and cannot be changed later. The request body is HTML; the response body is markdown unless you pass ?format=html or ?format=json.

curl -X POST "{{BASE_URL}}/v1/article/" \
  -H "Authorization: Bearer $RENEWCMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title":"How we price a bathroom renovation","body":"<p>A bathroom renovation is priced by room size, plumbing changes and finish level.</p>"}'

Status 201:

{"id":1,"title":"How we price a bathroom renovation","body":"A bathroom renovation is priced by room size, plumbing changes and finish level.","body_format":"markdown","is_online":false,"site_id":1,"authors":[],"created_at":"2026-10-23T01:11:16.767761797+02:00","updated_at":"2026-10-23T01:11:16.767761797+02:00","slug":"how-we-price-a-bathroom-renovation","excerpt":"","seo_title":"","seo_description":"","cover_image_id":null,"cover_image_alt":"","social_title":"","social_description":"","social_image_id":null,"canonical_url":"","noindex":false,"seo_dismissed":[]}

The article starts offline (is_online: false) on the default site.

2. Replace the body, move it to a site, set the excerpt

PATCH takes only body, site_id, author_ids and the SEO fields. At least one is required; {} answers 400. Send {"body": ""} to empty a body.

curl -X PATCH "{{BASE_URL}}/v1/article/1" \
  -H "Authorization: Bearer $RENEWCMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"body":"<h2>What drives the price</h2><p>Room size, plumbing changes and finish level.</p>","site_id":2,"excerpt":"What drives the price of a bathroom renovation."}'

Status 200:

{"id":1,"title":"How we price a bathroom renovation","body":"## What drives the price\n\nRoom size, plumbing changes and finish level.","body_format":"markdown","is_online":false,"site_id":2,"authors":[],"created_at":"2026-10-23T01:11:16.767761797+02:00","updated_at":"2026-10-23T01:11:16.771008847+02:00","slug":"how-we-price-a-bathroom-renovation","excerpt":"What drives the price of a bathroom renovation.","seo_title":"","seo_description":"","cover_image_id":null,"cover_image_alt":"","social_title":"","social_description":"","social_image_id":null,"canonical_url":"","noindex":false,"seo_dismissed":[]}

3. Check the SEO before publishing

An empty JSON object checks the saved article. Pass any SEO field to check a change without saving it.

curl -X POST "{{BASE_URL}}/v1/article/1/seo/check" \
  -H "Authorization: Bearer $RENEWCMS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Status 200:

{"status":"suggestions","suggestions":[{"code":"desc_short","field":"seo_description","params":{"length":47,"min":70}},{"code":"cover_none","field":"cover_image_id","params":{}},{"code":"no_au","field":"author_ids","params":{}},{"code":"short","field":"body","params":{"length":66,"min":300}}],"slug":{"available":true,"suggestion":null}}

Suggestions never block publishing.

4. Publish

curl -X PATCH "{{BASE_URL}}/v1/article/1/publish" \
  -H "Authorization: Bearer $RENEWCMS_API_KEY"

Status 200, same article object with "is_online":true. PATCH /v1/article/{id}/unpublish reverses it.

5. Read it back without credentials

curl "{{BASE_URL}}/v1/article/1?format=markdown"

Before step 4 this answers 404 with the text Article not found, because anonymous callers only see online articles.