Skip to main content
POST
/
api
/
v1
/
files
/
upload
Request Upload Url
import requests

url = "https://www.datalab.to/api/v1/files/upload"

payload = {
    "filename": "<string>",
    "content_type": "<string>"
}
headers = {
    "X-API-Key": "<api-key>",
    "Content-Type": "application/json"
}

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

print(response.text)
{
  "file_id": 123,
  "upload_url": "<string>",
  "reference": "<string>",
  "expires_in": 3600
}

Authorizations

X-API-Key
string
header
required

Cookies

wos-session
string
access_token
string
datalab_active_team
string

Body

application/json

Request to get a presigned upload URL.

filename
string
required

Original filename (used for R2 path and metadata)

content_type
string
required

MIME type of the file

Response

Successful Response

Response with presigned PUT URL for direct R2 upload.

file_id
integer
required

Unique file ID (use this to confirm upload)

upload_url
string
required

Presigned PUT URL to upload the file to

reference
string
required

File reference in datalab://file-{id} format

expires_in
integer
default:3600

URL expiry time in seconds