curl --request POST \
--url https://api-prod.extend.app/files/upload \
--header 'Authorization: Bearer <token>' \
--form 'file=@/path/to/document.pdf'
import requests
url = "https://api-prod.extend.app/files/upload"
headers = {"Authorization": "Bearer <token>"}
with open("document.pdf", "rb") as f:
response = requests.post(
url,
files={"file": f},
headers=headers
)
print(response.text)
const formData = new FormData();
formData.append("file", file);
const options = {
method: 'POST',
headers: {'Authorization": 'Bearer <token>'},
body: formData
};
fetch("https://api-prod.extend.app/files/upload", options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-prod.extend.app/files/upload",
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" => new CURLFile("/path/to/document.pdf")
],
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, _ := os.Open("document.pdf")
defer file.Close()
var requestBody bytes.Buffer
writer := multipart.NewWriter(&requestBody)
part, _ := writer.CreateFormFile("file", "document.pdf")
io.Copy(part, file)
writer.Close()
url := "https://api-prod.extend.app/files/upload"
req, _ := http.NewRequest("POST", url, &requestBody)
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", writer.FormDataContentType())
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api-prod.extend.app/files/upload")
.header("Authorization", "Bearer <token>")
.field("file", new File("document.pdf"))
.asString();
{
"object": "file",
"id": "file_1234",
"name": "example_file",
"type": "PDF",
"presignedUrl": "https://s3.example.com/file_1234.pdf",
"parentFileId": "file_5678", // Optional, only set if this file is a derivative of another file
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
File Endpoints
Upload File
Upload and create a new file in Extend.
curl --request POST \
--url https://api-prod.extend.app/files/upload \
--header 'Authorization: Bearer <token>' \
--form 'file=@/path/to/document.pdf'
import requests
url = "https://api-prod.extend.app/files/upload"
headers = {"Authorization": "Bearer <token>"}
with open("document.pdf", "rb") as f:
response = requests.post(
url,
files={"file": f},
headers=headers
)
print(response.text)
const formData = new FormData();
formData.append("file", file);
const options = {
method: 'POST',
headers: {'Authorization": 'Bearer <token>'},
body: formData
};
fetch("https://api-prod.extend.app/files/upload", options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-prod.extend.app/files/upload",
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" => new CURLFile("/path/to/document.pdf")
],
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, _ := os.Open("document.pdf")
defer file.Close()
var requestBody bytes.Buffer
writer := multipart.NewWriter(&requestBody)
part, _ := writer.CreateFormFile("file", "document.pdf")
io.Copy(part, file)
writer.Close()
url := "https://api-prod.extend.app/files/upload"
req, _ := http.NewRequest("POST", url, &requestBody)
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", writer.FormDataContentType())
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api-prod.extend.app/files/upload")
.header("Authorization", "Bearer <token>")
.field("file", new File("document.pdf"))
.asString();
{
"object": "file",
"id": "file_1234",
"name": "example_file",
"type": "PDF",
"presignedUrl": "https://s3.example.com/file_1234.pdf",
"parentFileId": "file_5678", // Optional, only set if this file is a derivative of another file
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}
This endpoint accepts file contents and registers them as a File in Extend, which can be used for running workflows, creating evaluation sets, parsing, etc.
If an uploaded file is detected as a Word or PowerPoint document, it will be automatically converted to a PDF.
Supported file types can be found here.
This endpoint requires multipart form encoding. Most HTTP clients will handle this encoding automatically (see the examples).
Headers
string
A
multi-part/form-data header containing the boundary, such as
multi-part/form-data; boundary="...".Body
Amultipart/form-data body containing a single file field and its binary data. For more information, see the MDN documenation.
The Content-Type field header is currently ignored and Extend will infer the type automatically based on the field’s Content-Disposition and the file’s contents.
Response
boolean
A true or false value for whether the file was processed successfully or not.
File
A File object representing the newly created file. See the File
object for more details.
Note: Since the file is not parsed, it will not contain
contents nor metadata.curl --request POST \
--url https://api-prod.extend.app/files/upload \
--header 'Authorization: Bearer <token>' \
--form 'file=@/path/to/document.pdf'
import requests
url = "https://api-prod.extend.app/files/upload"
headers = {"Authorization": "Bearer <token>"}
with open("document.pdf", "rb") as f:
response = requests.post(
url,
files={"file": f},
headers=headers
)
print(response.text)
const formData = new FormData();
formData.append("file", file);
const options = {
method: 'POST',
headers: {'Authorization": 'Bearer <token>'},
body: formData
};
fetch("https://api-prod.extend.app/files/upload", options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-prod.extend.app/files/upload",
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" => new CURLFile("/path/to/document.pdf")
],
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
)
func main() {
file, _ := os.Open("document.pdf")
defer file.Close()
var requestBody bytes.Buffer
writer := multipart.NewWriter(&requestBody)
part, _ := writer.CreateFormFile("file", "document.pdf")
io.Copy(part, file)
writer.Close()
url := "https://api-prod.extend.app/files/upload"
req, _ := http.NewRequest("POST", url, &requestBody)
req.Header.Set("Authorization", "Bearer <token>")
req.Header.Set("Content-Type", writer.FormDataContentType())
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://api-prod.extend.app/files/upload")
.header("Authorization", "Bearer <token>")
.field("file", new File("document.pdf"))
.asString();
{
"object": "file",
"id": "file_1234",
"name": "example_file",
"type": "PDF",
"presignedUrl": "https://s3.example.com/file_1234.pdf",
"parentFileId": "file_5678", // Optional, only set if this file is a derivative of another file
"createdAt": "2024-01-01T00:00:00Z",
"updatedAt": "2024-01-01T00:00:00Z"
}

