PageBaton

Publishing API

Publish files from your build process and keep an existing project link across revisions.

Quick start

Create an API key in account settings. Create a draft, upload its source, then publish it once processing completes. All paths below begin at your own console origin.

Authentication

Send your key in the Authorization header. A key lasts 90 days and can be revoked immediately in settings. It grants access to your projects, drafts and publication jobs. Keep it on your server.

Authorization: Bearer $PB_KEY

Upload a file

Upload a static site, document, ebook, image, audio track or video. Office files and EPUB/FB2 books provide text previews. Native media playback depends on the browser’s codecs.

# Set BASE to the origin of your PageBaton console.
curl -X POST "$BASE/api/v1/drafts" \
  -H "Authorization: Bearer $PB_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fileName":"index.html"}'

# Set DRAFT to the returned draftId. Use a fresh key for each new upload.
curl -X PUT "$BASE/api/v1/drafts/$DRAFT/source" \
  -H "Authorization: Bearer $PB_KEY" \
  -H "Idempotency-Key: $UPLOAD_KEY" --data-binary @index.html

Poll GET /api/v1/drafts/{draftId} until the state is ready. If processing returns invalid, read the error and correct the file. For an archive with several entry pages, select an entry from the returned candidates using PATCH /api/v1/drafts/{draftId}/entry.

Publish a draft

curl -X POST "$BASE/api/v1/publications" \
  -H "Authorization: Bearer $PB_KEY" \
  -H "Content-Type: application/json" -H "Idempotency-Key: $PUBLISH_KEY" \
  -d "{\"draftId\":\"$DRAFT\",\"slug\":\"my-page\"}"

The response contains an operationId. Poll GET /api/v1/publications/{operationId} until the state is succeeded or failed. Use the shareUrl from the project record to open the result. A retry with the same idempotency key must use the same body.

Update a live project

Fetch the project to obtain its current revision. Include projectId and expectedRevision when creating its replacement draft and submitting the publication. The share address keeps working. A revision conflict means another update landed first.

Project actions

Method and path under /api/v1Result
GET /projectsList your projects
GET /projects/{id}Find the revision and share URL
PATCH /projects/{id}Rename a project
GET /projects/{id}/exportDownload its original file
GET /projects/{id}/qr.pngDownload the share QR code
GET /projects/{id}/accessRead access settings

Errors and limits

The draft’s byteLimit is the upload limit in bytes. GET /api/v1/session returns quota.maxBytes and quota.monthlyBytes for the current plan. Your plan sets the number of live projects and successful publishes per UTC day. Read code, message and requestId on unsuccessful API responses. A 409 may require a new revision or slug. For a 429, wait for the Retry-After interval.

MCP and OpenAPI

Connect an MCP client to your own projects with the publishing skill and setup guide. For HTTP clients, download the OpenAPI contract or read the discovery guide.