Skip to main content
Your app sends the video file straight to our storage. Your server never carries the file. The upload has 4 steps:
  1. Create the upload. You get one pre-signed URL for each part.
  2. PUT each part to its URL. Keep the ETag header of each answer.
  3. Complete the upload with the list of part numbers and ETags.
  4. We encode the video. Poll the video until it is ready, or subscribe to the video.ready webhook.
The pre-signed URLs are for upload only. Playback uses separate signed playback tokens: see Create playback tokens on your server and Embed a video on any website.

Before you start

  • A project ID (prj_...) and an API key for that project (sk_...).
  • Base URL: https://api.segmnt.cloud
  • Send the key as Authorization: Bearer <key> on the API calls. Do not send it to the part URLs.

Limits

Small files (under 100 MiB) have one part. The size limit is checked 3 times: when you create the upload (declared sizeBytes), when you complete it (real size), and before encoding (real duration). If the real file is over the limit, the video ends as failed with failure.code = plan_limit_reached, and the file is removed. If the real file is not the same size as the sizeBytes you declared (larger or smaller), the video ends as failed with size_mismatch. No encoding starts.

Step 1: Create the upload

Answer (201):
Idempotency-Key is optional but we recommend it. If your request times out, send it again with the same key and you get the same upload. The header works with a server API key. With an upload token (browser upload), the header is ignored. The single-use token protects you instead. The answer has fresh part URLs, so you can send the parts again after the old part URLs expire (part URLs work for 4 hours). Treat the part URLs like secrets. Do not log them. We do not ask for a phone number or an SMS code to upload. A blocked account always gets 403 account_banned, and the ban check always applies. See Phone verification.

Step 2: PUT the parts

Cut the file into pieces of partSizeBytes. PUT the raw bytes of piece N to the URL for partNumber N. Send the part’s exact size as Content-Length: the part URL signs it, so a different length is refused. Content-Type is not checked. No auth header is needed. Read the ETag response header and keep it with the part number. Browsers can read ETag because our storage exposes it in CORS. See Browser for what a browser can and cannot do on your own domain. You can send parts in parallel (4 at a time is a good start) and in any order.

Step 3: Complete

Send every part. Use the ETag exactly as you got it (keep the quote marks) — quoted and unquoted ETags are both accepted. The ETag must come from the same part number. If a part was sent twice, use the ETag of the newest answer. Answer: 202 with the video, now with status: "processing". Complete is safe to retry. If the upload is already complete, you get 202 with the current video. A complete for a valid upload always answers 202, even when the encoder is busy. The video waits in one shared queue and shows processing until it is ready. Complete never fails because the encoder is busy. A complete can answer 429 rate_limited if you send too many requests. Wait the Retry-After seconds, then send the same request again. Do not cancel and do not upload again. See Uploading many videos (bulk import).

Step 4: Wait for the result

The video goes processing then ready (or failed). Poll GET /v1/projects/{projectId}/videos/{videoId} until the status changes, or subscribe to the video.ready webhook. The webhook is live: register your own HTTPS endpoint and we send the event when a video becomes ready. See Feature status. In rare cases our team can hold a video for review (status held). It does not play until the hold ends. See Moderation and held videos. Cancel only stops an upload that has not finished. To delete a video you have already completed, see Manage videos.

Cancel an upload

Answer: 204. The parts and the video are removed. Calling it again is safe. If the upload is already complete, you get 409 upload_closed. Open uploads that are not completed are removed after expiresAt.

Resume an interrupted upload

Status: Available. See Feature status.
If the connection drops, the page reloads, or a part link expires, you do not need to start again. Ask for the upload status, send only the parts that are missing, then complete the upload.
  1. Get the status. Call GET on the upload.
  2. Check each part. A part with "uploaded": true is already in storage. Keep its etag if the answer has one. A part with "uploaded": false has a new url. Send that part.
  3. PUT the missing parts. Use the new url. Send the part’s sizeBytes as Content-Length. Keep the ETag of each part.
  4. Complete. Send the parts with their ETags. You can also send only the part numbers, or an empty body ({}). If an ETag is missing, we read that part from storage.
