Sample - OpenAI API
POST/agents/environments/{environment_id}/files

Create an agent environment file

Creates a file in a connected agent execution environment by copying an uploaded Files API file or materializing inline base64 data. Choose the file_id or inline body variant and provide the destination path inside /workspace. A 201 response returns the created environment file with its path and size in bytes.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

1 parameter · 3 body fields
environment_idstringrequired
The ID of the execution environment. Must be at most 1048576 characters.

A file to materialize in the execution environment. Use either the file_id variant for a file uploaded through the Files API or the inline variant for standard-base64 file contents.

typestringrequired
The type of the object. Always `file_id`.
Allowed:file_idDefault:file_id
file_idstringrequired
The ID of the uploaded file.
pathstringrequired
The absolute destination path inside `/workspace`.

7 status codes
201Returns the created live environment file, including its object type, `environment_id`, absolute workspace `path`, and `size_bytes`.
objectstringrequired
The object type. Always `agent.environment.file`.
Allowed:agent.environment.fileDefault:agent.environment.file
environment_idstringrequired
The ID of the environment containing this file.
pathstringrequired
The absolute file path inside the environment's workspace.
size_bytesintegerrequired
The file size in bytes.
400Returned when the request is invalid, such as when the body does not match either supported file variant or a field fails validation.
errorobjectrequired
The error returned by the API.
401Returned when authentication or project context is missing.
errorobjectrequired
The error returned by the API.
404Returned when the requested session or event is not found.
errorobjectrequired
The error returned by the API.
409Returned when the request conflicts with the current session state.
errorobjectrequired
The error returned by the API.
500Returned when an internal error occurs.
errorobjectrequired
The error returned by the API.
503Returned when the service is temporarily unavailable.
errorobjectrequired
The error returned by the API.

Error handling

A 400 is returned when the request body is invalid, a 401 when authentication or project context is missing, and a 404 when the requested session or event is not found. A 409 indicates that the request conflicts with the current session state; a 500 indicates an internal error, and a 503 indicates temporary service unavailability. The body must use either the file_id variant with type, file_id, and path, or the inline variant with type, data, and path; path must be 1 to 4096 characters and data must be standard-base64 data of up to 6990508 characters.