Login / Register
PUT
/api/public/v1/call-scripts/{scriptId}/tree

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

call-scripts:write

Path Parameters

NameTypeRequiredDescription
scriptIdstringRequiredScript ID.

Request Body

PropertyTypeDescription
nodesarrayThe 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.
PUTExample request
curl
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"
          }
        ]
      }
    ]
  }'
200Example response
json
{
  "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"
      }
    ]
  }
}
400Example response
json
{
  "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.

xRM → Scripts
/xrm/scripts
  1. Open a script and edit its steps.