Files
Files are used to store binary data, such as documents, images, or other media. These files can be attached to messages or utilized in other contexts within the system.
File object
Attributes
id
StringA unique identifier for the file, used to reference the file across the API.
purpose
EnumDefines the purpose of the file. This determines how and where the file will be used.
name
StringThe human-readable name of the file, typically provided during upload.
size
NumberThe size of the file in bytes, representing the file’s storage requirement.
mime_type
StringThe MIME type of the file, indicating its format (e.g., "text/plain" for plain text files).
created_at
DateThe date and time when the file was created, in ISO 8601 format.
{"id": "file_Rm4Mnheq2bfEPhBhP7SY","purpose": "attachment","name": "example.txt","size": 1024,"mime_type": "text/plain","created_at": "2025-01-01T00:00:00.000Z"}
List Files
Retrieve a list of all files, optionally filtered by various criteria.
Query Parameters
id
ObjectOptionalFilter files by their unique identifiers.
created_at
ObjectOptionalFilter files based on their creation date.
purpose
ObjectOptionalFilter files by their designated purpose.
curl https://api.metorial.com/files-H "Authorization: Bearer metorial_sk_..."
Get File
Retrieve details of a specific file by its unique identifier.
URL Parameters
fileId
StringThe unique identifier of the file.
curl https://api.metorial.com/files/file_Rm4Mnheq2bfEPhBhP7SY-H "Authorization: Bearer metorial_sk_..."
Create File Link
Retrieve a downloadable link for a specific file by its unique identifier.
URL Parameters
fileId
StringThe unique identifier of the file.
curl https://api.metorial.com/files/file_Rm4Mnheq2bfEPhBhP7SY/links-H "Authorization: Bearer metorial_sk_..."
Create File
Upload a new file to the system. After the file is uploaded it it can be referenced by its unique identifier in other API calls. Note that the base URL for this endpoint is different from the other API endpoints, it is https://files.metorial.com
. Moreover, you should use Multipart Form Data for the request body.
Request Body
purpose
EnumDefines how the file will be used.
file
FileThe binary data of the file to be uploaded.
curl -X POST https://files.metorial.com/files-H "Authorization: Bearer $$SECRET_TOKEN"-F "purpose=attachment"-F "file=@/path/to/file.txt"