Uploads and ZIP import

View as Markdown

This page explains how to upload a large file, such as a long video or a project ZIP, and use it in an edit, a render or a ZIP import. For a whole project, see As a new project.

An upload is a file you send to Blitframe on its own, before the request that uses it.

Not every file needs an upload. How to send a file depends on what it is and how large it is:

What you send How to send it
Text, such as data.json Inside the edit, as content. No upload needed.
A binary file of up to 1 MB An upload, or inside the edit as contentBase64.
A file of up to 100 MB An upload with one PUT.
A larger file: up to 8 GB for a ZIP, or the file type's limit An upload in parts.

A file other than a ZIP can't be larger than your plan's project size.

A new file for a replacement in a render always needs an upload.

The examples need your API key. See Get an API key. Run the steps in order, in one shell or one file.

1. Create an upload

Creating an upload tells Blitframe the name and size of the file that is coming. Send POST /v1/uploads with both. The examples upload a video named background.mp4 from the current folder.

SIZE_BYTES=$(wc -c < background.mp4 | tr -d ' ')
UPLOAD=$(curl -s -X POST $BLITFRAME/uploads \
  -H "Authorization: Bearer $BLITFRAME_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"fileName":"background.mp4","sizeBytes":'$SIZE_BYTES'}')
UPLOAD_ID=$(echo "$UPLOAD" | jq -r .id)
UPLOAD_URL=$(echo "$UPLOAD" | jq -r .url)
import os, requests

api = os.environ["BLITFRAME"]
headers = {"Authorization": f"Bearer {os.environ['BLITFRAME_API_KEY']}"}

size_bytes = os.path.getsize("background.mp4")
response = requests.post(f"{api}/uploads", headers=headers,
                         json={"fileName": "background.mp4", "sizeBytes": size_bytes})
upload = response.json()
upload_id = upload["id"]
upload_url = upload["url"]
const { readFile, stat } = require("node:fs/promises");

const fileInfo = await stat("background.mp4");
const response = await fetch(`${process.env.BLITFRAME}/uploads`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BLITFRAME_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ fileName: "background.mp4", sizeBytes: fileInfo.size }),
});
const upload = await response.json();
const uploadId = upload.id;
const uploadUrl = upload.url;
import { readFile, stat } from "node:fs/promises";

const fileInfo = await stat("background.mp4");
const response = await fetch(`${process.env.BLITFRAME}/uploads`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BLITFRAME_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ fileName: "background.mp4", sizeBytes: fileInfo.size }),
});
const upload = await response.json();
const uploadId = upload.id;
const uploadUrl = upload.url;
<?php
$api = getenv("BLITFRAME");
$authorization = "Authorization: Bearer " . getenv("BLITFRAME_API_KEY");

$ch = curl_init("$api/uploads");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [$authorization, "Content-Type: application/json"],
    CURLOPT_POSTFIELDS => json_encode(["fileName" => "background.mp4", "sizeBytes" => filesize("background.mp4")]),
]);
$response = curl_exec($ch);
$upload = json_decode($response, true);
$uploadId = $upload["id"];
$uploadUrl = $upload["url"];
require "net/http"
require "json"

api = ENV["BLITFRAME"]
authorization = "Bearer #{ENV["BLITFRAME_API_KEY"]}"

uri = URI("#{api}/uploads")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = authorization
request["Content-Type"] = "application/json"
request.body = { fileName: "background.mp4", sizeBytes: File.size("background.mp4") }.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
upload = JSON.parse(response.body)
upload_id = upload["id"]
upload_url = upload["url"]
package main

import (
	"bytes"
	"encoding/json"
	"net/http"
	"os"
)

