Skip to main content
POST
Restore a previous flow version
Replaces a flow agent’s current flow_config with the contents of a previously-saved version. Useful when a recent change broke the flow and you want to go back to a known-good state without manually rebuilding. Required scope: agents:update (same as PATCH /agents/:id).

How it works

Every save of a flow agent creates a row in flow_versions (deduped by content hash, so re-saving the same graph doesn’t create redundant rows). Calling restore:
  1. Looks up the row identified by version_id
  2. Verifies the row belongs to this agent
  3. Sets agents.flow_config to that row’s stored content
  4. Snapshots a new flow_versions row reflecting the restored state — but if the restored content equals the current head (you’re restoring to where you already are), the unique constraint silently swallows it. No history pollution.
The current state stays in history before the restore happens, so you can always restore back to it later.

Workflow

  1. List versions: GET /agents/:id/flow/versions → pick a version_id
  2. Restore: POST /agents/:id/flow/restore with { "version_id": "..." }
  3. Optionally verify: GET /agents/:id and inspect flow_config

Constraints

  • Agent must be a flow agent (type='flow'). Restoring on a prompt agent returns 400.
  • version_id must belong to the agent named in the path. Cross-agent version ids return 404.

Example request

Example response

Errors

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).

Path Parameters

id
string<uuid>
required

Body

application/json
version_id
string<uuid>
required

Id from GET /agents/:id/flow/versions[].id.

Response

Restored. Returns the updated agent (same shape as PATCH /agents/:id).