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
| Method | Path | Purpose |
|---|---|---|
| GET | /v1/pages/{slug} | Read a page at its current revision |
| PUT | /v1/pages/{slug} | Write a new revision |
| GET | /v1/pages/{slug}/revisions | List revisions, newest first |
| POST | /v1/purge | Invalidate a path prefix |
| GET | /v1/health | Liveness 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
| Status | Code | Notes |
|---|---|---|
| 400 | invalid_slug | Slugs are [a-z0-9-], max 120 chars |
| 401 | token_revoked | Rotate and redeploy |
| 409 | revision_conflict | Retry with a fresh If-Match |
| 413 | payload_too_large | Hard limit 8 MB per page |
| 429 | rate_limited | 600 reads/min per token; retry-after is honoured |
| 503 | edge-no-origin | See failure modes |
Client notes
- Keep connections alive: the edge holds 120 s of idle keepalive, and most latency wins come from not re-handshaking.
- Send
accept-encoding: gzip. Brotli is supported on static assets only; the JSON API is uncompressed on purpose. - Do not retry non-idempotent writes on
5xxwithout checking/v1/pages/{slug}/revisionsfirst — a202may have landed even if the response was lost.