The status call:
Answer (200), shortened:
What the answer means:
  • url is only in the answer for a part that is missing, or that was stored at the wrong size. A part that is already stored has no url.
  • recommendedParallelism is 4. Send at most 4 parts at a time.
  • Each new url works for up to 4 hours, and never past expiresAt. Get the status again if a link expires.
  • A completed or failed upload returns the video and an empty parts list. A completed upload is done: poll the video or wait for the webhook. A failed video has a failure.code. Start a new upload to try again.
  • An aborted upload, or an open upload past its expiresAt, returns 409 upload_closed. Start a new upload. A completed or failed upload keeps returning its video, also after expiresAt.
If the complete call returns 400 invalid_parts, a part is missing or was stored at the wrong size. The detail names the part when it can. The upload stays open. Use the detail to fix the part, then complete again. If the detail says the upload did not arrive correctly, it does not name a part. Call the status again, PUT each part that has a url, then complete again. If no part has a url, start a new upload. Browser upload token. A token can call GET for its own upload. A token past its expiry still works for its own upload, while the upload is open and before its expiresAt. After that, the token gets 401 unauthorized. A token can never create another upload or read another upload. Rate limit. GET allows 30 calls a minute for each upload ID. A 429 answer has a Retry-After header. Wait that many seconds, then try again.

Uploading many videos (bulk import)

You can move a whole library in one run: hundreds of files, the same 4 steps for each. Three rules keep the run safe. 1. Keep up to 10 uploads open at a time. Create uploads and send parts for several files at once. A project can have 10 uploads open. An upload is open until you complete it, cancel it, or it expires. The eleventh create answers 429 too_many_open_uploads. Complete one open upload, or cancel it, then create the next. Completing an upload frees its place at once, even while its video is still encoding. 2. Complete each upload. Do not wait for encoding. Complete answers 202 for every valid upload. Encoding does not refuse it and does not make you retry. Videos from all customers share one encode queue. They start in arrival order as the encoder has room, and each shows processing until it is ready. Do not cancel, and do not upload the file again, because a video is still waiting.
  • If complete answers 429 rate_limited, wait the Retry-After seconds, then send the same complete request again, with the same parts. Your file is not lost.
  • Do not cancel a finished upload. Cancelling removes the stored file and the video, and you must upload the whole file again.
  • Do not upload the same file again. It creates a second video.
An open upload expires 24 hours after it was created (expiresAt). Complete each upload before then. 3. Track each video to the end. Use the video.ready webhook, or poll GET /v1/projects/{projectId}/videos/{videoId}, until each video is ready or failed. A failed video names the file to check. Do not embed a video before it is ready. For a copy-paste retry loop that honours Retry-After, see Code samples.

How long a bulk import takes

Upload speed does not set the total time. Encoding does. We do not promise a time, because the queue is shared by all customers. The wait depends on how many videos are waiting when you upload. Measure the first batch of your own import, and plan the rest from that. Encode time grows with the length and the quality of the source file.

Errors

Errors use application/problem+json. Use the code field in your code, not the text. Errors on the part PUT come from storage, not from our API. See the next section.

Retry rules

Do not retry 400, 401, 403 and 404 from the API without a change.

Code examples

These examples were run against the current release. The Node, Python and PHP examples each uploaded a 250 MiB file (3 parts) and the video reached processing. The create, complete, cancel and error paths are also covered by our test suite.

Node.js (18+)

Python 3 (pip install requests)

PHP / Laravel

Note: this PHP example reads each part into memory (100 MiB or more). Use a PHP memory_limit of at least 512 MB, or stream the part.

Browser

A browser can upload on your own domain with a browser upload token. The token is short-lived, single-use and capped in size. Your server creates it; the browser never sees your API key. The flow:
  1. Your server calls POST /v1/projects/{projectId}/upload-tokens with your full API key. The body names the verified domain, a maxSizeBytes and the contentType.
  2. Your server sends the returned token to the browser.
  3. The browser calls create and complete with Authorization: Bearer <token> from that domain. It also PUTs each part to its pre-signed URL and reads the ETag.
  4. The PUT work still goes straight to storage: the file never passes through the API.
The token allows exactly one create and its matching complete, and nothing else: it cannot list, delete or play. A second create gets 409 token_used. The part PUT needs no auth header, and our storage allows the PUT from any origin and exposes the ETag header. Rules: Create the token on your server:
Answer (201):
The browser then calls create and complete with the token instead of a key. Bans, plan limits and the review hold (where it is on) still apply.
If you cannot mint an upload token on your server, the older path still works: your server calls create and complete, and the browser only PUTs the parts. The browser cannot call create or complete with an API key from your own domain; only the token path above, or our dashboard origin, is allowed.