Write a source file in the current workspace to a path in a managed environment.
Endpoint
POST /agents/environments/{environment_id}/files
Writes a source file to a /workspace/ path in the specified environment. A successful call returns 201 and environment file information. A successful write means the file is on disk; it does not mean the model has read it.
Path parameters
| Field | Required | Type | Description |
|---|---|---|---|
environment_id | Yes | string | Environment ID, an environment in the current workspace |
Request body
| Field | Required | Type | Description |
|---|---|---|---|
type | Yes | string | File reference type, fixed as file_id |
file_id | Yes | string | Source file ID, from an Agent API upload in the current workspace |
path | Yes | string | Normalized absolute path under /workspace/; directory traversal is not allowed |
Request example
Response example
Response fields
| Field | Type | Description |
|---|---|---|
environment_id | string | Environment ID |
object | string | Environment file object type, fixed as agent.environment.file |
path | string | File path in the environment |
size_bytes | integer | Number of bytes written |
Error codes
| HTTP status | Error type / code | Solution |
|---|---|---|
400 | invalid_request_error / invalid_request_error | Add required fields and fix type and path as described for each field |
404 | not_found_error / not_found_error | Use a source file ID that exists and is visible in the current workspace |
400 | invalid_request_error / invalid_request_error, param=file_id | Use a source file uploaded through POST /agents/file |
409 | invalid_request_error / file_not_available, param=file_id | Use a source file that passed review and is available |
504 | server_error / environment_file_timeout | Retry later. If it keeps failing, submit a ticket with x-request-id |
{"error":{"type","code","message","param"}}. Gateway errors can use a different structure.