GoRunner

Copy a published version's snapshot over the draft

Requires scope workflow:write
POST
/api/workflows/{id}/versions/{versionId}/restore

Restore rewrites the DRAFT and NEVER touches production. A live workflow keeps running latestVersionId until you publish again — so after restoring, the response's hasUnpublishedChanges is what tells you whether the draft now differs from what is live. Restoring the version that is already live leaves hasUnpublishedChanges: false.

The restored definition passes the SAME gate as an editor save: the tree is structurally validated, an ACTIVE workflow's pieces are checked against the live worker fleet, and blank piece-version pins are filled. So an old snapshot naming a piece the current fleet cannot run is refused (422) here, rather than quietly breaking production at the next publish.

Optimistic locking: send {"expectedRev": N} with the workflow's current definitionRev. If the draft moved underneath you, the call is 409 and writes nothing — reload and restore again. Omit expectedRev (or send 0 or less, which is ignored) for an unconditional restore.

Also restored/refreshed as a side effect: the workflow's triggerType follows the restored definition, a webhook workflow that somehow had no token gets one, and pinned test data is re-stamped for staleness. Test payloads and pinned data are stored outside the definition, so restoring never deletes them.

Authorization

bearerAuth
AuthorizationBearer <token>

An API token: Authorization: Bearer grt_…. Mint one in the app under Settings → Workspace → API tokens; the raw value is shown once. Scopes confine the token — see x-permission on each operation.

In: header

Path Parameters

id*string

Workflow id (UUID).

Formatuuid
versionId*string

The version whose snapshot becomes the new draft. Must belong to this workflow.

Formatuuid

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/api/workflows/497f6eca-6276-4993-bfeb-53cbbbba6f08/versions/497f6eca-6276-4993-bfeb-53cbbbba6f08/restore" \  -H "Content-Type: application/json" \  -d '{}'
{  "data": {    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",    "name": "string",    "description": "string",    "definition": {      "schemaVersion": 2,      "trigger": {        "name": "string",        "displayName": "string",        "type": "manual",        "pieceId": "string",        "pieceVersion": "string",        "actionId": "string",        "config": {},        "connectionId": "string",        "valid": true,        "nextAction": {          "name": "string",          "displayName": "string",          "type": "PIECE",          "pieceId": "string",          "pieceVersion": "string",          "actionId": "string",          "config": {},          "connectionId": "string",          "valid": true,          "skip": true,          "nextAction": {},          "branches": [            {              "name": "string",              "conditions": [                [                  {                    "field": "string",                    "operator": "string",                    "value": null                  }                ]              ],              "firstAction": {}            }          ],          "firstLoopAction": {},          "onErrorAction": {}        }      },      "settings": {        "timeoutSeconds": 0,        "errorWorkflowId": "string",        "concurrencyLimit": 0,        "maintenanceMode": true,        "autoPublishFixes": true      },      "variables": {},      "annotations": null,      "pinnedData": {}    },    "status": "draft",    "triggerType": "manual",    "cronExpression": "string",    "webhookToken": "string",    "latestVersionId": "750445c5-7ad9-40bd-a593-bb37d7d846db",    "definitionRev": 0,    "hasUnpublishedChanges": true,    "folderId": "5b6379a4-2a6c-4085-b184-45838a3b8e7e",    "tags": [      "string"    ],    "testPayloads": {},    "pinnedData": {},    "workspaceId": "ef0efa32-d1c1-43d4-a5e2-fe7b4f00403c",    "orgId": "25b2c2d5-a7fc-47d0-89e4-8709a1560bfa",    "createdBy": "25a02396-1048-48f9-bf93-102d2fb7895e",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z"  }}