Skip to main content

File Upload API

Upload a file to the project.

Endpoint

POST /upload

Headers

HeaderRequiredDescription
AuthorizationYesBearer token for authentication
project_idYesProject identifier

Request Body

Multipart form data with a file field.

Response

{
"file_id": "string"
}

Examples

cURL

curl -X POST 'https://api.example.com/upload' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'project_id: YOUR_PROJECT_ID' \
-F 'file=@/path/to/your/file.pdf'

Python

import requests

url = 'https://api.example.com/upload'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'project_id': 'YOUR_PROJECT_ID'
}

with open('/path/to/your/file.pdf', 'rb') as f:
files = {'file': f}
response = requests.post(url, headers=headers, files=files)

print(response.json())

Node.js

const FormData = require("form-data");
const fs = require("fs");
const axios = require("axios");

async function uploadFile() {
const form = new FormData();
form.append("file", fs.createReadStream("/path/to/your/file.pdf"));

try {
const response = await axios.post("https://api.example.com/upload", form, {
headers: {
...form.getHeaders(),
Authorization: "Bearer YOUR_API_KEY",
project_id: "YOUR_PROJECT_ID",
},
});
console.log(response.data);
} catch (error) {
console.error("Error:", error);
}
}

uploadFile();

Error Responses

Status CodeDescription
400Bad Request - Missing or invalid parameters
500Internal Server Error