Upload a file
curl --request POST \
--url https://api.example.com/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/octet-stream' \
--data '<string>'import requests
url = "https://api.example.com/v1/files"
payload = "<string>"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/octet-stream"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/octet-stream'},
body: '<string>'
};
fetch('https://api.example.com/v1/files', 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://api.example.com/v1/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 => "<string>",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/octet-stream"
],
]);
$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://api.example.com/v1/files"
payload := strings.NewReader("<string>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/octet-stream")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/octet-stream")
.body("<string>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/octet-stream'
request.body = "<string>"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "file",
"filename": "<string>",
"content_type": "<string>",
"size": 4503599627370495,
"sha256": "<string>",
"origin": {
"type": "upload"
},
"created_at": "<string>",
"mime_type": "<string>",
"size_bytes": 4503599627370495
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "authentication_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "not_found_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "conflict_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "payload_too_large",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "unsupported_media_type",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "internal_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "service_unavailable",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}Upload a file
Upload one file as a raw body (up to 100 MiB) or as the file part of multipart/form-data (up to 16 MiB). A raw upload requires filename and Content-Length. An uploaded file is immutable.
POST
/
v1
/
files
Upload a file
curl --request POST \
--url https://api.example.com/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/octet-stream' \
--data '<string>'import requests
url = "https://api.example.com/v1/files"
payload = "<string>"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/octet-stream"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/octet-stream'},
body: '<string>'
};
fetch('https://api.example.com/v1/files', 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://api.example.com/v1/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 => "<string>",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/octet-stream"
],
]);
$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://api.example.com/v1/files"
payload := strings.NewReader("<string>")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/octet-stream")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/v1/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/octet-stream")
.body("<string>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/octet-stream'
request.body = "<string>"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"type": "file",
"filename": "<string>",
"content_type": "<string>",
"size": 4503599627370495,
"sha256": "<string>",
"origin": {
"type": "upload"
},
"created_at": "<string>",
"mime_type": "<string>",
"size_bytes": 4503599627370495
}{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "authentication_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "not_found_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "conflict_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "payload_too_large",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "unsupported_media_type",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "internal_error",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}{
"type": "error",
"error": {
"type": "service_unavailable",
"message": "<string>",
"code": "session_awaiting_action"
},
"request_id": "<string>",
"accepted": "<array>",
"failed_index": 123,
"unconfirmed_index": 123
}Headers
Query Parameters
Required for raw uploads. A single name, such as report.pdf.
Required string length:
1 - 255Pattern:
^(?:[^./\\\u0000-\u001f\u007f-\u009f\u2028\u2029][^/\\\u0000-\u001f\u007f-\u009f\u2028\u2029]*|\.[^./\\\u0000-\u001f\u007f-\u009f\u2028\u2029][^/\\\u0000-\u001f\u007f-\u009f\u2028\u2029]*|\.\.[^/\\\u0000-\u001f\u007f-\u009f\u2028\u2029]+)$Body
application/octet-streammultipart/form-data
The body is of type file.
Response
Success
Required string length:
1 - 255Pattern:
^(?:[^./\\\u0000-\u001f\u007f-\u009f\u2028\u2029][^/\\\u0000-\u001f\u007f-\u009f\u2028\u2029]*|\.[^./\\\u0000-\u001f\u007f-\u009f\u2028\u2029][^/\\\u0000-\u001f\u007f-\u009f\u2028\u2029]*|\.\.[^/\\\u0000-\u001f\u007f-\u009f\u2028\u2029]+)$