func main() {
	api := os.Getenv("BLITFRAME")
	authorization := "Bearer " + os.Getenv("BLITFRAME_API_KEY")
	client := &http.Client{}

	file, err := os.Open("background.mp4")
	if err != nil {
		panic(err)
	}
	info, err := file.Stat()
	if err != nil {
		panic(err)
	}
	uploadBody, err := json.Marshal(map[string]any{"fileName": "background.mp4", "sizeBytes": info.Size()})
	if err != nil {
		panic(err)
	}
	request, err := http.NewRequest("POST", api+"/uploads", bytes.NewReader(uploadBody))
	if err != nil {
		panic(err)
	}
	request.Header.Set("Authorization", authorization)
	request.Header.Set("Content-Type", "application/json")
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()
	var upload map[string]any
	if err := json.NewDecoder(response.Body).Decode(&upload); err != nil {
		panic(err)
	}
	uploadID := upload["id"].(string)
	uploadURL, _ := upload["url"].(string)
	_, _ = uploadID, uploadURL // the next steps use them
}
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json.Nodes;

var api = Environment.GetEnvironmentVariable("BLITFRAME");
var authorization = new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("BLITFRAME_API_KEY"));
var client = new HttpClient();

var sizeBytes = new FileInfo("background.mp4").Length;
var request = new HttpRequestMessage(HttpMethod.Post, $"{api}/uploads");
request.Headers.Authorization = authorization;
request.Content = JsonContent.Create(new { fileName = "background.mp4", sizeBytes });
var response = await client.SendAsync(request);
var upload = await response.Content.ReadFromJsonAsync<JsonNode>();
var uploadId = upload!["id"]!.GetValue<string>();
var uploadUrl = (string?)upload["url"];
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;

public class Example {
    public static void main(String[] args) throws Exception {
        String api = System.getenv("BLITFRAME");
        String authorization = "Bearer " + System.getenv("BLITFRAME_API_KEY");
        HttpClient client = HttpClient.newHttpClient();
        ObjectMapper json = new ObjectMapper();

        Path file = Path.of("background.mp4");
        String uploadBody = """
            {"fileName": "background.mp4", "sizeBytes": %d}
            """.formatted(Files.size(file));
        HttpRequest request = HttpRequest.newBuilder(URI.create(api + "/uploads"))
            .header("Authorization", authorization)
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(uploadBody))
            .build();
        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        JsonNode upload = json.readTree(response.body());
        String uploadId = upload.get("id").asText();
        String uploadUrl = upload.get("url").asText();
    }
}
Field What it does Values
fileName The file's name. Up to 255 characters. A supported file type, or .zip.
sizeBytes The size in bytes. Required. 1 byte to 8 GB.

A successful response means the upload was created and is waiting for the file. It contains the upload's id, which the request that uses the upload sends as uploadId or zipUploadId. For a file of up to 100 MB, it also contains the url to send the file to:

{ "id": "1c9d…", "status": "open", "fileName": "background.mp4", "sizeBytes": 48211933, "kind": "video", "url": "https://…", "method": "PUT", "expiresAt": "2026-11-04T20:00:00+00:00", "multipart": null, "error": null }

kind is the file's kind, null for a ZIP. For a file above 100 MB, url is null, and the file goes up in parts. See Multipart uploads.

To create up to 100 uploads in one request, send POST /v1/uploads/batch with files, a list of fileName and sizeBytes. It answers { "uploads": [...] }, one upload as above per file, in the order sent.

Send an Idempotency-Key header with either request, so a retry after a lost response gets the same uploads, with fresh URLs, instead of new ones. See Retrying safely.

API reference: Create an upload.

2. PUT the bytes

Send the file to the upload's url in a PUT request, with the file as the body. Send no Authorization header: the url is already signed. The body must be exactly sizeBytes bytes: storage answers any other size with SignatureDoesNotMatch.

Lost the url? GET /v1/uploads/{uploadId} answers a fresh one while the upload is open.

curl -s -X PUT --upload-file background.mp4 "$UPLOAD_URL"
with open("background.mp4", "rb") as file:
    requests.put(upload_url, data=file)
