Ponystudio Docs

API Reference

All endpoints are JSON over HTTPS. Base URL: https://docs.ponystudio.cn/v1

Authentication

Tokens are scoped to a single project and carry one of three roles: reader, writer, admin. Send them as a bearer credential:

Authorization: Bearer pony_live_7f3c…

Tokens expire after 90 days. Rotation is overlapping: issue the new token, deploy it, then revoke the old one. Requests signed with a revoked token return 401 token_revoked and are never retried by the edge.

Endpoints

MethodPathPurpose
GET/v1/pages/{slug}Read a page at its current revision
PUT/v1/pages/{slug}Write a new revision
GET/v1/pages/{slug}/revisionsList revisions, newest first
POST/v1/purgeInvalidate a path prefix
GET/v1/healthLiveness probe, no auth required

GET /v1/pages/{slug}

HTTP/2 200
content-type: text/html; charset=utf-8
cache-control: public, max-age=60, stale-while-revalidate=30
x-pony-cache: hit
x-pony-revision: r4821
x-pony-propagated: 4/4

PUT /v1/pages/{slug}

Body is the raw page. If-Match: r4821 is optional; when omitted the write wins and the previous revision remains available for 30 days.

HTTP/2 202
x-pony-revision: r4822
x-pony-propagated: 0/4

POST /v1/purge

{"prefix": "/guides/", "reason": "stale-screenshot"}

Purges are queued, not synchronous. A 202 means the request was accepted; poll GET /v1/purge/{id} or watch x-pony-propagated on the next read.

Error codes

StatusCodeNotes
400invalid_slugSlugs are [a-z0-9-], max 120 chars
401token_revokedRotate and redeploy
409revision_conflictRetry with a fresh If-Match
413payload_too_largeHard limit 8 MB per page
429rate_limited600 reads/min per token; retry-after is honoured
503edge-no-originSee failure modes

Client notes