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 }
]
}'
const res = await fetch('https://serpon.ai/v1/projects/1/workflows/reorder', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.SERPON_TOKEN}`,
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
steps: [
{ id: 502, step_number: 3 },
{ id: 503, step_number: 2 },
],
}),
});
const { success } = await res.json();
import os, requests
r = requests.post(
"https://serpon.ai/v1/projects/1/workflows/reorder",
headers={
"Authorization": f"Bearer {os.environ['SERPON_TOKEN']}",
"Accept": "application/json",
},
json={"steps": [{"id": 502, "step_number": 3}, {"id": 503, "step_number": 2}]},
)
ok = r.json()["success"]
{
"success": true,
"message": "Workflow steps reordered successfully."
}
{
"success": false,
"message": "One or more workflow steps do not belong to this project."
}
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
The project ID. Every step in the payload must belong to it.
Body parameters
At least one entry. Each is { "id": <step id>, "step_number": <new position> }.
The workflow step ID. If any ID in the array belongs to another project, the whole request is rejected and nothing changes.
New position, minimum 1.
Example
Swapping steps 2 and 3:
Response fields
true when the new order was applied.
Confirmation, or the reason for rejection.
The updated steps are not returned. List them to confirm the new order.
Errors
| Status | When |
|---|---|
401 | Missing, invalid, or expired token |
402 | Account has no active subscription |
403 | No update access to the project |
404 | No such project |
422 | Empty steps, a malformed entry, or an ID belonging to another project |
429 | Rate 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.