const fileBytes = await readFile("background.mp4");
await fetch(uploadUrl, { method: "PUT", body: fileBytes });
const fileBytes = await readFile("background.mp4");
await fetch(uploadUrl, { method: "PUT", body: fileBytes });
$file = fopen("background.mp4", "rb");
$ch = curl_init($uploadUrl);
curl_setopt_array($ch, [
    CURLOPT_UPLOAD => true,
    CURLOPT_INFILE => $file,
    CURLOPT_INFILESIZE => filesize("background.mp4"),
    CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
fclose($file);
uri = URI(upload_url)
request = Net::HTTP::Put.new(uri)
File.open("background.mp4", "rb") do |file|
  request.body_stream = file
  request["Content-Length"] = file.size.to_s
  Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
end
putRequest, err := http.NewRequest("PUT", uploadURL, file)
if err != nil {
	panic(err)
}
putRequest.ContentLength = info.Size()
putResponse, err := client.Do(putRequest)
if err != nil {
	panic(err)
}
putResponse.Body.Close()
await using var file = File.OpenRead("background.mp4");
await client.PutAsync(uploadUrl, new StreamContent(file));
HttpRequest putRequest = HttpRequest.newBuilder(URI.create(uploadUrl))
    .PUT(HttpRequest.BodyPublishers.ofFile(file))
    .build();
client.send(putRequest, HttpResponse.BodyHandlers.discarding());

3. Complete it

Completing an upload tells Blitframe that the whole file has arrived. Blitframe then checks the file, and the upload can be used once the check passes. Complete every upload after you send its bytes.

curl -s -X POST $BLITFRAME/uploads/$UPLOAD_ID/complete \
  -H "Authorization: Bearer $BLITFRAME_API_KEY" \
  -H "Prefer: wait=30" | jq '{status, error}'
response = requests.post(f"{api}/uploads/{upload_id}/complete", headers={**headers, "Prefer": "wait=30"})
completed = response.json()
print(completed["status"], completed["error"])
const completeResponse = await fetch(`${process.env.BLITFRAME}/uploads/${uploadId}/complete`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.BLITFRAME_API_KEY}`, Prefer: "wait=30" },
});
const completed = await completeResponse.json();
console.log(completed.status, completed.error);
const completeResponse = await fetch(`${process.env.BLITFRAME}/uploads/${uploadId}/complete`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.BLITFRAME_API_KEY}`, Prefer: "wait=30" },
});
const completed = await completeResponse.json();
console.log(completed.status, completed.error);
$ch = curl_init("$api/uploads/$uploadId/complete");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [$authorization, "Prefer: wait=30"],
]);
$response = curl_exec($ch);
$completed = json_decode($response, true);
print_r([$completed["status"], $completed["error"]]);
uri = URI("#{api}/uploads/#{upload_id}/complete")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = authorization
request["Prefer"] = "wait=30"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
completed = JSON.parse(response.body)
p completed["status"], completed["error"]
// also import "fmt"
completeRequest, err := http.NewRequest("POST", api+"/uploads/"+uploadID+"/complete", nil)
if err != nil {
	panic(err)
}
completeRequest.Header.Set("Authorization", authorization)
completeRequest.Header.Set("Prefer", "wait=30")
completeResponse, err := client.Do(completeRequest)
if err != nil {
	panic(err)
}
defer completeResponse.Body.Close()
var completed map[string]any
if err := json.NewDecoder(completeResponse.Body).Decode(&completed); err != nil {
	panic(err)
}
fmt.Println(completed["status"], completed["error"])
var completeRequest = new HttpRequestMessage(HttpMethod.Post, $"{api}/uploads/{uploadId}/complete");
completeRequest.Headers.Authorization = authorization;
completeRequest.Headers.Add("Prefer", "wait=30");
var completeResponse = await client.SendAsync(completeRequest);
var completed = await completeResponse.Content.ReadFromJsonAsync<JsonNode>();
var errorMessage = (string?)completed!["error"]?["message"];
Console.WriteLine($"{completed["status"]} {errorMessage ?? "null"}");
HttpRequest completeRequest = HttpRequest.newBuilder(URI.create(api + "/uploads/" + uploadId + "/complete"))
    .header("Authorization", authorization)
    .header("Prefer", "wait=30")
    .POST(HttpRequest.BodyPublishers.noBody())
    .build();
HttpResponse<String> completeResponse = client.send(completeRequest, HttpResponse.BodyHandlers.ofString());
JsonNode completed = json.readTree(completeResponse.body());
System.out.println(completed.get("status").asText() + " " + completed.get("error"));

