Initiate upload
curl --request POST \
--url https://files.adclear.ai/v1/uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fileName": "<string>",
"fileSize": 123,
"contentType": "<string>"
}
'import requests
url = "https://files.adclear.ai/v1/uploads"
payload = {
"fileName": "<string>",
"fileSize": 123,
"contentType": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({fileName: '<string>', fileSize: 123, contentType: '<string>'})
};
fetch('https://files.adclear.ai/v1/uploads', 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://files.adclear.ai/v1/uploads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileName' => '<string>',
'fileSize' => 123,
'contentType' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://files.adclear.ai/v1/uploads"
payload := strings.NewReader("{\n \"fileName\": \"<string>\",\n \"fileSize\": 123,\n \"contentType\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://files.adclear.ai/v1/uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileName\": \"<string>\",\n \"fileSize\": 123,\n \"contentType\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://files.adclear.ai/v1/uploads")
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/json'
request.body = "{\n \"fileName\": \"<string>\",\n \"fileSize\": 123,\n \"contentType\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"uploadId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"uploadUrl": "<string>",
"maxChunkSize": 123,
"correlationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Missing or malformed Content-Range header. Expected: bytes <start>-<end>/<total|*>",
"details": [
{
"type": "field_error",
"field": "fileName",
"message": "Required"
}
]
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid Bearer token"
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "PAYLOAD_TOO_LARGE",
"message": "File size 104857600 exceeds limit of 31457280 bytes for pdf files",
"details": [
{
"type": "constraint_violation",
"constraint": "max_file_size",
"limit": 31457280,
"actual": 104857600
}
]
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests",
"details": [
{
"type": "retry_info",
"retryAfterSeconds": 30
}
]
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "INTERNAL_ERROR",
"message": "Internal server error"
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "SERVICE_ERROR",
"message": "Storage returned unexpected status 503"
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}Upload
Initiate upload
Creates a GCS resumable upload session behind our domain. The caller PUTs file chunks to the returned uploadUrl with Content-Range headers.
POST
/
v1
/
uploads
Initiate upload
curl --request POST \
--url https://files.adclear.ai/v1/uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"fileName": "<string>",
"fileSize": 123,
"contentType": "<string>"
}
'import requests
url = "https://files.adclear.ai/v1/uploads"
payload = {
"fileName": "<string>",
"fileSize": 123,
"contentType": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({fileName: '<string>', fileSize: 123, contentType: '<string>'})
};
fetch('https://files.adclear.ai/v1/uploads', 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://files.adclear.ai/v1/uploads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'fileName' => '<string>',
'fileSize' => 123,
'contentType' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://files.adclear.ai/v1/uploads"
payload := strings.NewReader("{\n \"fileName\": \"<string>\",\n \"fileSize\": 123,\n \"contentType\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://files.adclear.ai/v1/uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"fileName\": \"<string>\",\n \"fileSize\": 123,\n \"contentType\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://files.adclear.ai/v1/uploads")
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/json'
request.body = "{\n \"fileName\": \"<string>\",\n \"fileSize\": 123,\n \"contentType\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"uploadId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"uploadUrl": "<string>",
"maxChunkSize": 123,
"correlationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Missing or malformed Content-Range header. Expected: bytes <start>-<end>/<total|*>",
"details": [
{
"type": "field_error",
"field": "fileName",
"message": "Required"
}
]
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing or invalid Bearer token"
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "PAYLOAD_TOO_LARGE",
"message": "File size 104857600 exceeds limit of 31457280 bytes for pdf files",
"details": [
{
"type": "constraint_violation",
"constraint": "max_file_size",
"limit": 31457280,
"actual": 104857600
}
]
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "RATE_LIMITED",
"message": "Too many requests",
"details": [
{
"type": "retry_info",
"retryAfterSeconds": 30
}
]
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "INTERNAL_ERROR",
"message": "Internal server error"
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}{
"error": {
"code": "SERVICE_ERROR",
"message": "Storage returned unexpected status 503"
},
"correlationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}Headers
Workspace ID fallback. Required when authenticating with a Bearer token in environments where cookies cannot be shared (e.g. preview). Not needed for API key auth (workspace is embedded in the key metadata) or when the workspace cookie is present.
Example:
"43dc2a1c-3384-41b5-a6e9-3b2d607d0fae"
Body
application/json
Response
Upload initiated — use uploadUrl to PUT file chunks
Was this page helpful?