Conway

Files

Upload, download, and list files in sandboxes.

Upload File

POST /v1/sandboxes/:id/files

Upload a file to a sandbox.

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe sandbox ID

Request Body

ParameterTypeRequiredDescription
pathstringYesThe path in the sandbox where the file should be saved
contentstringYesThe file content (base64 encoded for binary files)

Example

curl -X POST https://api.conway.tech/v1/sandboxes/sbx_abc123/files \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "/home/ubuntu/hello.txt",
    "content": "Hello from Conway!"
  }'
await fetch("https://api.conway.tech/v1/sandboxes/sbx_abc123/files", {
  method: "POST",
  headers: {
    Authorization: "Bearer your-api-key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    path: "/home/ubuntu/hello.txt",
    content: "Hello from Conway!",
  }),
});

Response

Returns 201 Created on success.


Download File

GET /v1/sandboxes/:id/files?path=<path>

Download a file from a sandbox.

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe sandbox ID

Query Parameters

ParameterTypeRequiredDescription
pathstringYesThe path of the file in the sandbox

Example

curl "https://api.conway.tech/v1/sandboxes/sbx_abc123/files?path=/home/ubuntu/hello.txt" \
  -H "Authorization: Bearer your-api-key"
const response = await fetch(
  "https://api.conway.tech/v1/sandboxes/sbx_abc123/files?path=/home/ubuntu/hello.txt",
  {
    headers: { Authorization: "Bearer your-api-key" },
  }
);

Response

{
  "content": "Hello from Conway!"
}

List Files

GET /v1/sandboxes/:id/files/list?path=<path>

List files and directories in a sandbox path.

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe sandbox ID

Query Parameters

ParameterTypeRequiredDescription
pathstringYesThe directory path to list

Example

curl "https://api.conway.tech/v1/sandboxes/sbx_abc123/files/list?path=/home/ubuntu" \
  -H "Authorization: Bearer your-api-key"
const response = await fetch(
  "https://api.conway.tech/v1/sandboxes/sbx_abc123/files/list?path=/home/ubuntu",
  {
    headers: { Authorization: "Bearer your-api-key" },
  }
);

Response

{
  "files": [
    {
      "name": "hello.txt",
      "isDir": false,
      "size": 17
    },
    {
      "name": "projects",
      "isDir": true,
      "size": 4096
    }
  ]
}