/api/public/v1/call-scripts/{scriptId}/treeReplace a call script’s tree
Makes the script’s whole tree match a nested outline, in one write. A step that carries the `id` of one of the script’s current steps **keeps it** — edited and moved in place, so the runs that visited it still count — a step without an id is new, and a current step the outline leaves out is **deleted with everything under it**. Send the outline you get from the script’s `nodes`, changed, to edit safely; omit ids only for steps you mean to create. Up to 500 steps, 20 levels deep, at least one root.
Required scope
The access token must carry this scope. A token missing it gets 403 Forbidden. Grant them to an API client under Dev Tools → API, to an assistant or CLI sign-in when you approve or edit it under Dev Tools, and to a teammate under Employee → Permissions.
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
scriptId | string | Required | Script ID. |
Request Body
| Property | Type | Description |
|---|---|---|
nodes | array | The root steps, in order. Each is `{ id?, type, label, body?, note?, outcome?, action?, actionUrl?, children? }`, where `children` is the same shape, in order — what comes next under that step. Fields as in Add a step. |
curl -X PUT "https://www.pxb.app/api/public/v1/call-scripts/{scriptId}/tree" \
-H "Authorization: Bearer your_access_token" \
-H "Content-Type: application/json" \
-d '{
"nodes": [
{
"id": "nod_1",
"type": "STATEMENT",
"label": "Hi, is now a bad time?",
"children": [
{
"type": "RESPONSE",
"label": "Not now",
"outcome": "CALLBACK_REQUESTED"
}
]
}
]
}'{
"message": "Call script tree replaced successfully!",
"content": {
"nodes": [
{
"id": "nod_1",
"scriptId": "scr_6620",
"parentId": null,
"type": "STATEMENT",
"order": 0,
"label": "Hi, is now a bad time?",
"body": null,
"note": null,
"outcome": null,
"action": null,
"actionUrl": null,
"createdAt": "2026-06-30T08:00:00.000Z",
"updatedAt": "2026-06-30T08:00:00.000Z"
}
]
}
}{
"message": "Step nod_9 is not in this script."
}In the console
The same thing done by hand, for anyone comparing the API against the screen they already use.