curl -X POST "https://app.runtm.com/api/cloud/sessions/ses_abc123/file" \
-H "Authorization: Bearer runtm_xxx" \
-H "Content-Type: application/json" \
-d '{
"path": "/src/index.ts",
"content": "console.log(\"hello world\");\n"
}'
import requests
response = requests.post(
"https://app.runtm.com/api/cloud/sessions/ses_abc123/file",
headers={
"Authorization": "Bearer runtm_xxx",
"Content-Type": "application/json",
},
json={
"path": "/src/index.ts",
"content": 'console.log("hello world");\n',
},
)
print(response.json()["path"])
const response = await fetch(
"https://app.runtm.com/api/cloud/sessions/ses_abc123/file",
{
method: "POST",
headers: {
"Authorization": "Bearer runtm_xxx",
"Content-Type": "application/json",
},
body: JSON.stringify({
path: "/src/index.ts",
content: 'console.log("hello world");\n',
}),
}
);
const data = await response.json();
console.log(`Wrote ${data.size} bytes to ${data.path}`);
{
"path": "/src/index.ts",
"size": 28
}
Files
Write File
Create or overwrite a file in the sandbox
POST
/
api
/
sessions
/
{session_id}
/
file
curl -X POST "https://app.runtm.com/api/cloud/sessions/ses_abc123/file" \
-H "Authorization: Bearer runtm_xxx" \
-H "Content-Type: application/json" \
-d '{
"path": "/src/index.ts",
"content": "console.log(\"hello world\");\n"
}'
import requests
response = requests.post(
"https://app.runtm.com/api/cloud/sessions/ses_abc123/file",
headers={
"Authorization": "Bearer runtm_xxx",
"Content-Type": "application/json",
},
json={
"path": "/src/index.ts",
"content": 'console.log("hello world");\n',
},
)
print(response.json()["path"])
const response = await fetch(
"https://app.runtm.com/api/cloud/sessions/ses_abc123/file",
{
method: "POST",
headers: {
"Authorization": "Bearer runtm_xxx",
"Content-Type": "application/json",
},
body: JSON.stringify({
path: "/src/index.ts",
content: 'console.log("hello world");\n',
}),
}
);
const data = await response.json();
console.log(`Wrote ${data.size} bytes to ${data.path}`);
{
"path": "/src/index.ts",
"size": 28
}
Creates or overwrites a file at the specified path in the sandbox.
Required scope:
sessions:write
Path Parameters
string
required
The session ID (e.g.
ses_abc123).Headers
string
required
Bearer token. Example:
Bearer runtm_xxxBody
string
required
Path where the file should be written (e.g.
/src/index.ts).string
required
File contents to write.
Response
string
Path of the written file.
integer
Size of the written file in bytes.
curl -X POST "https://app.runtm.com/api/cloud/sessions/ses_abc123/file" \
-H "Authorization: Bearer runtm_xxx" \
-H "Content-Type: application/json" \
-d '{
"path": "/src/index.ts",
"content": "console.log(\"hello world\");\n"
}'
import requests
response = requests.post(
"https://app.runtm.com/api/cloud/sessions/ses_abc123/file",
headers={
"Authorization": "Bearer runtm_xxx",
"Content-Type": "application/json",
},
json={
"path": "/src/index.ts",
"content": 'console.log("hello world");\n',
},
)
print(response.json()["path"])
const response = await fetch(
"https://app.runtm.com/api/cloud/sessions/ses_abc123/file",
{
method: "POST",
headers: {
"Authorization": "Bearer runtm_xxx",
"Content-Type": "application/json",
},
body: JSON.stringify({
path: "/src/index.ts",
content: 'console.log("hello world");\n',
}),
}
);
const data = await response.json();
console.log(`Wrote ${data.size} bytes to ${data.path}`);
{
"path": "/src/index.ts",
"size": 28
}