POST
/containers/{container_id}/filesCreate a file in a container
Creates a file in a container from raw multipart file content or a file ID supplied in a JSON request. Choose the request format based on whether you are uploading file content or referencing a file, and use container_id to identify the destination container.
- IdempotentThe SDK sends
Idempotency-Key, so a retried request is only applied once.
container_idstringrequired
The identifier of the container to add the file to.
Provide either a JSON request with a file ID or a multipart/form-data request with raw file content.
file_idstringoptional
Name of the file to create.
filestringoptional
The File object (not file name) to be uploaded.
200Returns the created container file object, including its identifier, container, creation time, size in bytes, path, and source.
idstringrequired
Unique identifier for the file.
objectstringrequired
The type of this object (`container.file`).
container_idstringrequired
The container this file belongs to.
created_atintegerrequired
Unix timestamp (in seconds) when the file was created.
bytesintegerrequired
Size of the file in bytes.
pathstringrequired
Path of the file in the container.
sourcestringrequired
Source of the file (e.g., `user`, `assistant`).
400Returned when the file input is invalid or creating the file would exceed the container file limit.
errorobjectrequired
404Returned when the container was not found or has expired.
errorobjectrequired
429Returned when the request exceeds a rate limit.
errorobjectrequired
Error handling
A 400 is returned when the file input is invalid or the container file limit would be exceeded. A 404 is returned when the container_id path parameter identifies a container that was not found or has expired. A 429 is returned when the request exceeds a rate limit.