📁 Upload Files
Upload File
This endpoint allows you to upload a file to a specific index. The uploaded file will be stored in S3 in a two-step process. First, you'll request a pre-signed URL, and then you'll upload the file to that URL.
POST
/
v1
/
indexes
/
{id}
/
files
Header
Path
Body
# Example Request
curl --location --request POST 'https://api.getmetal.io/v1/indexes/{id}/files' \
--header 'Content-Type: application/json' \
--header 'x-metal-api-key: <api-key>' \
--header 'x-metal-client-id: <client-id>' \
--data-raw '{
"fileName": "example.pdf",
"fileType": "application/pdf"
}'
{
"data": {
"id": "<generated-id>",
"status": "CREATED",
"createdAt": "2023-08-29T18:00:00.000Z",
"fileName": "example.pdf",
"fileType": "application/pdf",
"url": "<preSignedUrl>"
}
}
Two-step process
- Step 1:
POST https://api.getmetal.io/v1/indexes/{id}/files
- Step 2:
PUT
to the signed URL
Step 1: Request a Pre-signed URL for the File
Auth Headers
x-metal-api-key
string
requiredAn API key for your org.
x-metal-client-id
string
requiredA Client ID for your org.
x-metal-file-size
number
The size of the file in bytes. Limited to 10MB.
Params
id
string
requiredIndex ID
Body
fileName
string
requiredThe name of the file being uploaded.
fileType
string
requiredThe MIME type of the file being uploaded. Must be one of the following:
application/pdf
for PDF filestext/csv
for CSV filesapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
for DOCX files
Step 2: Upload the File to the Signed URL
# Example Request
curl --location --request PUT '<preSignedUrl>' \
--header 'Content-Type: application/pdf' \
--upload-file '/path/to/your/example.pdf'
# Example Request
curl --location --request POST 'https://api.getmetal.io/v1/indexes/{id}/files' \
--header 'Content-Type: application/json' \
--header 'x-metal-api-key: <api-key>' \
--header 'x-metal-client-id: <client-id>' \
--data-raw '{
"fileName": "example.pdf",
"fileType": "application/pdf"
}'
{
"data": {
"id": "<generated-id>",
"status": "CREATED",
"createdAt": "2023-08-29T18:00:00.000Z",
"fileName": "example.pdf",
"fileType": "application/pdf",
"url": "<preSignedUrl>"
}
}