Upload File
POST /api/files
Upload a new file to the system and optionally process it.
Code Examples
- cURL
- Node.js
- Python
- PHP
- Java
- Go
- .NET
- Ruby
curl --request POST \
--url 'https://tess.pareto.io/api/files' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@/path/to/file' \
--form 'process=false'
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('file', fs.createReadStream('/path/to/file'));
form.append('process', 'false');
const config = {
method: 'post',
url: 'https://tess.pareto.io/api/files',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
...form.getHeaders()
},
data: form
};
try {
const response = await axios(config);
console.log(response.data);
} catch (error) {
console.error(error);
}
import requests
url = "https://tess.pareto.io/api/files"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
files = {
'file': open('/path/to/file', 'rb')
}
data = {
'process': 'false'
}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.json())
<?php
$curl = curl_init();
$file = new CURLFile('/path/to/file');
curl_setopt_array($curl, [
CURLOPT_URL => "https://tess.pareto.io/api/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => [
'file' => $file,
'process' => 'false'
],
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: multipart/form-data"
]
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "Error: " . $err;
} else {
echo $response;
}
import java.io.File;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Path;
String boundary = "---boundary" + System.currentTimeMillis();
File file = new File("/path/to/file");
HttpClient client = HttpClient.newBuilder().build();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tess.pareto.io/api/files"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "multipart/form-data;boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofFile(file.toPath()))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, err := os.Open("/path/to/file")
if err != nil {
fmt.Println(err)
return
}
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile("file", "filename")
if err != nil {
fmt.Println(err)
return
}
io.Copy(part, file)
writer.WriteField("process", "false")
writer.Close()
client := &http.Client{}
req, err := http.NewRequest("POST", "https://tess.pareto.io/api/files", body)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
req.Header.Add("Content-Type", writer.FormDataContentType())
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(respBody))
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
using (var formData = new MultipartFormDataContent())
{
var fileContent = new ByteArrayContent(File.ReadAllBytes("/path/to/file"));
formData.Add(fileContent, "file", "filename");
formData.Add(new StringContent("false"), "process");
try
{
var response = await client.PostAsync("https://tess.pareto.io/api/files", formData);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
}
require 'uri'
require 'net/http'
require 'json'
uri = URI('https://tess.pareto.io/api/files')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
form_data = [
['file', File.open('/path/to/file')],
['process', 'false']
]
request.set_form form_data, 'multipart/form-data'
response = http.request(request)
puts response.read_body
Headers
Parameter | Type | Required | Description |
---|---|---|---|
x-workspace-id | integer | No | ID of the workspace. If not provided, the user's selected workspace will be used. |
Request Body
Parameter | Type | Required | Description |
---|---|---|---|
file | binary | Yes | The file to upload |
process | boolean | No | Whether to process the file after upload (default: false). The file processing consume credits (true). |
Response
{
"id": 73325,
"object": "file",
"bytes": 35504128,
"created_at": "2025-01-05T22:26:27+00:00",
"filename": "endpoints.pdf",
"credits": 0,
"status": "waiting"
}
Try it out!
Authentication
This endpoint requires Bearer token authentication.