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 bodyfilebinary file (required)File part in the form; the filename comes from the form and mime_type is detected by the serviceNo 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 fieldsidstringSource file IDtype stringResource type, fixed as filefilename stringFile namemime_type stringMIME type detected by the servicesize_bytes integerFile size in bytesdownloadable booleanPlatform metadata flag; not a substitute for the inspection check used when writing to an environmentstatus stringFile status: checking, available, rejected, type_rejected, and so oncreated_at stringCreation time, RFC3339 timestamprequest_id stringIdentifier of this upload requestA successful upload does not mean the file passed inspection or can be written to an environment immediately. Writing can fail or wait while the file is being inspected or after inspection fails. | Response example |
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.