Link Files to Agent
POST /api/agents/{agentId}/files
Link a file to be associated with a specific agent.
Code Examples
- cURL
- Node.js
- Python
- PHP
- Java
- Go
- .NET
- Ruby
curl --request POST \
--url 'https://tess.pareto.io/api/agents/{agentId}/files' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: multipart/form-data' \
-H 'Content-Type: application/json' \
-d '{
"file_ids": [
fileId1,fileId2
]
}'
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'));
const config = {
method: 'post',
url: 'https://tess.pareto.io/api/agents/{agentId}/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/agents/{agentId}/files"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
files = {
'file': open('/path/to/file', 'rb')
}
response = requests.post(url, headers=headers, files=files)
print(response.json())
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://tess.pareto.io/api/agents/{agentId}/files",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: multipart/form-data"
],
CURLOPT_POSTFIELDS => [
'file' => new CURLFILE('/path/to/file')
]
]);
$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.Files;
File file = new File("/path/to/file");
String boundary = "---boundary" + System.currentTimeMillis();
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tess.pareto.io/api/agents/{agentId}/files"))
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(Files.readAllBytes(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", file.Name())
if err != nil {
fmt.Println(err)
return
}
_, err = io.Copy(part, file)
if err != nil {
fmt.Println(err)
return
}
writer.Close()
client := &http.Client{}
req, err := http.NewRequest("POST", "https://tess.pareto.io/api/agents/{agentId}/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())
using (var formData = new MultipartFormDataContent())
{
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
var fileContent = new ByteArrayContent(System.IO.File.ReadAllBytes("/path/to/file"));
formData.Add(fileContent, "file", "filename");
try
{
var response = await client.PostAsync("https://tess.pareto.io/api/agents/{agentId}/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/agents/{agentId}/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')]]
request.set_form form_data, 'multipart/form-data'
response = http.request(request)
puts response.read_body
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
agentId | string | Yes | The ID of the agent |
Body Parameters
Parameter | Type | Required | Description |
---|---|---|---|
file_ids | array | Yes | The files ids to link to the agent |
Response
{
"id": 8794,
"files_count": {
"total": 1,
"completed": 1,
"failed": 0,
"in_progress": 0
},
"files": [
{
"id": 73336,
"object": "file",
"bytes": 35504128,
"created_at": "2025-01-05T22:39:57+00:00",
"filename": "endpoints.pdf",
"credits": 20.10060847168,
"status": "completed"
}
],
"status": "completed"
}
Try it out!
Authentication
This endpoint requires Bearer token authentication.