A successful response describes the upload, and its status says where the check stands. The Prefer: wait=30 header makes Blitframe hold the request for up to 30 seconds, until the upload is ready or failed. The longest wait is 50 seconds.

status Meaning
open Not completed yet.
processing Being checked. A long video can take minutes.
ready An edit, render or import can use it. A ZIP is checked only when it is imported.
failed error says why.

A failed upload looks like this:

{ "id": "1c9d…", "status": "failed", "fileName": "background.mp4", "sizeBytes": 48211933, "kind": "video", "url": null, "method": null, "expiresAt": "2026-11-04T20:00:00+00:00", "multipart": null, "error": { "code": "invalid_request", "message": "'background.mp4' is not a valid .mp4 file." } }

If the upload is still processing, ask for it with GET /v1/uploads/{uploadId} until it is ready or failed. This request takes Prefer: wait=N too.

What to do about a failed upload depends on the code in its error:

Failure What to do
interrupted Complete the upload again, without sending the bytes again.
check_limit Upload the file again.
Any other The file itself failed. Create a new upload.

API reference: Get an upload.

4. Use it

Each upload can be used once: by an edit, a ZIP import or one render.

Use it before its expiresAt: 1 hour after you create it, or 24 hours for a multipart upload. See Limits.

In an edit

To add the uploaded file to a project, send an edit, POST /v1/projects/{projectId}/versions, that names the upload as one of its files. path is where the file goes in the project:

{ "files": [{ "path": "video/background.mp4", "uploadId": "1c9d…" }] }
  • The path must end in the upload's extension.
  • To upload a composition, create the upload with the fileName data.json.
  • The upload must be ready.

See Editing a project.

In a render

A render can show an uploaded image or video in place of a layer's own, for that video only. The layer's replacement names the upload in its file:

{ "layer": "/layers/3", "file": { "path": "images/product-es.png", "uploadId": "1c9d…" } }

The upload must be ready. See Render with replacements and When an upload is refused.

As a new project

A whole project can go up as one ZIP: the composition together with its images, videos, fonts and audio. A composition exported from After Effects is uploaded this way. See After Effects extension.

Upload the ZIP with steps 1 to 3, with a fileName that ends in .zip. Then create the project from the upload:

POST /v1/projects
{ "name": "Summer ad", "zipUploadId": "1c9d…", "fontLicenseAccepted": true }

A successful response means the project was created from the ZIP, and contains the project's id. If the ZIP is still importing when the request answers, you get 202 Accepted with an import to follow instead. See Large ZIPs.

The ZIP's files become the project's first version, with paths counted from the folder that holds data.json.

  • Put data.json at the top of the ZIP, or zip the folder that holds it. With more than one data.json, the one nearest the top is the composition; if two are equally near, neither is.
  • Every file must be a supported type. Files your system adds, such as .DS_Store, are skipped.
  • A ZIP with font files needs "fontLicenseAccepted": true. See Font licensing.
  • A ZIP exported from Blitframe also brings back its version's name, message and soundtrack, from its version.blitframe file.
  • A ready export of this workspace needs no download or upload: send its id as fromExportId instead of zipUploadId, here or in an import into an existing project.
  • A project export creates every variation it holds, each with its folder's files.

Into an existing project

A ZIP can also replace the files of a project you already have. Upload the ZIP the same way, then import it as the project's next version:

POST /v1/projects/{projectId}/package
{ "zipUploadId": "1c9d…", "expectedHeadVersionId": "b7e2…" }

A successful response describes the new version, which is now the head. The new version holds only the ZIP's files: a file of the old head that is not in the ZIP is not in the new version. A ZIP whose files and soundtrack match the head, and whose name does too when it has one, makes no version: the response is the head, with 200 OK.

Field What it does Default
variation The variation to import into. main
fontLicenseAccepted true when the ZIP has font files. false
expectedHeadVersionId The head you read. If it has moved when the import finishes, you get 409 head_moved and the upload stays usable.

