WorkflowsReorder steps

POST /v1/projects/{project}/workflows/reorder

Renumber several workflow steps at once, without unique-constraint collisions.

curl -X POST https://serpon.ai/v1/projects/1/workflows/reorder \
  -H "Authorization: Bearer $SERPON_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "steps": [
      { "id": 502, "step_number": 3 },
      { "id": 503, "step_number": 2 }
    ]
  }'
{
  "success": true,
  "message": "Workflow steps reordered successfully."
}

Assign new step numbers to several steps in one transaction.

POST https://serpon.ai/v1/projects/{project}/workflows/reorder

Step numbers are unique within a workflow, so swapping two steps with individual updates collides on the first write. This endpoint applies the whole new order atomically instead, and bumps the workflow's revision once the new order is in place.

Authentication

Bearer token in the Authorization header. Requires update access to the project. See Authentication.

Path parameters

path
projectinteger
Required

The project ID. Every step in the payload must belong to it.

Body parameters

body
stepsarray
Required

At least one entry. Each is { "id": <step id>, "step_number": <new position> }.

body
steps[].idinteger
Required

The workflow step ID. If any ID in the array belongs to another project, the whole request is rejected and nothing changes.

Example

Swapping steps 2 and 3:

Response fields

successboolean
Required

true when the new order was applied.

messagestring
Required

Confirmation, or the reason for rejection.

The updated steps are not returned. List them to confirm the new order.

Errors

StatusWhen
401Missing, invalid, or expired token
402Account has no active subscription
403No update access to the project
404No such project
422Empty steps, a malformed entry, or an ID belonging to another project
429Rate limit exceeded

Note that the ownership failure returns 422 with success: false in the body, not the usual errors map.

See Errors for the full reference.

Tips

Prompts reference earlier steps by number through {step_N_output}. Reordering does not rewrite those references — after a swap, a prompt asking for {step_2_output} gets whatever now sits at position 2. Review the prompts of every step you moved.

Send the complete new ordering for the steps you are moving, not just the ones that changed relative position. Steps you omit keep their current numbers, which is a common source of accidental duplicates in the next edit.