Skip to main content
POST
Restore an earlier workflow version
Requires agents:update. Restoring publishes a copy of an earlier version’s workflow as a new version. It rolls forward: version numbers only go up, the version you restored from stays in the history, and callers reach the new version on their next call. A call already in progress keeps the version it started on.
string
required
Local agent UUID.
string
The id of the version to restore, from List workflow versions. Send exactly one of version_id and version.
integer
The number of the version to restore, instead of its id.
integer
The saved draft’s version you last read. When the draft has moved since, the answer is 409 WORKFLOW_CONFLICT and nothing is published. Optional.
boolean
default:"false"
true replaces a saved draft that holds unpublished changes with the restored workflow. false refuses instead of losing them.
201 returns the new revision (id, version, content_hash, published_at, environment), execution_version, restored_from (id and version of the copy’s source), draft_version, discarded_draft, and settings_updated_at, the same token Publish workflow returns. Send it as expected_updated_at on your next agent PATCH.

What a restore does and does not promise

  • It is a new version. The restored workflow is published again, so the list shows a new row with source: "restore" and restored_from_version.
  • It is not guaranteed to be byte-identical. The old document is checked and built again with today’s rules. For most versions the result matches; an agent whose version was rebuilt on 2026-11-12 can differ from it in compiled details (the document text you read with Get workflow version is what is restored).
  • It can be refused. If the old document no longer passes today’s checks (a tool in it was archived, an app account was disconnected) the answer is 422 WORKFLOW_REFERENCE_INVALID or WORKFLOW_VALIDATION_FAILED with issues[], nothing is published, and your draft is put back as it was.
  • It is not idempotent. Every successful call makes one more version. If you never received the answer, read the version list before sending it again.

Refusals

To undo a Teach run, restore the run’s base_revision.

Authorizations

Authorization
string
header
required

Your Yappr API key (e.g. ypr_live_...). Generate one in the dashboard under Settings → API Keys. No key is 401 MISSING_KEY; a key that is not one of ours, or is revoked, is 401 INVALID_KEY; an expired one is 401 EXPIRED_KEY. A valid key without the scope an operation needs is 403 INSUFFICIENT_SCOPE on every operation, and the message names the scope. Every response, a 401 included, carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset: the budget is 60 requests a minute per API key. Every 429, whatever its code, carries Retry-After (whole seconds, never zero): the per-key budget's RATE_LIMIT asks for what is left of the minute, a route's daily cap (RATE_LIMITED) for the time until that cap resets. All four headers are listed in Access-Control-Expose-Headers, so a browser can read them. A path the API does not serve (an unknown sub-path, an id left empty) is 404 ROUTE_NOT_FOUND, and a method a served path does not take is 405 METHOD_NOT_ALLOWED with an Allow header; both are answered before any scope check, and nothing is read or changed. A trailing slash is ignored where it cannot be an id left empty (POST /calls/ is POST /calls) and refused where it can (GET /calls/). A doubled slash inside a path is merged into one before the request reaches the API (GET //calls is GET /calls).

Headers

x-company-id
string<uuid>

Explicit active workspace. Optional; when sent it must be the API key's own workspace — any other value is refused with 403 WORKSPACE_MISMATCH.

Path Parameters

id
string<uuid>
required

Body

application/json

Name the version with exactly one of version_id and version.

version_id
string<uuid>

The id of the version to restore, from GET /agents/{id}/workflow/versions.

version
integer

The number of the version to restore.

Required range: x >= 1
expected_version
integer

The saved draft's version you last read. Refused with 409 WORKFLOW_CONFLICT when the draft has moved since. Optional.

Required range: 1 <= x <= 9007199254740991
discard_draft
boolean
default:false

True replaces a saved draft that holds unpublished changes with the restored workflow. False (default) refuses with 409 WORKFLOW_DRAFT_HAS_UNPUBLISHED_CHANGES instead of losing them.

Response

The restored workflow is live as a new version.

revision
object
required
execution_version
any
required
read-only
restored_from
object
required
draft_version
integer
required

The saved draft's version after the restore.

Required range: x >= 1
discarded_draft
boolean
required

True when unpublished draft changes were replaced.

settings_updated_at
string<date-time>
read-only

The agent settings token as of this restore, as POST /agents/{id}/workflow/publish answers it. Send it as expected_updated_at on your next PATCH /agents/{id}.