Upload a file
curl --request POST \
--url https://transform.unstructured.io/api/v2/upload \
--header 'Content-Type: multipart/form-data' \
--header 'unstructured-api-key: <api-key>' \
--form file='@example-file'import requests
url = "https://transform.unstructured.io/api/v2/upload"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {"unstructured-api-key": "<api-key>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {'unstructured-api-key': '<api-key>'}};
options.body = form;
fetch('https://transform.unstructured.io/api/v2/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://transform.unstructured.io/api/v2/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 => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"unstructured-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://transform.unstructured.io/api/v2/upload"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("unstructured-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://transform.unstructured.io/api/v2/upload")
.header("unstructured-api-key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://transform.unstructured.io/api/v2/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["unstructured-api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"file_id": "file_01HZX6J9Q4F3T4HY6F9W8D9K2R",
"mimetype": "application/pdf",
"expires_at": "2026-09-01T18:25:43Z"
}{
"code": "invalid_input",
"message": "Missing or invalid file."
}{
"code": "unauthorized",
"message": "Authentication required: send either an 'unstructured-api-key' header or 'Authorization: Bearer <token>'."
}{
"code": "file_too_large",
"message": "The file exceeds the maximum upload size."
}{
"code": "unsupported_file_type",
"message": "Check the file extension and try again."
}{
"code": "internal_error",
"message": "The file operation could not be completed. Retry the request."
}API endpoints
Upload a file
Upload a file for reuse in Parse or Extract requests. Review supported input, the returned file ID and media type, and the file expiry timestamp.
POST
/
api
/
v2
/
upload
Upload a file
curl --request POST \
--url https://transform.unstructured.io/api/v2/upload \
--header 'Content-Type: multipart/form-data' \
--header 'unstructured-api-key: <api-key>' \
--form file='@example-file'import requests
url = "https://transform.unstructured.io/api/v2/upload"
files = { "file": ("example-file", open("example-file", "rb")) }
headers = {"unstructured-api-key": "<api-key>"}
response = requests.post(url, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
const options = {method: 'POST', headers: {'unstructured-api-key': '<api-key>'}};
options.body = form;
fetch('https://transform.unstructured.io/api/v2/upload', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://transform.unstructured.io/api/v2/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 => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"unstructured-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://transform.unstructured.io/api/v2/upload"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("unstructured-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://transform.unstructured.io/api/v2/upload")
.header("unstructured-api-key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://transform.unstructured.io/api/v2/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["unstructured-api-key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"file_id": "file_01HZX6J9Q4F3T4HY6F9W8D9K2R",
"mimetype": "application/pdf",
"expires_at": "2026-09-01T18:25:43Z"
}{
"code": "invalid_input",
"message": "Missing or invalid file."
}{
"code": "unauthorized",
"message": "Authentication required: send either an 'unstructured-api-key' header or 'Authorization: Bearer <token>'."
}{
"code": "file_too_large",
"message": "The file exceeds the maximum upload size."
}{
"code": "unsupported_file_type",
"message": "Check the file extension and try again."
}{
"code": "internal_error",
"message": "The file operation could not be completed. Retry the request."
}Upload a file once and reuse its
file_id in Parse or Extract. The response returns file_id, mimetype, and expires_at.
Start with Parse your first document.Authorizations
ApiKeyAuthBearerAuth
Body
multipart/form-data
The document to upload.
Was this page helpful?

