Skip to content

Menu

  • Media
  • Pricing
  • Docs
  • Language: English

    This page isn’t available in the greyed-out languages.

    • English
    • Español
    • Português
    • Français
    • Deutsch
    • Italiano
    • Nederlands
    • Polski
    • 日本語
    • 한국어
    • Bahasa Indonesia
    • Tiếng Việt
    • Türkçe
    • العربية
    • ไทย
    • Български
    • Català
    • Hrvatski
    • Eesti
    • Magyar
    • Latviešu
    • Lietuvių
    • Srpski
    • Slovenčina
    • Slovenščina
    • Українська
    • Čeština
    • Română
    • Svenska
    • Dansk
    • Norsk bokmål
    • Suomi
    • עברית
    • हिन्दी
    • Tagalog
    • Bahasa Melayu
    • Ελληνικά
    • 简体中文
    • 繁體中文

Uploading files

Files go straight to storage: in one send up to 5 GB, or in parts. The API hands out the links, then checks the file before any job uses it.

On this page

How an upload works

  1. Start the upload with POST /v1/uploads: the operation the file is for, and the file’s name and size.
  2. Send the file with PUT to its link: in one request up to 5 GB, or in parts, each to its own link.
  3. Complete the upload with POST /v1/uploads/{id}/complete. The file is checked, and its ID is ready for a job.

A file up to 5 GB goes in one request. A larger file goes in parts, and so does any file you ask parts for: a dropped part is then sent again on its own, so an interrupted upload never starts over.

Start an upload

One call starts up to 50 uploads. The operation decides which types and sizes it takes, and each file is checked against them now, before anything is sent.

curl -X POST https://api.filesokay.com/v1/uploads \
  -H "Authorization: Bearer $FILESOKAY_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operation": "video.compress",
    "files": [
      {
        "name": "lecture.mp4",
        "size": 12417467,
        "type": "video/mp4"
      }
    ]
  }'
const res = await fetch("https://api.filesokay.com/v1/uploads", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    operation: "video.compress",
    files: [
      {
        name: "lecture.mp4",
        size: 12417467,
        type: "video/mp4"
      }
    ]
  }),
});
const uploads = await res.json();
import os
import uuid

import requests

res = requests.post(
    "https://api.filesokay.com/v1/uploads",
    headers={
        "Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
      "operation": "video.compress",
      "files": [
        {
          "name": "lecture.mp4",
          "size": 12417467,
          "type": "video/mp4"
        }
      ]
    },
)
uploads = res.json()
Response
{
  "files": [
    {
      "id": "file_3cf0737aefa34b89b7b4443c9467d60c",
      "name": "lecture.mp4",
      "size": 12417467,
      "part_size": 12417467,
      "part_count": 1,
      "parts": [
        {
          "number": 1,
          "url": "https://…"
        }
      ],
      "links_expire_at": "2026-12-03T10:22:53Z",
      "delete_at": "2026-12-10T09:22:52Z"
    }
  ]
}
  • A file up to 5 GB comes with one link for the whole file: part_count is 1 and part_size is the file’s size. Send "multipart": true to get parts instead, for a file of any size.
  • In parts, part_size is the size of every part except the last: at least 16 MiB, and large enough that the file fits in 10,000 parts.
  • parts holds the links for the first 20 parts. Each link works for one hour, until links_expire_at.
  • delete_at is when the upload is deleted if it isn’t completed: 7 days after it starts.

A file that can’t be added is refused with file_too_large, unsupported_type or empty_file. The error’s files lists each file with a problem by its position in your request.

Send the parts

With one link, send the whole file to it in one PUT. In parts, send part 1 as the file’s first part_size bytes, part 2 as the next, and so on. Parts can go in any order, and several at once. Send them without your API key: each link carries its own permission.

A file with more than 20 parts needs more links. Ask for up to 100 at a time with POST /v1/uploads/{id}/parts, and ask again the same way when links expire. This function uploads a file of any size, in parts:

