Upload an Agent API source file through multipart/form-data and obtain a file_id.
Endpoint
POST /agents/file
Uploads a source file to the current workspace with multipart/form-data. A successful call returns 200 and file metadata. Uploading and writing to an environment are separate steps; after obtaining the file_id, write the file to an environment.
Request body
| Field | Required | Type | Description |
|---|---|---|---|
file | Yes | binary file | File part in the form; the filename comes from the form and mime_type is detected by the service |
purpose field is required. The service saves the file with the Agent API origin. Upload size is limited by the gateway and content inspection.
Request example
Response example
Response fields
| Field | Type | Description |
|---|---|---|
id | string | Source file ID |
type | string | Resource type, fixed as file |
filename | string | File name |
mime_type | string | MIME type detected by the service |
size_bytes | integer | File size in bytes |
downloadable | boolean | Platform metadata flag; not a substitute for the inspection check used when writing to an environment |
status | string | File status: checking, available, rejected, type_rejected, and so on |
created_at | string | Creation time, RFC3339 timestamp |
request_id | string | Identifier of this upload request |
Error codes
| HTTP status | Error type / code | Solution |
|---|---|---|
400 | invalid_request_error / invalid_request_error, param=file | Select a non-empty file and retry |
413 | invalid_request_error / invalid_request_error, param=file | Reduce the file size and retry |
| — | Can return No such File or a batch purpose limit | Use /agents/file to upload source files |
x-request-id, and file metadata for troubleshooting.