Skip to main content
POST
/
apps
/
{app_id}
/
files
/
uploads
Create a new file upload
curl --request POST \
  --url https://api.example.com/apps/{app_id}/files/uploads \
  --header 'Content-Type: application/json' \
  --data '
{
  "allowed_types": [
    "*/*"
  ],
  "region": "european-union",
  "bucket": "cortex-eu",
  "document_extract_contents": true,
  "document_extract_images": true,
  "document_pages": [
    1,
    2,
    3
  ],
  "expires_in_seconds": 3600,
  "visibility": "PRIVATE",
  "storage": "PERSISTENT",
  "metadata": {}
}
'
import requests

url = "https://api.example.com/apps/{app_id}/files/uploads"

payload = {
"allowed_types": ["*/*"],
"region": "european-union",
"bucket": "cortex-eu",
"document_extract_contents": True,
"document_extract_images": True,
"document_pages": [1, 2, 3],
"expires_in_seconds": 3600,
"visibility": "PRIVATE",
"storage": "PERSISTENT",
"metadata": {}
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
allowed_types: ['*/*'],
region: 'european-union',
bucket: 'cortex-eu',
document_extract_contents: true,
document_extract_images: true,
document_pages: [1, 2, 3],
expires_in_seconds: 3600,
visibility: 'PRIVATE',
storage: 'PERSISTENT',
metadata: {}
})
};

fetch('https://api.example.com/apps/{app_id}/files/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://api.example.com/apps/{app_id}/files/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([
'allowed_types' => [
'*/*'
],
'region' => 'european-union',
'bucket' => 'cortex-eu',
'document_extract_contents' => true,
'document_extract_images' => true,
'document_pages' => [
1,
2,
3
],
'expires_in_seconds' => 3600,
'visibility' => 'PRIVATE',
'storage' => 'PERSISTENT',
'metadata' => [

]
]),
CURLOPT_HTTPHEADER => [
"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://api.example.com/apps/{app_id}/files/uploads"

payload := strings.NewReader("{\n \"allowed_types\": [\n \"*/*\"\n ],\n \"region\": \"european-union\",\n \"bucket\": \"cortex-eu\",\n \"document_extract_contents\": true,\n \"document_extract_images\": true,\n \"document_pages\": [\n 1,\n 2,\n 3\n ],\n \"expires_in_seconds\": 3600,\n \"visibility\": \"PRIVATE\",\n \"storage\": \"PERSISTENT\",\n \"metadata\": {}\n}")

req, _ := http.NewRequest("POST", url, payload)

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://api.example.com/apps/{app_id}/files/uploads")
.header("Content-Type", "application/json")
.body("{\n \"allowed_types\": [\n \"*/*\"\n ],\n \"region\": \"european-union\",\n \"bucket\": \"cortex-eu\",\n \"document_extract_contents\": true,\n \"document_extract_images\": true,\n \"document_pages\": [\n 1,\n 2,\n 3\n ],\n \"expires_in_seconds\": 3600,\n \"visibility\": \"PRIVATE\",\n \"storage\": \"PERSISTENT\",\n \"metadata\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/apps/{app_id}/files/uploads")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"allowed_types\": [\n \"*/*\"\n ],\n \"region\": \"european-union\",\n \"bucket\": \"cortex-eu\",\n \"document_extract_contents\": true,\n \"document_extract_images\": true,\n \"document_pages\": [\n 1,\n 2,\n 3\n ],\n \"expires_in_seconds\": 3600,\n \"visibility\": \"PRIVATE\",\n \"storage\": \"PERSISTENT\",\n \"metadata\": {}\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "future_file_id": "<string>",
  "file": {
    "id": "<string>",
    "file_id": "<string>",
    "file_filename": "document.pdf",
    "file_size": 1024,
    "file_mimetype": "application/pdf",
    "file_url": "<string>",
    "created_at": "2023-12-25",
    "file_format": "DOCUMENT",
    "file_status": "PROCESSED",
    "file_status_message": "<string>",
    "document": {
      "filename": "<string>",
      "filetype": "<string>",
      "contents": [
        {
          "id": 123,
          "content": "<string>",
          "page": 123,
          "content_as_html": "<string>",
          "parent": 123
        }
      ],
      "images": [
        {
          "id": "<string>",
          "file_id": "<string>",
          "image_url": "<string>",
          "type": "<string>",
          "page": 123,
          "height": 123,
          "width": 123
        }
      ],
      "extracted_pages": "<string>",
      "time": 123
    },
    "document_extract_contents": true,
    "document_extract_images": true,
    "document_extract_pages": true,
    "document_pages": [
      1,
      2,
      3
    ],
    "document_progress": 123,
    "storage": "PERSISTENT"
  },
  "upload_url": "<string>",
  "expires_at": "2023-12-25",
  "document_pages": [
    1,
    2,
    3
  ],
  "storage": "PERSISTENT",
  "visibility": "PRIVATE",
  "created_at": "2023-12-25",
  "updated_at": "2023-12-25",
  "region": "european-union",
  "bucket": "cortex-eu",
  "metadata": {},
  "allowed_types": [
    "*/*"
  ],
  "document_extract_contents": true,
  "document_extract_images": true
}

