Skip to content
Last updated

Generate a resumable upload URL for large file uploads (advanced).

POSThttps://api.aitronos.com/v1/organizations/{organization_id}/files/upload-url

Generate a resumable upload session URI for uploading large files directly to cloud storage. This endpoint is designed for files larger than 100MB or when you need resumable upload capabilities (e.g., unreliable network connections). The returned upload URL is valid for 7 days.

For simpler uploads under 100MB, use the direct upload endpoint instead.

Path Parameters

organization_id string required

The unique identifier of the organization.

Request Body

filename string required

Original filename (1-255 characters).

file_size integer required

File size in bytes. Must be greater than 0.

mime_type string required

MIME type of the file (e.g., application/pdf, video/mp4).

upload_type string optional

Upload type: resumable or simple. Default: resumable.


Returns

Returns an upload session object containing:

  • upload_url - Resumable upload session URI for uploading the file
  • gcs_path - Destination path in cloud storage (use this when registering)
  • file_id - Pre-generated file ID
  • expires_at - Session expiry timestamp (7 days from now)
  • max_file_size - Maximum allowed file size (5GB)
  • upload_type - Upload type (always resumable)
  • chunk_size_recommended - Recommended chunk size for uploads (5MB)

After uploading your file to the upload_url, call the register file endpoint with the gcs_path to complete the process.

cURL
curl -X POST https://api.aitronos.com/v1/organizations/org_123/files/upload-url \
  -H "X-API-Key: $FREDDY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "large_video.mp4",
    "file_size": 524288000,
    "mime_type": "video/mp4"
  }'

Resumable Upload Example

After receiving the upload URL, upload your file using the resumable protocol:

import requests

# Step 1: Get upload URL (from above)
upload_url = upload_session['upload_url']
gcs_path = upload_session['gcs_path']
file_id = upload_session['file_id']

# Step 2: Upload file to GCS using resumable protocol
with open('/path/to/large_video.mp4', 'rb') as f:
    headers = {
        'Content-Type': 'video/mp4'
    }
    upload_response = requests.put(upload_url, headers=headers, data=f)

# Step 3: Register the completed upload (see Register File endpoint)
register_url = f"https://api.aitronos.com/v1/organizations/{org_id}/files"
register_data = {
    "filename": "large_video.mp4",
    "gcs_path": gcs_path,
    "file_size": 524288000,
    "mime_type": "video/mp4"
}
register_response = requests.post(
    register_url,
    headers={"X-API-Key": api_key},
    json=register_data
)
file_obj = register_response.json()
print(f"File registered: {file_obj['id']}")

Upload Process

  1. Call this endpoint to get an upload URL
  2. Upload file to the returned upload_url using resumable upload protocol
  3. Call register file endpoint with the gcs_path and file_id