---
title: "Attach an input file"
method: POST
path: "/agents/{id}/files"
---

# Attach an input file

`POST /agents/{id}/files`

## Request

- Base URL: `https://api.endclose.com/v1`
- URL: `https://api.endclose.com/v1/agents/{id}/files`
- Auth: API key in header `X-API-KEY`

Attaches one file to the agent's input files — the same files the app's agent form manages under "Files". Every run lists the agent's input files in its prompt and can download them, so this is how to hand an agent a mapping table, a prior statement, or any reference material. Send `multipart/form-data` with a single `file` part; call once per file. Limits match the app: 50 MB per file, 20 files per agent, any content type (JSON is fine as an input). A file whose name matches an existing input file is added as a second file, not a replacement — delete the old one first to replace it.

## Path parameters

- `id` string, required

## Request body `multipart/form-data`

- object
  - `file` string, binary, required: The file to attach (at most 50 MB)

## Response `201`

File attached

- AgentFile: A file attached to an agent (input) or produced by a run (output). `url` is an absolute, signed download link on the API host; input files can also be fetched with `GET /agents/{id}/files/{file_id}`.
  - `id` string, uuid
  - `filename` string
  - `byte_size` integer
  - `content_type` string
  - `created_at` string, date-time
  - `url` string: Absolute signed download URL on the API host (e.g. `https://api.endclose.com/rails/active_storage/blobs/redirect/...`). Fetching it needs no credentials; it 302s to a short-lived object-storage URL.

## Other responses

- `401`: Unauthorized
- `403`: Forbidden — agent management requires a standard API key
- `404`: Agent not found
- `422`: No `file` part, file over 50 MB, or the agent already has 20 input files

## Changes

- **2026-09-09** `e1526383424c`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/endclose/apis/end-close-api/changes/agents/:id/files/post.md)

---

[API](https://skmtc.dev/endclose/apis/end-close-api.md) - [All operations](https://skmtc.dev/endclose/apis/end-close-api/llms.txt) - [OpenAPI document](https://skmtc.dev/endclose/apis/end-close-api/revisions/dfe0fde00f12?raw)
