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": "notes/demo.txt",
"old_text": "hello, world",
"new_text": "hi, world"
},
{
"path": "notes/demo.txt",
"old_text": "second line",
"new_text": "2nd line"
}
]
}
'import requests
url = "https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit"
payload = { "edits": [
{
"path": "notes/demo.txt",
"old_text": "hello, world",
"new_text": "hi, world"
},
{
"path": "notes/demo.txt",
"old_text": "second line",
"new_text": "2nd line"
}
] }
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: 'notes/demo.txt', old_text: 'hello, world', new_text: 'hi, world'},
{path: 'notes/demo.txt', old_text: 'second line', new_text: '2nd line'}
]
})
};
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' => 'notes/demo.txt',
'old_text' => 'hello, world',
'new_text' => 'hi, world'
],
[
'path' => 'notes/demo.txt',
'old_text' => 'second line',
'new_text' => '2nd line'
]
]
]),
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\": \"notes/demo.txt\",\n \"old_text\": \"hello, world\",\n \"new_text\": \"hi, world\"\n },\n {\n \"path\": \"notes/demo.txt\",\n \"old_text\": \"second line\",\n \"new_text\": \"2nd line\"\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\": \"notes/demo.txt\",\n \"old_text\": \"hello, world\",\n \"new_text\": \"hi, world\"\n },\n {\n \"path\": \"notes/demo.txt\",\n \"old_text\": \"second line\",\n \"new_text\": \"2nd line\"\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\": \"notes/demo.txt\",\n \"old_text\": \"hello, world\",\n \"new_text\": \"hi, world\"\n },\n {\n \"path\": \"notes/demo.txt\",\n \"old_text\": \"second line\",\n \"new_text\": \"2nd line\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"path": "notes/demo.txt",
"replacements_made": 1
},
{
"path": "notes/demo.txt",
"replacements_made": 1
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Agent Workspace
Multi Edit
Apply multiple file edits atomically in the agent’s workspace
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": "notes/demo.txt",
"old_text": "hello, world",
"new_text": "hi, world"
},
{
"path": "notes/demo.txt",
"old_text": "second line",
"new_text": "2nd line"
}
]
}
'import requests
url = "https://api.xpander.ai/v1/agents/{agent_id}/workspace/multi_edit"
payload = { "edits": [
{
"path": "notes/demo.txt",
"old_text": "hello, world",
"new_text": "hi, world"
},
{
"path": "notes/demo.txt",
"old_text": "second line",
"new_text": "2nd line"
}
] }
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: 'notes/demo.txt', old_text: 'hello, world', new_text: 'hi, world'},
{path: 'notes/demo.txt', old_text: 'second line', new_text: '2nd line'}
]
})
};
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' => 'notes/demo.txt',
'old_text' => 'hello, world',
'new_text' => 'hi, world'
],
[
'path' => 'notes/demo.txt',
'old_text' => 'second line',
'new_text' => '2nd line'
]
]
]),
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\": \"notes/demo.txt\",\n \"old_text\": \"hello, world\",\n \"new_text\": \"hi, world\"\n },\n {\n \"path\": \"notes/demo.txt\",\n \"old_text\": \"second line\",\n \"new_text\": \"2nd line\"\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\": \"notes/demo.txt\",\n \"old_text\": \"hello, world\",\n \"new_text\": \"hi, world\"\n },\n {\n \"path\": \"notes/demo.txt\",\n \"old_text\": \"second line\",\n \"new_text\": \"2nd line\"\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\": \"notes/demo.txt\",\n \"old_text\": \"hello, world\",\n \"new_text\": \"hi, world\"\n },\n {\n \"path\": \"notes/demo.txt\",\n \"old_text\": \"second line\",\n \"new_text\": \"2nd line\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"path": "notes/demo.txt",
"replacements_made": 1
},
{
"path": "notes/demo.txt",
"replacements_made": 1
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Apply multiple file edits atomically. Each edit uses the same exact-match semantics as File Edit. If any edit fails, all changes are rolled back.
Path Parameters
string
required
Agent ID (UUID)
Request Body
array
required
Response
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_textnot found), the entire batch is rolled back so the workspace is not left in a half-applied state.
See Also
Authorizations
API Key for authentication
Path Parameters
Body
application/json
List of edits to apply atomically. If any edit fails, all changes are rolled back.
Show child attributes
Show child attributes
Response
Successful Response
Results for each edit operation
Show child attributes
Show child attributes
Was this page helpful?
⌘I

