curl --request POST \
--url https://api.segmnt.cloud/v1/projects/{projectId}/uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "Lesson 1 - Introduction",
"fileName": "lesson-01.mp4",
"sizeBytes": 2147483648
}
'import requests
url = "https://api.segmnt.cloud/v1/projects/{projectId}/uploads"
payload = {
"title": "Lesson 1 - Introduction",
"fileName": "lesson-01.mp4",
"sizeBytes": 2147483648
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: 'Lesson 1 - Introduction',
fileName: 'lesson-01.mp4',
sizeBytes: 2147483648
})
};
fetch('https://api.segmnt.cloud/v1/projects/{projectId}/uploads', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.segmnt.cloud/v1/projects/{projectId}/uploads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'title' => 'Lesson 1 - Introduction',
'fileName' => 'lesson-01.mp4',
'sizeBytes' => 2147483648
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.segmnt.cloud/v1/projects/{projectId}/uploads"
payload := strings.NewReader("{\n \"title\": \"Lesson 1 - Introduction\",\n \"fileName\": \"lesson-01.mp4\",\n \"sizeBytes\": 2147483648\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.segmnt.cloud/v1/projects/{projectId}/uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Lesson 1 - Introduction\",\n \"fileName\": \"lesson-01.mp4\",\n \"sizeBytes\": 2147483648\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.segmnt.cloud/v1/projects/{projectId}/uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"Lesson 1 - Introduction\",\n \"fileName\": \"lesson-01.mp4\",\n \"sizeBytes\": 2147483648\n}"
response = http.request(request)
puts response.read_body{
"id": "upl_2bN6rD",
"video": {
"id": "vid_9xR4tL",
"projectId": "<string>",
"title": "Lesson 1 - Introduction",
"status": "uploading",
"durationSeconds": 123,
"qualities": [
"360p"
],
"sizeBytes": 123,
"failure": {
"code": "unsupported_codec",
"message": "<string>",
"retryable": true
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"readyAt": "2023-11-07T05:31:56Z"
},
"partSizeBytes": 104857600,
"parts": [
{
"partNumber": 2,
"url": "<string>"
}
],
"expiresAt": "2023-11-07T05:31:56Z"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}Start an upload
Creates a video in uploading status and returns one pre-signed PUT URL
per part. The client sends each part straight to storage, keeps the ETag
response header of each part, then calls the complete route.
Two ways to authenticate: a project API key or session from your server,
or a single-use upload token from POST /v1/projects/{projectId}/upload-tokens
for a browser. With a token, the browser must send the token’s verified
domain as its Origin; the token’s maxSizeBytes and content type are
enforced here and on complete.
Part upload: PUT the raw bytes to the part URL with the exact size of
that part as Content-Length. No auth header is needed (Content-Type
is not checked). The part URL signs the part’s Content-Length, so a
request that declares a different length is refused. Storage CORS allows
PUT from any origin and exposes ETag, so a browser can read it.
URLs are for upload only. Playback never uses storage URLs. Part URLs
work for 4 hours. The upload itself stays open until expiresAt, 24
hours after the start; calling create again with the same
Idempotency-Key returns the same upload with fresh part URLs.
Plan limits are checked here with sizeBytes, and again later: on complete
(real file size) and before encoding (real duration). A file over the limit
ends as failed with failure.code = plan_limit_reached and is removed.
Upload hours: Starter, Pro and Agency can keep uploading after they use
their included upload hours in the calendar month, up to 3 times those
hours. The included hours are 5 h on Starter, 15 h on Pro and 30 h on
Agency, so the cap is 15 h, 45 h and 90 h. At the cap, this call returns
403 with code = plan_limit_reached and limit = monthly_uploads_cap.
To go higher, contact support. Free and Pilot (by invitation) stop at their included hours
and return 403 with limit = monthly_uploads. Upload hours count the
processing hours of new uploads, as on the usage page. Extra upload hours
are recorded at 10 SAR per hour, before VAT; automatic billing for them
is coming soon. The stored-hours
limit, the file size, the video length and the encode limit still apply.
Rate limits: a call that uses a project API key is not limited per IP.
Each key may make up to 1,000 create and complete calls a minute. A browser
that uses an upload token is limited to 60 calls a minute per IP address.
If a call is limited,
the API returns 429 with a Retry-After header. Wait that many seconds,
then try again.
curl --request POST \
--url https://api.segmnt.cloud/v1/projects/{projectId}/uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "Lesson 1 - Introduction",
"fileName": "lesson-01.mp4",
"sizeBytes": 2147483648
}
'import requests
url = "https://api.segmnt.cloud/v1/projects/{projectId}/uploads"
payload = {
"title": "Lesson 1 - Introduction",
"fileName": "lesson-01.mp4",
"sizeBytes": 2147483648
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: 'Lesson 1 - Introduction',
fileName: 'lesson-01.mp4',
sizeBytes: 2147483648
})
};
fetch('https://api.segmnt.cloud/v1/projects/{projectId}/uploads', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.segmnt.cloud/v1/projects/{projectId}/uploads",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'title' => 'Lesson 1 - Introduction',
'fileName' => 'lesson-01.mp4',
'sizeBytes' => 2147483648
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.segmnt.cloud/v1/projects/{projectId}/uploads"
payload := strings.NewReader("{\n \"title\": \"Lesson 1 - Introduction\",\n \"fileName\": \"lesson-01.mp4\",\n \"sizeBytes\": 2147483648\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.segmnt.cloud/v1/projects/{projectId}/uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Lesson 1 - Introduction\",\n \"fileName\": \"lesson-01.mp4\",\n \"sizeBytes\": 2147483648\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.segmnt.cloud/v1/projects/{projectId}/uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"Lesson 1 - Introduction\",\n \"fileName\": \"lesson-01.mp4\",\n \"sizeBytes\": 2147483648\n}"
response = http.request(request)
puts response.read_body{
"id": "upl_2bN6rD",
"video": {
"id": "vid_9xR4tL",
"projectId": "<string>",
"title": "Lesson 1 - Introduction",
"status": "uploading",
"durationSeconds": 123,
"qualities": [
"360p"
],
"sizeBytes": 123,
"failure": {
"code": "unsupported_codec",
"message": "<string>",
"retryable": true
},
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"readyAt": "2023-11-07T05:31:56Z"
},
"partSizeBytes": 104857600,
"parts": [
{
"partNumber": 2,
"url": "<string>"
}
],
"expiresAt": "2023-11-07T05:31:56Z"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}{
"type": "<string>",
"title": "<string>",
"status": 123,
"code": "plan_limit_reached",
"detail": "<string>",
"limit": "<string>"
}