The ZIP follows the same rules as for a new project, but a project export is refused with 400 invalid_request. The new version keeps the project's soundtrack as long as the ZIP holds the soundtrack's audio file, unless the ZIP is an export with a soundtrack of its own, which it uses instead.

Send an Idempotency-Key header with either import request, so a retry can't import the ZIP twice. See Retrying safely.

Large ZIPs

An import request answers within 50 seconds, or sooner with Prefer: wait=N. If the ZIP is still importing then, you get 202 Accepted with an import: the job that is still bringing the ZIP into the project. Follow it by its id:

{
  "id": "e41c…",
  "projectId": "9a0f…",
  "status": "importing",
  "versionId": null,
  "error": null,
  "createdAt": "2026-11-07T09:30:00+00:00",
  "finishedAt": null
}
  1. Send GET /v1/projects/{projectId}/package/{importId} until status is succeeded or failed. It takes Prefer: wait=N too.
  2. On succeeded, read the new versionId. On failed, error says why.

A project created from a ZIP that fails is not kept. If an import fails with interrupted, send it again.

For other failures, see Refusals and background errors.

API reference: Get a ZIP import.

Multipart uploads

A multipart upload sends one file in several parts, each in its own PUT. A file above 100 MB goes up this way, in parts of partSize bytes. Create the upload as in step 1. Its response has multipart in place of url, with a link for each part:

{
  "id": "7a41…",
  "status": "open",
  "fileName": "launch-film.mp4",
  "sizeBytes": 240000000,
  "kind": "video",
  "url": null,
  "method": null,
  "expiresAt": "2026-11-05T20:00:00+00:00",
  "multipart": {
    "partSize": 67108864,
    "partCount": 4,
    "urlsExpireAt": "2026-11-04T21:00:00+00:00",
    "parts": [{ "partNumber": 1, "url": "https://…" }, { "partNumber": 2, "url": "https://…" }, …]
  },
  "error": null
}
  1. PUT each part to its URL: part 1 is the first partSize bytes, part 2 the next, and so on. Parts can go in parallel.
  2. Keep the ETag header of each PUT response.
  3. Complete the upload with every part: { "parts": [{ "partNumber": 1, "etag": "…" }] }.

The examples continue from step 1, in place of steps 2 and 3.

PART_SIZE=$(echo "$UPLOAD" | jq -r .multipart.partSize)
PARTS='[]'
for N in $(echo "$UPLOAD" | jq -r '.multipart.parts[].partNumber'); do
  PART_URL=$(echo "$UPLOAD" | jq -r --argjson n "$N" '.multipart.parts[] | select(.partNumber == $n) | .url')
  ETAG=$(dd if=background.mp4 bs="$PART_SIZE" skip=$((N - 1)) count=1 2>/dev/null \
    | curl -s -X PUT --data-binary @- -D - -o /dev/null "$PART_URL" \
    | tr -d '\r' | awk 'tolower($1) == "etag:" { print $2 }')
  PARTS=$(echo "$PARTS" | jq -c --argjson n "$N" --arg etag "$ETAG" '. + [{partNumber: $n, etag: $etag}]')
done

curl -s -X POST $BLITFRAME/uploads/$UPLOAD_ID/complete \
  -H "Authorization: Bearer $BLITFRAME_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Prefer: wait=50" \
  -d '{"parts":'"$PARTS"'}' | jq '{status, error}'
part_size = upload["multipart"]["partSize"]
parts = []
with open("background.mp4", "rb") as file:
    for part in upload["multipart"]["parts"]:
        file.seek((part["partNumber"] - 1) * part_size)
        response = requests.put(part["url"], data=file.read(part_size))
        parts.append({"partNumber": part["partNumber"], "etag": response.headers["ETag"]})

response = requests.post(f"{api}/uploads/{upload_id}/complete", headers={**headers, "Prefer": "wait=50"},
                         json={"parts": parts})
completed = response.json()
print(completed["status"], completed["error"])
const { open } = require("node:fs/promises");

