sandpi/ platform

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

PUT /v1/environments/{environmentId}/file

Upload one file under /workspace; at most 10 MiB of raw bytes.

Authentication: Platform API bearer token

Parameters and headers
FieldType and constraintsRequiredDescription
query: pathstring · min length 1; max length 2048YesCanonical absolute workspace path. For directory listing, identify the directory; file operations require a regular file path.
path: environmentIdstring · min length 1YesEnvironment identifier. It must belong to the caller’s account or Project.

Request example

sh
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.md
Request body · required application/octet-stream

Maximum bytes: 10,485,760

FieldType and constraintsRequiredDescription
bodystring · format: binaryYes—
Example
Example
"<binary bytes>"

Responses

200 Successful response.
Response body application/json
FieldType and constraintsRequiredDescription
dataobject · extra fields rejectedYesWorkspace file path, byte size and SHA-256 content identity.
data.pathstringYeswithin dataCanonical absolute path inside /workspace. Protected state, Git metadata and symlinks are not accepted file targets.
data.sizeBytesinteger · ≥ -9007199254740991; ≤ 9007199254740991Yeswithin dataUTF-8 or file content size in bytes.
data.sha256string
Validation pattern^[a-f0-9]{64}$
Yeswithin dataLowercase hexadecimal SHA-256 digest of the file bytes.
Example
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.

FieldType and constraintsRequiredDescription
errorobject · extra fields rejectedYesStructured failure information. Inspect the stable code and retain the request ID for investigation.
error.codestringYeswithin errorStable error code used to distinguish failures programmatically.
error.messagestringYeswithin errorHuman-readable diagnostic text.
error.requestIdstringYeswithin errorRequest identifier for correlating diagnostics and support investigations.
error.detailsanyNowithin errorOptional structured error context. Its shape is specific to the service failure.
error.loginUrlstringNowithin errorAuthentication URL supplied when a browser login is required.
error.registrationOpenbooleanNowithin errorWhether new account registration is enabled for this deployment.
Example
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

GET /v1/environments/{environmentId}/files

Authentication: Platform API bearer token

Parameters and headers
FieldType and constraintsRequiredDescription
query: pathstring · min length 1; max length 2048YesCanonical absolute workspace path. For directory listing, identify the directory; file operations require a regular file path.
path: environmentIdstring · min length 1YesEnvironment identifier. It must belong to the caller’s account or Project.

Request example

sh
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
FieldType and constraintsRequiredDescription
dataobject · extra fields rejectedYesSuccessful result wrapped by the API. The child fields describe its content.
data.pathstringYeswithin dataCanonical absolute path inside /workspace. Protected state, Git metadata and symlinks are not accepted file targets.
data.entriesarrayYeswithin dataDirectory entries returned for the requested workspace path.
data.entries[]object · extra fields rejectedYeseach array item—
data.entries[].pathstringYeseach array itemCanonical absolute path inside /workspace. Protected state, Git metadata and symlinks are not accepted file targets.
data.entries[].namestringYeseach array itemHuman-readable name for this resource.
data.entries[].kindstring · values: "file" | "folder"Yeseach array itemSelects the resource or operation variant described by the allowed values.
data.entries[].sizeBytesinteger · ≥ -9007199254740991; ≤ 9007199254740991Noeach array itemUTF-8 or file content size in bytes.
Example
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.

FieldType and constraintsRequiredDescription
errorobject · extra fields rejectedYesStructured failure information. Inspect the stable code and retain the request ID for investigation.
error.codestringYeswithin errorStable error code used to distinguish failures programmatically.
error.messagestringYeswithin errorHuman-readable diagnostic text.
error.requestIdstringYeswithin errorRequest identifier for correlating diagnostics and support investigations.
error.detailsanyNowithin errorOptional structured error context. Its shape is specific to the service failure.
error.loginUrlstringNowithin errorAuthentication URL supplied when a browser login is required.
error.registrationOpenbooleanNowithin errorWhether new account registration is enabled for this deployment.
Example
Example
{
  "error": {
    "code": "platform_balance_insufficient",
    "message": "Top up Platform credits before submitting a Run.",
    "requestId": "req_example"
  }
}

Read an Environment file as base64

GET /v1/environments/{environmentId}/file

Read one file as base64; files are limited to 10 MiB.

Authentication: Platform API bearer token

Parameters and headers
FieldType and constraintsRequiredDescription
query: pathstring · min length 1; max length 2048YesCanonical absolute workspace path. For directory listing, identify the directory; file operations require a regular file path.
path: environmentIdstring · min length 1YesEnvironment identifier. It must belong to the caller’s account or Project.

Request example

sh
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
FieldType and constraintsRequiredDescription
dataobject · extra fields rejectedYesSuccessful result wrapped by the API. The child fields describe its content.
data.pathstringYeswithin dataCanonical absolute path inside /workspace. Protected state, Git metadata and symlinks are not accepted file targets.
data.sizeBytesinteger · ≥ -9007199254740991; ≤ 9007199254740991Yeswithin dataUTF-8 or file content size in bytes.
data.sha256string
Validation pattern^[a-f0-9]{64}$
Yeswithin dataLowercase hexadecimal SHA-256 digest of the file bytes.
data.encodingstring · values: "base64"Yeswithin dataEncoding used for returned file content; base64 represents the raw bytes.
data.contentstringYeswithin dataFile bytes encoded as base64. Decode them before use.
Example
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.

FieldType and constraintsRequiredDescription
errorobject · extra fields rejectedYesStructured failure information. Inspect the stable code and retain the request ID for investigation.
error.codestringYeswithin errorStable error code used to distinguish failures programmatically.
error.messagestringYeswithin errorHuman-readable diagnostic text.
error.requestIdstringYeswithin errorRequest identifier for correlating diagnostics and support investigations.
error.detailsanyNowithin errorOptional structured error context. Its shape is specific to the service failure.
error.loginUrlstringNowithin errorAuthentication URL supplied when a browser login is required.
error.registrationOpenbooleanNowithin errorWhether new account registration is enabled for this deployment.
Example
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

DELETE /v1/environments/{environmentId}/file

Authentication: Platform API bearer token

Parameters and headers
FieldType and constraintsRequiredDescription
query: pathstring · min length 1; max length 2048YesCanonical absolute workspace path. For directory listing, identify the directory; file operations require a regular file path.
path: environmentIdstring · min length 1YesEnvironment identifier. It must belong to the caller’s account or Project.

Request example

sh
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.

FieldType and constraintsRequiredDescription
errorobject · extra fields rejectedYesStructured failure information. Inspect the stable code and retain the request ID for investigation.
error.codestringYeswithin errorStable error code used to distinguish failures programmatically.
error.messagestringYeswithin errorHuman-readable diagnostic text.
error.requestIdstringYeswithin errorRequest identifier for correlating diagnostics and support investigations.
error.detailsanyNowithin errorOptional structured error context. Its shape is specific to the service failure.
error.loginUrlstringNowithin errorAuthentication URL supplied when a browser login is required.
error.registrationOpenbooleanNowithin errorWhether new account registration is enabled for this deployment.
Example
Example
{
  "error": {
    "code": "platform_balance_insufficient",
    "message": "Top up Platform credits before submitting a Run.",
    "requestId": "req_example"
  }
}