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 parametersenvironment_idstring (required)Environment ID, an environment in the current workspaceRequest bodytypestring (required)File reference type, fixed as file_idfile_id string (required)Source file ID, from an Agent API upload in the current workspacepath string (required)Normalized absolute path under /workspace/; directory traversal is not allowedThe request body does not accept extra fields. The source file must come from an Agent API upload in the current workspace. | Request example |
Response fieldsenvironment_idstringEnvironment IDobject stringEnvironment file object type, fixed as agent.environment.filepath stringFile path in the environmentsize_bytes integerNumber of bytes writtenThe response does not contain a new source file ID and is not an artifact publication receipt. | Response example |
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.