const partSize = upload.multipart.partSize;
const file = await open("background.mp4");
const parts = [];
for (const { partNumber, url } of upload.multipart.parts) {
  const { buffer, bytesRead } = await file.read(Buffer.alloc(partSize), 0, partSize, (partNumber - 1) * partSize);
  const partResponse = await fetch(url, { method: "PUT", body: buffer.subarray(0, bytesRead) });
  parts.push({ partNumber, etag: partResponse.headers.get("etag") });
}
await file.close();

const completeResponse = await fetch(`${process.env.BLITFRAME}/uploads/${uploadId}/complete`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BLITFRAME_API_KEY}`,
    "Content-Type": "application/json",
    Prefer: "wait=50",
  },
  body: JSON.stringify({ parts }),
});
const completed = await completeResponse.json();
console.log(completed.status, completed.error);
import { open } from "node:fs/promises";

const partSize: number = upload.multipart.partSize;
const file = await open("background.mp4");
const parts: { partNumber: number; etag: string | null }[] = [];
for (const { partNumber, url } of upload.multipart.parts) {
  const { buffer, bytesRead } = await file.read(Buffer.alloc(partSize), 0, partSize, (partNumber - 1) * partSize);
  const partResponse = await fetch(url, { method: "PUT", body: buffer.subarray(0, bytesRead) });
  parts.push({ partNumber, etag: partResponse.headers.get("etag") });
}
await file.close();

const completeResponse = await fetch(`${process.env.BLITFRAME}/uploads/${uploadId}/complete`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BLITFRAME_API_KEY}`,
    "Content-Type": "application/json",
    Prefer: "wait=50",
  },
  body: JSON.stringify({ parts }),
});
const completed = await completeResponse.json();
console.log(completed.status, completed.error);
$partSize = $upload["multipart"]["partSize"];
$file = fopen("background.mp4", "rb");
$parts = [];
foreach ($upload["multipart"]["parts"] as $part) {
    fseek($file, ($part["partNumber"] - 1) * $partSize);
    $etag = "";
    $ch = curl_init($part["url"]);
    curl_setopt_array($ch, [
        CURLOPT_CUSTOMREQUEST => "PUT",
        CURLOPT_POSTFIELDS => fread($file, $partSize),
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$etag) {
            if (stripos($line, "etag:") === 0) {
                $etag = trim(substr($line, 5));
            }
            return strlen($line);
        },
    ]);
    curl_exec($ch);
    $parts[] = ["partNumber" => $part["partNumber"], "etag" => $etag];
}
fclose($file);

$ch = curl_init("$api/uploads/$uploadId/complete");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [$authorization, "Content-Type: application/json", "Prefer: wait=50"],
    CURLOPT_POSTFIELDS => json_encode(["parts" => $parts]),
]);
$response = curl_exec($ch);
$completed = json_decode($response, true);
print_r([$completed["status"], $completed["error"]]);
part_size = upload["multipart"]["partSize"]
parts = File.open("background.mp4", "rb") do |file|
  upload["multipart"]["parts"].map do |part|
    file.seek((part["partNumber"] - 1) * part_size)
    uri = URI(part["url"])
    request = Net::HTTP::Put.new(uri)
    request.body = file.read(part_size)
    response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
    { partNumber: part["partNumber"], etag: response["ETag"] }
  end
end

uri = URI("#{api}/uploads/#{upload_id}/complete")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = authorization
request["Content-Type"] = "application/json"
request["Prefer"] = "wait=50"
request.body = { parts: parts }.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") { |http| http.request(request) }
completed = JSON.parse(response.body)
p completed["status"], completed["error"]
// also import "fmt" and "io"
multipart := upload["multipart"].(map[string]any)
partSize := int64(multipart["partSize"].(float64))
parts := []map[string]any{}
for _, item := range multipart["parts"].([]any) {
	part := item.(map[string]any)
	number := int64(part["partNumber"].(float64))
	offset := (number - 1) * partSize
	length := min(partSize, info.Size()-offset)
	partRequest, err := http.NewRequest("PUT", part["url"].(string), io.NewSectionReader(file, offset, length))
	if err != nil {
		panic(err)
	}
	partRequest.ContentLength = length
	partResponse, err := client.Do(partRequest)
	if err != nil {
		panic(err)
	}
	partResponse.Body.Close()
	parts = append(parts, map[string]any{"partNumber": number, "etag": partResponse.Header.Get("ETag")})
}