# Split the file into parts of part_size bytes (16777216 here): part-aa, part-ab, …
split -b 16777216 keynote.mp4 part-

# Send each part to its own link, in order: part-aa to part 1, part-ab to part 2, …
curl -X PUT --upload-file part-aa "$PART_1_URL"
curl -X PUT --upload-file part-ab "$PART_2_URL"

# Past the first 20 links, ask for the next ones, up to 100 at a time.
curl https://api.filesokay.com/v1/uploads/file_20f80f7404ff41858dc0a0544f059576/parts \
  -H "Authorization: Bearer $FILESOKAY_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "part_numbers": [21, 22, 23] }'
import fs from "node:fs/promises";
import path from "node:path";

const API = "https://api.filesokay.com/v1";

async function post(route, body) {
  const res = await fetch(API + route, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
      "Content-Type": "application/json",
    },
    body: body && JSON.stringify(body),
  });
  const data = await res.json();
  if (!res.ok) throw new Error(`${data.code}: ${data.detail}`);
  return data;
}

// Uploads a file of any size for an operation, and returns it with its check.
async function uploadFile(filePath, operation) {
  const handle = await fs.open(filePath);
  try {
    const { size } = await handle.stat();
    const { files: [upload] } = await post("/uploads", {
      operation,
      files: [{ name: path.basename(filePath), size }],
      multipart: true,
    });

    // Links work for an hour: past the last link, or after 50 minutes, ask for the next 100.
    let links = new Map(upload.parts.map((part) => [part.number, part.url]));
    let linksAt = Date.now();
    for (let number = 1; number <= upload.part_count; number++) {
      if (!links.has(number) || Date.now() - linksAt > 50 * 60 * 1000) {
        const last = Math.min(number + 99, upload.part_count);
        const part_numbers = Array.from({ length: last - number + 1 }, (_, i) => number + i);
        const more = await post(`/uploads/${upload.id}/parts`, { part_numbers });
        links = new Map(more.parts.map((part) => [part.number, part.url]));
        linksAt = Date.now();
      }
      const start = (number - 1) * upload.part_size;
      const bytes = Buffer.alloc(Math.min(upload.part_size, size - start));
      await handle.read(bytes, 0, bytes.length, start);
      const res = await fetch(links.get(number), { method: "PUT", body: bytes });
      if (!res.ok) throw new Error(`Part ${number} failed: ${res.status}`);
    }
    return await post(`/uploads/${upload.id}/complete`);
  } finally {
    await handle.close();
  }
}

const file = await uploadFile("lecture.mp4", "video.compress");
console.log(file.id, file.check.state);
import os
import time

import requests

API = "https://api.filesokay.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}"}


def post(route, body=None):
    res = requests.post(API + route, json=body, headers=HEADERS)
    data = res.json()
    if not res.ok:
        raise RuntimeError(f"{data['code']}: {data['detail']}")
    return data


def upload_file(file_path, operation):
    """Uploads a file of any size for an operation, and returns it with its check."""
    upload = post("/uploads", {
        "operation": operation,
        "files": [{"name": os.path.basename(file_path), "size": os.path.getsize(file_path)}],
        "multipart": True,
    })["files"][0]

    # Links work for an hour: past the last link, or after 50 minutes, ask for the next 100.
    links = {part["number"]: part["url"] for part in upload["parts"]}
    links_at = time.monotonic()
    with open(file_path, "rb") as f:
        for number in range(1, upload["part_count"] + 1):
            if number not in links or time.monotonic() - links_at > 50 * 60:
                last = min(number + 99, upload["part_count"])
                more = post(f"/uploads/{upload['id']}/parts",
                            {"part_numbers": list(range(number, last + 1))})
                links = {part["number"]: part["url"] for part in more["parts"]}
                links_at = time.monotonic()
            f.seek((number - 1) * upload["part_size"])
            requests.put(links[number], data=f.read(upload["part_size"])).raise_for_status()
    return post(f"/uploads/{upload['id']}/complete")


