REST API

The API lives at https://admin.tryzine.ai/api/v1. Use the API origin saved by CLI login for your environment.

Authentication

Send Authorization: Bearer pk_… for site-scoped reads and subscriber actions. The publishable key identifies a single site and can be used in the subscribe form. Keep the whsec_… key server-side. It authorizes bulk import and verifies publish webhooks.

Readers can have a signed viewer token. Pass it as X-Zine-Viewer when requesting a post. Gated listings omit the body and unauthorized detail requests receive a teaser. The server checks the reader and their access to the requested site on each detail request.

Content

Method and path Purpose
GET /posts?limit=20&offset=0 Lists published posts for the site. Limit is capped at 100.
GET /posts/{slug} Returns { post, access }. A renamed slug can return a 404 with { redirect: { toSlug } }.
GET /pages/{slug} Returns a published page and its editable slots.
POST /posts/import Accepts up to 200 Markdown posts with the site’s server-side secret.
curl 'https://admin.tryzine.ai/api/v1/posts?limit=20' \
  -H 'Authorization: Bearer pk_your_site'

Content responses vary by authorization and viewer. Zine caches common lists per site internally and invalidates that cache when a post changes.

Subscriber and reader email

Method and path Purpose
OPTIONS /subscribe, POST /subscribe Browser signup preflight and email opt-in. POST accepts an email and the site key.
GET /subscribe/confirm-redirect?token=… Confirms an emailed signup token and redirects to the site’s canonical URL.
POST /subscribe/confirm Compatibility route for custom confirmation UIs. Send the site key and { token }.
GET /email/unsubscribe?token=…, POST /email/unsubscribe?token=… Displays confirmation on GET and handles one-click or form opt-out on POST.
GET /email/notifications/unsubscribe?token=…, POST /email/notifications/unsubscribe?token=… Manages a Zine account’s notification digest opt-out.
POST /auth/start, POST /auth/redeem Starts reader sign-in and exchanges an emailed token for a viewer session.
GET /auth/dev-redeem Local development landing for reader sign-in.

Other endpoints

Method and path Purpose
GET /health Liveness check used by the CLI.
POST /cli/device-start, POST /cli/device-poll Starts a CLI sign-in and polls until approved.
POST /cli/device-approve Signed-in approval for a CLI device grant.
GET /visitors/collect, OPTIONS /visitors/collect, POST /visitors/collect Collector health, CORS preflight, and a site-key-authenticated page view.
POST /checkout, POST /portal, GET /portal/redeem Reader membership checkout and portal. These require Stripe configuration.

Publish webhook

Next.js installs can expose POST /api/zine/revalidate on their own domain. The CLI scaffolds the handler. Zine signs the raw JSON body with the site’s whsec_ secret and sends it in the X-Zine-Signature header as sha256=<hex>. The body carries a site ID, timestamp, paths, and tags. The handler verifies the signature before refreshing the site’s cache.