completeBody, err := json.Marshal(map[string]any{"parts": parts})
if err != nil {
	panic(err)
}
completeRequest, err := http.NewRequest("POST", api+"/uploads/"+uploadID+"/complete", bytes.NewReader(completeBody))
if err != nil {
	panic(err)
}
completeRequest.Header.Set("Authorization", authorization)
completeRequest.Header.Set("Content-Type", "application/json")
completeRequest.Header.Set("Prefer", "wait=50")
completeResponse, err := client.Do(completeRequest)
if err != nil {
	panic(err)
}
defer completeResponse.Body.Close()
var completed map[string]any
if err := json.NewDecoder(completeResponse.Body).Decode(&completed); err != nil {
	panic(err)
}
fmt.Println(completed["status"], completed["error"])
var partSize = upload["multipart"]!["partSize"]!.GetValue<long>();
await using var file = File.OpenRead("background.mp4");
var parts = new List<object>();
foreach (var part in upload["multipart"]!["parts"]!.AsArray())
{
    var partNumber = part!["partNumber"]!.GetValue<int>();
    file.Position = (partNumber - 1) * partSize;
    var bytes = new byte[Math.Min(partSize, file.Length - file.Position)];
    await file.ReadExactlyAsync(bytes);
    var partResponse = await client.PutAsync((string)part["url"]!, new ByteArrayContent(bytes));
    parts.Add(new { partNumber, etag = partResponse.Headers.GetValues("ETag").First() });
}

var completeRequest = new HttpRequestMessage(HttpMethod.Post, $"{api}/uploads/{uploadId}/complete");
completeRequest.Headers.Authorization = authorization;
completeRequest.Headers.Add("Prefer", "wait=50");
completeRequest.Content = JsonContent.Create(new { parts });
var completeResponse = await client.SendAsync(completeRequest);
var completed = await completeResponse.Content.ReadFromJsonAsync<JsonNode>();
var errorMessage = (string?)completed!["error"]?["message"];
Console.WriteLine($"{completed["status"]} {errorMessage ?? "null"}");
// also import java.io.RandomAccessFile
long partSize = upload.get("multipart").get("partSize").asLong();
var parts = json.createArrayNode();
try (RandomAccessFile reader = new RandomAccessFile(file.toFile(), "r")) {
    for (JsonNode part : upload.get("multipart").get("parts")) {
        int partNumber = part.get("partNumber").asInt();
        long offset = (partNumber - 1) * partSize;
        byte[] partBytes = new byte[(int) Math.min(partSize, reader.length() - offset)];
        reader.seek(offset);
        reader.readFully(partBytes);
        HttpRequest partRequest = HttpRequest.newBuilder(URI.create(part.get("url").asText()))
            .PUT(HttpRequest.BodyPublishers.ofByteArray(partBytes))
            .build();
        HttpResponse<Void> partResponse = client.send(partRequest, HttpResponse.BodyHandlers.discarding());
        String etag = partResponse.headers().firstValue("ETag").orElseThrow();
        parts.addObject().put("partNumber", partNumber).put("etag", etag);
    }
}

String completeBody = json.createObjectNode().set("parts", parts).toString();
HttpRequest completeRequest = HttpRequest.newBuilder(URI.create(api + "/uploads/" + uploadId + "/complete"))
    .header("Authorization", authorization)
    .header("Content-Type", "application/json")
    .header("Prefer", "wait=50")
    .POST(HttpRequest.BodyPublishers.ofString(completeBody))
    .build();
HttpResponse<String> completeResponse = client.send(completeRequest, HttpResponse.BodyHandlers.ofString());
JsonNode completed = json.readTree(completeResponse.body());
System.out.println(completed.get("status").asText() + " " + completed.get("error"));

A successful response describes the upload, as in step 3. If its status is still processing, get the upload until it is ready or failed. If a part is missing, the completion is refused: upload that part and complete again.

The links to the parts last 1 hour, and the upload stays open for 24 hours. To go on after the links have expired, ask for new links to the parts you have not sent:

