API DocsUploadsUpload a video file

Upload a video file

PUTuploadUrl (from presign)
videos:writeuploads:writevideos:read

Upload a local video file in five calls:

  • 1. Create - POST /api/video/create with a new UUID as s3Key, isExternalUpload: true, uploadStatus: "uploading", and the file's width, height and duration. Plan limits apply
  • 2. Presign - POST /api/video/upload/presign with videoId, fileName and byteLength. Keep uploadUrl, headers and key
  • 3. PUT - Send the file bytes to uploadUrl with exactly those headers and no Authorization header. One PUT, so up to 5 GB
  • 4. Process - POST /api/video/:id/process-upload with { "sourceKey": key }
  • 5. Poll - GET /api/video/:id every few seconds until video.uploadStatus is ready, or video.uploadProcessingStatus is failed

Share and embed

  • Share page: https://flare.link/video/VIDEO_ID
  • Embed: see Get embed code

Examples

curl
TOKEN="flr_pat_..."
FILE="demo.mp4"
ID=$(uuidgen | tr 'A-Z' 'a-z')

# 1. Create
curl -s https://flare.link/api/video/create \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d "{\"fileName\":\"$FILE\",\"s3Key\":\"$ID\",\"isExternalUpload\":true,\"uploadStatus\":\"uploading\",\"width\":1920,\"height\":1080,\"duration\":120}"

# 2. Presign
PRESIGN=$(curl -s https://flare.link/api/video/upload/presign \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d "{\"videoId\":\"$ID\",\"fileName\":\"$FILE\",\"byteLength\":$(wc -c < "$FILE" | tr -d ' ')}")

# 3. PUT
curl -s -X PUT "$(echo "$PRESIGN" | jq -r .uploadUrl)" \
  -H "Content-Type: $(echo "$PRESIGN" | jq -r '.headers["Content-Type"]')" \
  --data-binary @"$FILE"

# 4. Process
curl -s https://flare.link/api/video/$ID/process-upload \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d "{\"sourceKey\":$(echo "$PRESIGN" | jq .key)}"

# 5. Poll
until curl -s https://flare.link/api/video/$ID -H "Authorization: Bearer $TOKEN" \
  | jq -e '.video.uploadStatus == "ready" or .video.uploadProcessingStatus == "failed"' > /dev/null
do sleep 5; done
node
import { randomUUID } from "node:crypto";
import { readFile } from "node:fs/promises";

const api = (path, body) =>
  fetch(`https://flare.link${path}`, {
    method: body ? "POST" : "GET",
    headers: { Authorization: "Bearer flr_pat_...", "Content-Type": "application/json" },
    body: body && JSON.stringify(body),
  }).then((res) => res.json());

const file = await readFile("demo.mp4");
const id = randomUUID();

await api("/api/video/create", {
  fileName: "demo.mp4", s3Key: id, isExternalUpload: true, uploadStatus: "uploading",
  width: 1920, height: 1080, duration: 120,
});
const presign = await api("/api/video/upload/presign", {
  videoId: id, fileName: "demo.mp4", byteLength: file.length,
});
await fetch(presign.uploadUrl, { method: "PUT", headers: presign.headers, body: file });
await api(`/api/video/${id}/process-upload`, { sourceKey: presign.key });

let video;
do {
  await new Promise((r) => setTimeout(r, 5000));
  ({ video } = await api(`/api/video/${id}`));
} while (video.uploadStatus !== "ready" && video.uploadProcessingStatus !== "failed");

console.log(`https://flare.link/video/${id}`);
python
import os, time, uuid
import requests

API = "https://flare.link"
H = {"Authorization": "Bearer flr_pat_..."}
path = "demo.mp4"
vid = str(uuid.uuid4())

requests.post(f"{API}/api/video/create", headers=H, json={
  "fileName": "demo.mp4", "s3Key": vid, "isExternalUpload": True,
  "uploadStatus": "uploading", "width": 1920, "height": 1080, "duration": 120,
}).raise_for_status()

presign = requests.post(f"{API}/api/video/upload/presign", headers=H, json={
  "videoId": vid, "fileName": "demo.mp4", "byteLength": os.path.getsize(path),
}).json()

with open(path, "rb") as f:
  requests.put(presign["uploadUrl"], headers=presign["headers"], data=f).raise_for_status()

requests.post(f"{API}/api/video/{vid}/process-upload", headers=H,
  json={"sourceKey": presign["key"]}).raise_for_status()

while True:
  time.sleep(5)
  video = requests.get(f"{API}/api/video/{vid}", headers=H).json()["video"]
  if video["uploadStatus"] == "ready" or video.get("uploadProcessingStatus") == "failed":
    break

print(f"https://flare.link/video/{vid}")

Expected response

{
  "success": true,
  "video": {
    "id": "VIDEO_ID",
    "uploadStatus": "ready",
    "uploadProcessingStatus": "completed",
    "thumbnailUrl": "https://videos.flare.link/VIDEO_ID/thumbnail.jpg"
  }
}