Publishing

POST/v1/books/{bookId}/publishscope: publish:write

Publish or unpublish a book. On publish, every chapter must have content; Anthra mints a globally unique slug (reusing the book’s slug if it was already published before), sets publishedAt, and revalidates the public reader at /read/{slug}.

Body

FieldTypeNotes
publishbooleanRequired. true publishes (status → published); false reverts to ready.
visibilityprivate | unlisted | publicOptional. Defaults to whatever the book already has. unlisted = anyone with the slug can read; public = also indexable.
curl -X POST "$ANTHRA_BASE/books/$BOOK/publish" \
  -H "authorization: Bearer $ANTHRA_TOKEN" \
  -H "content-type: application/json" \
  -d '{ "publish": true, "visibility": "unlisted" }'

The response includes the updated Book, including slug and readerUrl.

Common errors

  • 400 invalid_state — “Finish writing all chapters before publishing.” Some chapter has empty content.
  • 403 insufficient_scope — the token doesn’t carry publish:write.