---
title: "Create an agent environment file"
method: POST
path: "/agents/environments/{environment_id}/files"
tags: ["Agents"]
---

# Create an agent environment file

`POST /agents/environments/{environment_id}/files`

Copies inline bytes or a Files API file into a connected execution environment. See [environment files](https://developers.openai.com/api/docs/guides/agents-api/environments/files).

## Path parameters

- `environment_id` string, required

## Request body

- union — A file materialized in an OpenAI-hosted execution environment.
  - object — A file previously uploaded through the OpenAI Files API.
    - `type` 'file_id', required — The type of the object. Always `file_id`.
    - `file_id` string, required — The ID of the uploaded file.
    - `path` string, required — The absolute destination path inside `/workspace`.
  - object — A file supplied directly as standard-base64 data.
    - `type` 'inline', required — The type of the object. Always `inline`.
    - `data` string, required — The standard-base64-encoded file contents.
    - `path` string, required — The absolute destination path inside `/workspace`.

## Response `201`

The created live environment file.

- EnvironmentFileResource — A live file in an execution environment.
  - `object` 'agent.environment.file', required — The object type. Always `agent.environment.file`.
  - `environment_id` string, required — The ID of the environment containing this file.
  - `path` string, required — The absolute file path inside the environment's workspace.
  - `size_bytes` integer, required — The file size in bytes.

## Other responses

- `400` — The request was invalid.
- `401` — Authentication or project context was missing.
- `403` — The API key lacks the required permission.
- `404` — The requested session or event was not found.
- `409` — The request conflicted with the current session state.
- `500` — An internal error occurred.
- `503` — The service is temporarily unavailable.

## Changes

- **2026-09-25** `d86203de41ae` — 1 info
  - added the non-success response with the status `403`
- **2026-09-10** `f2dae1a9aced` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/openai/apis/openapi/changes/agents/environments/:environment_id/files/post.md)

---

[API](https://skmtc.dev/openai/apis/openapi.md) · [All operations](https://skmtc.dev/openai/apis/openapi/llms.txt) · [OpenAPI document](https://skmtc.dev/openai/apis/openapi/revisions/4b75527da17b?raw)