POST /v1/uploads/7a41…/parts
{ "partNumbers": [3, 4] }

Leave out partNumbers to get every part.

Browsers can upload parts directly: the URLs accept cross-origin PUT requests and expose the ETag header.

Delete an upload

DELETE /v1/uploads/{uploadId} deletes an upload and answers 204.

A workspace can hold 1,000 unexpired uploads. Delete the ones you won't use, or let them expire. See Limits.

API reference: Delete an upload.

File capabilities

GET /v1/files/capabilities returns every supported file type with its limits. Use it for file pickers and to check a file before upload.

{
  "upload": { "maxSizeBytes": 8589934592, "singlePutMaxBytes": 104857600, "multipartPartSizeBytes": 67108864, "singleUploadLifetimeSeconds": 3600, "multipartUploadLifetimeSeconds": 86400, "partUrlLifetimeSeconds": 3600 },
  "zip": { "maxFiles": 5000, "maxUncompressedBytes": 8589934592, "maxCompressionRatio": 200 },
  "maxFilesPerVersion": 5000,
  "maxInlineEditBytes": 67108864,
  "maxInlineBinaryBytes": 1048576,
  "compositionPath": "data.json",
  "textFittingPath": "text_fitting.json",
  "files": [
    { "extension": ".mp4", "kind": "video", "contentType": "video/mp4", "maxSizeBytes": 4294967296, "defaultFolder": "videos/", "maxWidth": 8192, "maxHeight": 8192, "maxDurationSeconds": 3600, "fontLicenseRequired": false },
    { "extension": ".png", "kind": "image", "contentType": "image/png", "maxSizeBytes": 134217728, "defaultFolder": "images/", "maxWidth": 8192, "maxHeight": 8192, "maxDurationSeconds": null, "fontLicenseRequired": false },
    { "extension": ".ttf", "kind": "font", "contentType": "font/ttf", "maxSizeBytes": 67108864, "defaultFolder": "fonts/", "maxWidth": null, "maxHeight": null, "maxDurationSeconds": null, "fontLicenseRequired": true },
    …
  ]
}
Field Meaning
maxInlineEditBytes The largest edit request.
maxInlineBinaryBytes The largest file sent as contentBase64.
textFittingPath The file with a version's text fitting rules.
defaultFolder A suggestion. Any valid path works.
fontLicenseRequired true for fonts, which need fontLicenseAccepted: true.
maxDurationSeconds null for a type that never moves. On images, only GIF and WebP have one.

API reference: Get file capabilities.

Details

Refusals

A refused edit or import changes nothing.

Request Answer When
Create 413 too_large The file is over 8 GB or the limit for its type. See File capabilities.
Create 403 project_too_large A file other than a ZIP is over your plan's project size.
Create 403 storage_limit The file doesn't fit in your plan's storage. Delete projects or renders, or choose a larger plan.
Create 409 upload_limit The workspace holds 1,000 unexpired uploads. See Delete an upload.
Create, complete, edit or import 402 insufficient_render_seconds or 402 payment_disputed The workspace has no trial or plan, or a payment failed or is disputed. A low balance alone doesn't stop uploads.
Complete 409 upload_incomplete The file's bytes were not sent yet.
Complete 400 invalid_request A multipart upload's parts are missing, or storage refused them.
Edit 400 invalid_request The upload has expired, or another request used it.
Edit 409 upload_incomplete The upload is not completed.
Edit 409 upload_processing The upload is still being checked. The Retry-After header says when to try again.
Edit 409 upload_failed The upload failed its check.
Edit or import 403 project_too_large The version would be over your plan's project size.
Import 400 invalid_request The upload has expired or is not a .zip.
Import 409 head_moved expectedHeadVersionId is no longer the head. The upload stays usable.
Import 409 import_limit 10 imports are already waiting or running.
Import 404 not_found fromExportId names no export of this workspace, or one that has expired.
Import 409 export_not_ready The export fromExportId names is not ready.

A render that names an upload is refused in the same ways. See When an upload is refused.

Import details

  • A finished import's status is kept for 7 days.