file = upload_file("lecture.mp4", "video.compress")
print(file["id"], file["check"]["state"])

Complete the upload

Completing joins the parts and checks the file’s content. Calling it again gives the same answer.

curl -X POST https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c/complete \
  -H "Authorization: Bearer $FILESOKAY_KEY"
const res = await fetch("https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c/complete", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
  },
});
const file = await res.json();
import os

import requests

res = requests.post(
    "https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c/complete",
    headers={
        "Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
    },
)
file = res.json()
Response
{
  "id": "file_3cf0737aefa34b89b7b4443c9467d60c",
  "name": "lecture.mp4",
  "operation": "video.compress",
  "state": "uploaded",
  "size": 12417467,
  "created_at": "2026-12-03T09:22:53Z",
  "uploaded_at": "2026-12-03T09:23:02Z",
  "delete_at": "2026-12-04T09:23:02Z",
  "check": {
    "state": "proceed",
    "kind": "video",
    "type": "mp4",
    "facts": {
      "container": "mp4",
      "protection": "none",
      "attachments": [],
      "duration_ms": 20023,
      "frame_count": 600,
      "audio_tracks": [
        {
          "codec": "aac",
          "channels": 1,
          "sample_rate": 44100
        }
      ],
      "video_tracks": [
        {
          "hdr": "none",
          "codec": "h264",
          "width": 1280,
          "chroma": "420",
          "height": 720,
          "profile": "High",
          "rotation": 0,
          "bit_depth": 8,
          "frame_rate": 30,
          "interlaced": false,
          "variable_frame_rate": false
        }
      ],
      "data_end_bytes": 12417467,
      "subtitle_tracks": []
    },
    "facts_complete": true
  }
}

The check says what the file really is, whatever its name says: its kind, its real format in type, and the facts it read, such as a video’s length and codecs. Its state is one of these:

StateMeaning
proceedA job can use the file.
refuseNo job can use it, for the reason given, such as a damaged or protected file.
couldnt_readThe check couldn’t read all of it. A job can still use it, and reads it in full.
check_failedA problem on our side. Complete the upload again to check it again.
checkingThe check hasn’t finished yet.

If a part is missing or has the wrong length, completing is refused with upload_incomplete, which lists the parts to send again.

Resume an interrupted upload

GET /v1/uploads/{id} lists the parts storage already has, in parts_received. Send only the missing ones, with fresh links if the first have expired, then complete the upload.

curl https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c \
  -H "Authorization: Bearer $FILESOKAY_KEY"
const res = await fetch("https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c", {
  headers: {
    Authorization: `Bearer ${process.env.FILESOKAY_KEY}`,
  },
});
const progress = await res.json();
import os

import requests

res = requests.get(
    "https://api.filesokay.com/v1/uploads/file_3cf0737aefa34b89b7b4443c9467d60c",
    headers={
        "Authorization": f"Bearer {os.environ['FILESOKAY_KEY']}",
    },
)
progress = res.json()
Response
{
  "delete_at": "2026-12-10T09:22:52Z",
  "id": "file_3cf0737aefa34b89b7b4443c9467d60c",
  "part_count": 1,
  "part_size": 12417467,
  "parts_received": [
    {
      "number": 1,
      "size": 12417467
    }
  ],
  "size": 12417467,
  "state": "uploading"
}

Once its delete_at has passed, the upload is deleted, and calls to it answer not_found: start it again. To stop an upload yourself, cancel it with DELETE /v1/uploads/{id}, which also discards the parts already sent.

How long an upload is kept

A completed upload that no job uses is deleted 24 hours after it completes, or 3 days after for a file of 10 GiB or more. Once a job uses it, the job’s rules apply: how long files are kept.