Skip to content
Last updated

Register a completed file upload after using the resumable upload flow.

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

Register a completed file upload after uploading directly to cloud storage via the resumable upload flow.

Path Parameters

organization_id string required

The unique identifier of the organization.

Request Body

filename string required

Original filename of the uploaded file.

gcs_path string required

The storage path returned by the Generate Upload URL endpoint.

file_size integer required

File size in bytes.

mime_type string required

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


Returns

Returns a File object with complete metadata. The file is now ready to be used in vector stores or AI conversations.

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

Complete Resumable Upload Flow

import os
import requests

api_key = os.environ["FREDDY_API_KEY"]
org_id = "org_123"
file_path = "/path/to/large_video.mp4"

# Step 1: Generate upload URL
upload_url_endpoint = f"https://api.aitronos.com/v1/organizations/{org_id}/files/upload-url"
headers = {"X-API-Key": api_key}

with open(file_path, 'rb') as f:
    file_size = len(f.read())

upload_url_data = {
    "filename": "large_video.mp4",
    "file_size": file_size,
    "mime_type": "video/mp4"
}

response = requests.post(upload_url_endpoint, headers=headers, json=upload_url_data)
session = response.json()

# Step 2: Upload file to GCS
with open(file_path, 'rb') as f:
    upload_headers = {'Content-Type': 'video/mp4'}
    requests.put(session['upload_url'], headers=upload_headers, data=f)

# Step 3: Register the completed upload
register_endpoint = f"https://api.aitronos.com/v1/organizations/{org_id}/files"
register_data = {
    "filename": "large_video.mp4",
    "gcs_path": session['gcs_path'],
    "file_size": file_size,
    "mime_type": "video/mp4"
}

response = requests.post(register_endpoint, headers=headers, json=register_data)
file_obj = response.json()
print(f"Upload complete! File ID: {file_obj['id']}")

Upload Process

  1. Call generate upload URL to get an upload session
  2. Upload file to the returned URL using resumable upload protocol
  3. Call this endpoint to validate and register the completed upload