Skip to main content
POST
/
v1
/
agents
/
{agent_id}
/
workspace
/
multi_edit
Workspace: Multi Edit
curl --request POST \
  --url https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "edits": [
    {
      "path": "<string>",
      "old_text": "<string>",
      "new_text": "<string>"
    }
  ]
}
'
import requests

url = "https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit"

payload = { "edits": [
{
"path": "<string>",
"old_text": "<string>",
"new_text": "<string>"
}
] }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({edits: [{path: '<string>', old_text: '<string>', new_text: '<string>'}]})
};

fetch('https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'edits' => [
[
'path' => '<string>',
'old_text' => '<string>',
'new_text' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit"

payload := strings.NewReader("{\n \"edits\": [\n {\n \"path\": \"<string>\",\n \"old_text\": \"<string>\",\n \"new_text\": \"<string>\"\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"edits\": [\n {\n \"path\": \"<string>\",\n \"old_text\": \"<string>\",\n \"new_text\": \"<string>\"\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"edits\": [\n {\n \"path\": \"<string>\",\n \"old_text\": \"<string>\",\n \"new_text\": \"<string>\"\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "results": [
    {
      "path": "<string>",
      "replacements_made": 0
    }
  ]
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
Apply multiple file edits atomically. Each edit uses the same exact-match semantics as Workspace: File Edit. If any edit fails, all changes are rolled back.

Path Parameters

agent_id
string
required
Agent ID (UUID)

Request Body

edits
array
required
Ordered list of edits to apply. Each item has:

Response

status
string
Result status (e.g., ok).

Example Request

curl -X POST "https://api.xpander.ai/v1/agents/<agent-id>/workspace/multi_edit" \
  -H "Content-Type: application/json" \
  -H "x-api-key: <your-api-key>" \
  -d '{
    "edits": [
      {
        "path": "app.py",
        "old_text": "DEBUG = True",
        "new_text": "DEBUG = False"
      }
    ]
  }'

Notes

  • Edits are applied in the order provided. Later edits can operate on content produced by earlier edits in the same request.
  • If any single edit fails (e.g., old_text not found), the entire batch is rolled back so the workspace is not left in a half-applied state.

See Also

Authorizations

x-api-key
string
header
required

API Key for authentication

Path Parameters

agent_id
string
required

Body

application/json
edits
SingleEdit · object[]
required

List of edits to apply atomically. If any edit fails, all changes are rolled back.

Response

Successful Response

results
SingleEditResult · object[]

Results for each edit operation