Prerequisites
- An API key with
full_editoraccess — see Create an API key - A website with version history — see Edit source code
The two recovery tools
Both require an edit lease token.
1
Acquire an edit lease
Acquire a lease
{ "leaseToken": "...", "headVersion": 9 } also tells you the current head version. GET /v1/websiteSourceCode/summary reports headVersion, publishedVersion, and hasUnpublishedChanges if you need orientation first.2
Discard the draft
Restore the head to match the published website. Production does not change.The response is
Restore head to published
{ "version": 10, "changed": true }, a new head version containing the published files. If head already matched, changed is false. A website that has never published returns 404.3
Restore an older version to head
Bring back a known-good version for review by passing a version number as
to. This changes only the draft:Restore version 7 to head
to must be an existing version (1 up to the current head); anything higher returns 400 Version does not exist. Review the result on the draft host, then take it live with the normal pipeline: POST /v1/websiteSourceCode/head/check, then POST /v1/websiteSourceCode/head/publish.4
Roll back the published website immediately
When production is broken, skip the review loop. Rollback validates version Rollback re-runs the full publish gate: the version must pass validation and build. It does not require billing. It also moves head to the rolled-back content, so head and published end up aligned.
n, builds it, and re-publishes in one call:Roll back production to version 7
Response
5
Recover from a failed build
A publish that fails validation or build returns a The recovery loop: fix the offending source file, run
400 with the failure message, and the deployment records status: "failed". Inspect it:Check deployment status
Response (truncated)
POST /v1/websiteSourceCode/head/check until it passes, then publish again. POST /v1/websiteSourceCode/deployment/ensure (body { websiteId, target }) re-triggers a build for the head or published version without publishing — useful to confirm a fix builds cleanly. The published website keeps serving its last ready deployment throughout; a failed build never takes production down.6
Verify the outcome
List files changed from published to head to confirm the state you expect:
List changed files
After a rollback or a restore to
published you should see "items": [], meaning head and published match. After restoring an older version to head, items lists what will change when you publish. Inspect a selected entry with GET /v1/websiteSourceCode/files/diff?websiteId=...&name=....Troubleshooting
409 Invalid edit lease
409 Invalid edit lease
Another editor acquired the lease after you did. Re-acquire the lease and repeat the operation.
409 Website deployment is still building; retry shortly
409 Website deployment is still building; retry shortly
Rollback found a build in progress for that version. Retry after a short wait; the build is reused once ready.
404 Website has no published version
404 Website has no published version
Restoring to
published and comparing against published need at least one publish. Restore to a version number instead on a never-published website.Next steps
- Preview drafts and versions to review a restored head before publishing
- Agent-safe publishing to make rollback a planned part of agent workflows