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

String

A unique identifier for the file, used to reference the file across the API.

purpose

Enum

Defines the purpose of the file. This determines how and where the file will be used.

name

String

The human-readable name of the file, typically provided during upload.

size

Number

The size of the file in bytes, representing the file’s storage requirement.

mime_type

String

The MIME type of the file, indicating its format (e.g., "text/plain" for plain text files).

created_at

Date

The 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

ObjectOptional

Filter files by their unique identifiers.

created_at

ObjectOptional

Filter files based on their creation date.

purpose

ObjectOptional

Filter files by their designated purpose.

GEThttps://api.metorial.com/files
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

String

The unique identifier of the file.

GEThttps://api.metorial.com/files/:fileId
curl https://api.metorial.com/files/file_Rm4Mnheq2bfEPhBhP7SY
-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

Enum

Defines how the file will be used.

file

File

The binary data of the file to be uploaded.

POSThttps://files.metorial.com/files
curl -X POST https://files.metorial.com/files
-H "Authorization: Bearer $$SECRET_TOKEN"
-F "purpose=attachment"
-F "file=@/path/to/file.txt"