Path Parameters

app_id
string
required

The ID of the app

Body

Request body for creating a new file upload

Create a new file upload

allowed_types
string[] | null

The allowed mime types for the file field (e.g. image/*, application/pdf)

Maximum array length: 255
Maximum string length: 255
region
enum<string>

Region on R2/Cloudflare where the file will be stored

Available options:
auto,
north-america,
european-union
Example:

"european-union"

bucket
enum<string>

Storage bucket where the file will be stored

Available options:
dev-cortex,
cortex,
cortex-eu,
cortex-dev-eu,
devbucket
Example:

"cortex-eu"

document_extract_contents
boolean

Whether to extract contents from the document. If true, the file will be processed and contents extracted.

document_extract_images
boolean

Whether to extract images from the document. If true, images will be extracted.

document_pages
number[]

Array of page numbers to extract from the document

Maximum array length: 1024
Example:
[1, 2, 3]
expires_in_seconds
number

Timestamp when the uploaded file will expire. By default, it is set to 30 days

Required range: 1 <= x <= 315360000
Example:

3600

visibility
enum<string>

Whether the file is private or public, private files URLs are signed with a token and can be accessed temporarily

Available options:
PUBLIC,
PRIVATE
Example:

"PRIVATE"

storage
enum<string>
default:PERSISTENT

Whether the file is stored permanently or temporarily, indicating the storage type

Available options:
PERSISTENT,
TEMPORARY
Example:

"PERSISTENT"

metadata
object | null

Custom metadata for the uploaded file as key-value pairs (Max 2KB)

Response

200 - application/json

Uploaded file information

id
string
required

Unique identifier for the uploaded file

future_file_id
string
required

Future file ID for the uploaded file

file
object | null
required

The file associated with the upload, if available

upload_url
string
required

URL to upload the file

expires_at
string<date> | null
required

Timestamp when the uploaded file will expire

document_pages
number[] | null
required

Array of page numbers to extract from the document

Maximum array length: 1024
Example:
[1, 2, 3]
storage
enum<string>
default:PERSISTENT
required

Whether the file is stored permanently or temporarily, indicating the storage type

Available options:
PERSISTENT,
TEMPORARY
Example:

"PERSISTENT"

visibility
enum<string>
required

Whether the file is private or public, private files URLs are signed with a token and can be accessed temporarily

Available options:
PUBLIC,
PRIVATE
Example:

"PRIVATE"

created_at
string<date> | null
required

Timestamp when the uploaded file was created

updated_at
string<date> | null
required

Timestamp when the uploaded file was last updated

region
string

Region on R2/Cloudflare

Example:

"european-union"

bucket
string

Storage bucket for the file

Example:

"cortex-eu"

metadata
object | null

Custom metadata for the uploaded file as key-value pairs (Max 2KB)

allowed_types
string[] | null

The allowed mime types for the file field (e.g. image/*, application/pdf)

Maximum array length: 255
Maximum string length: 255
document_extract_contents
boolean

Whether to extract contents from the document. If true, the file will be processed and contents extracted.

document_extract_images
boolean

Whether to extract images from the document. If true, images will be extracted.