Configure the workspace
Files & artifacts
Upload inputs, pin file content and retrieve results.
On this page
Store task inputs
Files live in the Environment's persistent /workspace RootFS. The public API supports directory listing, byte upload, base64 readback, and deletion; see the generated file operations for their exact paths, parameters, media types, and size limits. Parent directories must exist. File operations need an initial checkpoint and cannot proceed while a Run or rollback holds the lifecycle lock. Paths must be canonical and inside /workspace; protected Sandpi state, Git metadata, symlinks, and directories are not accepted as file targets. Bytes stay in Sandbox0, not PostgreSQL.
Workspace access and conflicts
File-access conflicts return HTTP 409 with a reason-specific error code documented in the API details. A Run being queued or executed, checkpoint capture, rollback, initialization, and pause/resume transitions are distinct from generic lock contention; failed checkpoints are reported separately. A ready Run checkpoint can be visible before the worker finishes its subsequent memory pause and releases the lifecycle lock. Clients should wait for active work to finish and retry transient transitions; persistent checkpoint failures require operator investigation. No file operation bypasses the lock.
Reference existing files
Runs can reference regular Environment files that already exist. The worker checks paths just before starting the harness. An optional digest detects content changes; without one, a queued Run reads the file as it exists at execution time. Runs execute serially, so earlier work can alter files before a later Run begins. A rollback can remove or restore referenced files; a later Run checks its paths against the restored Workspace. The harness receives file paths in its prompt and reads them using native tools.
Inspect file changes
The Run file diff reports regular file additions, changes, and deletions under /workspace with before and after SHA-256 identities. Sandpi state, Git metadata, and generated caches are excluded. A large Workspace can fail diff computation without failing the Run or its checkpoint.
Create or replace an Environment file
/v1/environments/{environmentId}/fileUpload one file under /workspace; at most 10 MiB of raw bytes.
Authentication: Platform API bearer token
Parameters and headers
| Field | Type and constraints | Required | Description |
|---|---|---|---|
query: path | string · min length 1; max length 2048 | Yes | Canonical absolute workspace path. For directory listing, identify the directory; file operations require a regular file path. |
path: environmentId | string · min length 1 | Yes | Environment identifier. It must belong to the caller’s account or Project. |
Request example
curl -X PUT \
"https://api.sandpi.ai/v1/environments/$ENVIRONMENT_ID/file?path=%2Fworkspace%2Fexample.md" \
-H "Authorization: Bearer $SANDPI_API_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @example.mdRequest body · required application/octet-stream
Maximum bytes: 10,485,760
| Field | Type and constraints | Required | Description |
|---|---|---|---|
body | string · format: binary | Yes | — |
Example
"<binary bytes>"Responses
200 Successful response.Response body application/json
| Field | Type and constraints | Required | Description |
|---|---|---|---|
data | object · extra fields rejected | Yes | Workspace file path, byte size and SHA-256 content identity. |
data.path | string | Yeswithin data | Canonical absolute path inside /workspace. Protected state, Git metadata and symlinks are not accepted file targets. |
data.sizeBytes | integer · ≥ -9007199254740991; ≤ 9007199254740991 | Yeswithin data | UTF-8 or file content size in bytes. |
data.sha256 | stringValidation pattern^[a-f0-9]{64}$ | Yeswithin data | Lowercase hexadecimal SHA-256 digest of the file bytes. |
Example
{
"data": {
"path": "",
"sizeBytes": -9007199254740991,
"sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
}Error responses
400 Invalid request.application/json
401 Missing or invalid Platform API token.application/json
404 Resource not found or outside token scope.application/json
409 Environment file access is temporarily blocked. The error code identifies queued/executing work, checkpoint saving, initialization, rollback, pausing, resuming, or other lock contention. Checkpoint ready does not guarantee the lifecycle lock has been released.application/json
413 Uploaded file exceeds the byte limit.application/json
415 Unsupported request media type.application/json
default Sandpi error.Error body application/json
Standard error envelope containing a stable code, diagnostic message and request identity.
| Field | Type and constraints | Required | Description |
|---|---|---|---|
error | object · extra fields rejected | Yes | Structured failure information. Inspect the stable code and retain the request ID for investigation. |
error.code | string | Yeswithin error | Stable error code used to distinguish failures programmatically. |
error.message | string | Yeswithin error | Human-readable diagnostic text. |
error.requestId | string | Yeswithin error | Request identifier for correlating diagnostics and support investigations. |
error.details | any | Nowithin error | Optional structured error context. Its shape is specific to the service failure. |
error.loginUrl | string | Nowithin error | Authentication URL supplied when a browser login is required. |
error.registrationOpen | boolean | Nowithin error | Whether new account registration is enabled for this deployment. |
Example
{
"error": {
"code": "platform_balance_insufficient",
"message": "Top up Platform credits before submitting a Run.",
"requestId": "req_example"
}
}Read artifacts
List the output directory after execution and its checkpoint settle. File reads return base64 content, size and a SHA-256 digest. Decode the content in your client; it is not a raw download body.
List files in an Environment directory
/v1/environments/{environmentId}/filesAuthentication: Platform API bearer token
Parameters and headers
| Field | Type and constraints | Required | Description |
|---|---|---|---|
query: path | string · min length 1; max length 2048 | Yes | Canonical absolute workspace path. For directory listing, identify the directory; file operations require a regular file path. |
path: environmentId | string · min length 1 | Yes | Environment identifier. It must belong to the caller’s account or Project. |
Request example
curl \
"https://api.sandpi.ai/v1/environments/$ENVIRONMENT_ID/files?path=%2Fworkspace%2Fexample.md" \
-H "Authorization: Bearer $SANDPI_API_TOKEN"No request body.
Responses
200 Successful response.Response body application/json
| Field | Type and constraints | Required | Description |
|---|---|---|---|
data | object · extra fields rejected | Yes | Successful result wrapped by the API. The child fields describe its content. |
data.path | string | Yeswithin data | Canonical absolute path inside /workspace. Protected state, Git metadata and symlinks are not accepted file targets. |
data.entries | array | Yeswithin data | Directory entries returned for the requested workspace path. |
data.entries[] | object · extra fields rejected | Yeseach array item | — |
data.entries[].path | string | Yeseach array item | Canonical absolute path inside /workspace. Protected state, Git metadata and symlinks are not accepted file targets. |
data.entries[].name | string | Yeseach array item | Human-readable name for this resource. |
data.entries[].kind | string · values: "file" | "folder" | Yeseach array item | Selects the resource or operation variant described by the allowed values. |
data.entries[].sizeBytes | integer · ≥ -9007199254740991; ≤ 9007199254740991 | Noeach array item | UTF-8 or file content size in bytes. |
Example
{
"data": {
"path": "",
"entries": [
{
"path": "",
"name": "",
"kind": "file"
}
]
}
}Error responses
400 Invalid request.application/json
401 Missing or invalid Platform API token.application/json
404 Resource not found or outside token scope.application/json
409 Environment file access is temporarily blocked. The error code identifies queued/executing work, checkpoint saving, initialization, rollback, pausing, resuming, or other lock contention. Checkpoint ready does not guarantee the lifecycle lock has been released.application/json
default Sandpi error.Error body application/json
Standard error envelope containing a stable code, diagnostic message and request identity.
| Field | Type and constraints | Required | Description |
|---|---|---|---|
error | object · extra fields rejected | Yes | Structured failure information. Inspect the stable code and retain the request ID for investigation. |
error.code | string | Yeswithin error | Stable error code used to distinguish failures programmatically. |
error.message | string | Yeswithin error | Human-readable diagnostic text. |
error.requestId | string | Yeswithin error | Request identifier for correlating diagnostics and support investigations. |
error.details | any | Nowithin error | Optional structured error context. Its shape is specific to the service failure. |
error.loginUrl | string | Nowithin error | Authentication URL supplied when a browser login is required. |
error.registrationOpen | boolean | Nowithin error | Whether new account registration is enabled for this deployment. |
Example
{
"error": {
"code": "platform_balance_insufficient",
"message": "Top up Platform credits before submitting a Run.",
"requestId": "req_example"
}
}Read an Environment file as base64
/v1/environments/{environmentId}/fileRead one file as base64; files are limited to 10 MiB.
Authentication: Platform API bearer token
Parameters and headers
| Field | Type and constraints | Required | Description |
|---|---|---|---|
query: path | string · min length 1; max length 2048 | Yes | Canonical absolute workspace path. For directory listing, identify the directory; file operations require a regular file path. |
path: environmentId | string · min length 1 | Yes | Environment identifier. It must belong to the caller’s account or Project. |
Request example
curl \
"https://api.sandpi.ai/v1/environments/$ENVIRONMENT_ID/file?path=%2Fworkspace%2Fexample.md" \
-H "Authorization: Bearer $SANDPI_API_TOKEN"No request body.
Responses
200 Successful response.Response body application/json
| Field | Type and constraints | Required | Description |
|---|---|---|---|
data | object · extra fields rejected | Yes | Successful result wrapped by the API. The child fields describe its content. |
data.path | string | Yeswithin data | Canonical absolute path inside /workspace. Protected state, Git metadata and symlinks are not accepted file targets. |
data.sizeBytes | integer · ≥ -9007199254740991; ≤ 9007199254740991 | Yeswithin data | UTF-8 or file content size in bytes. |
data.sha256 | stringValidation pattern^[a-f0-9]{64}$ | Yeswithin data | Lowercase hexadecimal SHA-256 digest of the file bytes. |
data.encoding | string · values: "base64" | Yeswithin data | Encoding used for returned file content; base64 represents the raw bytes. |
data.content | string | Yeswithin data | File bytes encoded as base64. Decode them before use. |
Example
{
"data": {
"path": "",
"sizeBytes": -9007199254740991,
"sha256": "",
"encoding": "base64",
"content": ""
}
}Error responses
400 Invalid request.application/json
401 Missing or invalid Platform API token.application/json
404 Resource not found or outside token scope.application/json
409 Environment file access is temporarily blocked. The error code identifies queued/executing work, checkpoint saving, initialization, rollback, pausing, resuming, or other lock contention. Checkpoint ready does not guarantee the lifecycle lock has been released.application/json
default Sandpi error.Error body application/json
Standard error envelope containing a stable code, diagnostic message and request identity.
| Field | Type and constraints | Required | Description |
|---|---|---|---|
error | object · extra fields rejected | Yes | Structured failure information. Inspect the stable code and retain the request ID for investigation. |
error.code | string | Yeswithin error | Stable error code used to distinguish failures programmatically. |
error.message | string | Yeswithin error | Human-readable diagnostic text. |
error.requestId | string | Yeswithin error | Request identifier for correlating diagnostics and support investigations. |
error.details | any | Nowithin error | Optional structured error context. Its shape is specific to the service failure. |
error.loginUrl | string | Nowithin error | Authentication URL supplied when a browser login is required. |
error.registrationOpen | boolean | Nowithin error | Whether new account registration is enabled for this deployment. |
Example
{
"error": {
"code": "platform_balance_insufficient",
"message": "Top up Platform credits before submitting a Run.",
"requestId": "req_example"
}
}Pin a Run input
Include the path in the Run’s files array. Use the digest returned by a read when you need to ensure the worker sees those same bytes. The Run API details supplies the exact file-reference contract. Uploading a file alone does not attach it to a Run.
Remove a file
Deletion changes the live workspace. Existing checkpoints can still contain the file, and rollback can restore it. For whole-Environment cleanup, use retention and deletion.
Delete an Environment file
/v1/environments/{environmentId}/fileAuthentication: Platform API bearer token
Parameters and headers
| Field | Type and constraints | Required | Description |
|---|---|---|---|
query: path | string · min length 1; max length 2048 | Yes | Canonical absolute workspace path. For directory listing, identify the directory; file operations require a regular file path. |
path: environmentId | string · min length 1 | Yes | Environment identifier. It must belong to the caller’s account or Project. |
Request example
curl -X DELETE \
"https://api.sandpi.ai/v1/environments/$ENVIRONMENT_ID/file?path=%2Fworkspace%2Fexample.md" \
-H "Authorization: Bearer $SANDPI_API_TOKEN"No request body.
Responses
204 No content.Empty response body.
Error responses
400 Invalid request.application/json
401 Missing or invalid Platform API token.application/json
404 Resource not found or outside token scope.application/json
409 Environment file access is temporarily blocked. The error code identifies queued/executing work, checkpoint saving, initialization, rollback, pausing, resuming, or other lock contention. Checkpoint ready does not guarantee the lifecycle lock has been released.application/json
default Sandpi error.Error body application/json
Standard error envelope containing a stable code, diagnostic message and request identity.
| Field | Type and constraints | Required | Description |
|---|---|---|---|
error | object · extra fields rejected | Yes | Structured failure information. Inspect the stable code and retain the request ID for investigation. |
error.code | string | Yeswithin error | Stable error code used to distinguish failures programmatically. |
error.message | string | Yeswithin error | Human-readable diagnostic text. |
error.requestId | string | Yeswithin error | Request identifier for correlating diagnostics and support investigations. |
error.details | any | Nowithin error | Optional structured error context. Its shape is specific to the service failure. |
error.loginUrl | string | Nowithin error | Authentication URL supplied when a browser login is required. |
error.registrationOpen | boolean | Nowithin error | Whether new account registration is enabled for this deployment. |
Example
{
"error": {
"code": "platform_balance_insufficient",
"message": "Top up Platform credits before submitting a Run.",
"requestId": "req_example"
}
}