Endpoints
Upload File
Create a presigned upload URL and the final public media URL for a file.
POST
/
api
/
v1
/
upload
Create presigned upload URL
curl --request POST \
--url https://mallary.ai/api/v1/upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "launch-video.mp4",
"size": 2,
"type": "video/mp4"
}
'import requests
url = "https://mallary.ai/api/v1/upload"
payload = {
"filename": "launch-video.mp4",
"size": 2,
"type": "video/mp4"
}
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({filename: 'launch-video.mp4', size: 2, type: 'video/mp4'})
};
fetch('https://mallary.ai/api/v1/upload', 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://mallary.ai/api/v1/upload",
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([
'filename' => 'launch-video.mp4',
'size' => 2,
'type' => 'video/mp4'
]),
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://mallary.ai/api/v1/upload"
payload := strings.NewReader("{\n \"filename\": \"launch-video.mp4\",\n \"size\": 2,\n \"type\": \"video/mp4\"\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://mallary.ai/api/v1/upload")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"launch-video.mp4\",\n \"size\": 2,\n \"type\": \"video/mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mallary.ai/api/v1/upload")
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 \"filename\": \"launch-video.mp4\",\n \"size\": 2,\n \"type\": \"video/mp4\"\n}"
response = http.request(request)
puts response.read_body{
"uploadUrl": "<string>",
"mediaUrl": "<string>",
"contentType": "<string>",
"storageKey": "<string>",
"size": 123,
"headers": {}
}Use this upload endpoint for your post media and custom video thumbnail images.
Send the file’s MIME type in
If you omit
type when you know it. For an MP4 video, use:
{
"filename": "launch.mp4",
"type": "video/mp4"
}
type, Mallary uses the filename extension to choose a supported MIME type. Files with unknown extensions need an explicit supported type.
Upload the file bytes to the returned uploadUrl with HTTP PUT. Use the returned headers, including Content-Type, without changing them. Wait for the upload to finish before passing mediaUrl to POST /api/v1/post.Authorizations
Use Authorization: Bearer {api_key}
Body
application/json
Example:
"launch-video.mp4"
Optional file size in bytes for early validation against the 5GB limit.
Required range:
x >= 1File MIME type. Send it when known, such as video/mp4 for an MP4 video. If omitted, Mallary infers it from a supported filename extension. Files with unknown extensions need an explicit supported type.
Example:
"video/mp4"
Last modified on September 22, 2026
Was this page helpful?
Create presigned upload URL
curl --request POST \
--url https://mallary.ai/api/v1/upload \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "launch-video.mp4",
"size": 2,
"type": "video/mp4"
}
'import requests
url = "https://mallary.ai/api/v1/upload"
payload = {
"filename": "launch-video.mp4",
"size": 2,
"type": "video/mp4"
}
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({filename: 'launch-video.mp4', size: 2, type: 'video/mp4'})
};
fetch('https://mallary.ai/api/v1/upload', 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://mallary.ai/api/v1/upload",
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([
'filename' => 'launch-video.mp4',
'size' => 2,
'type' => 'video/mp4'
]),
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://mallary.ai/api/v1/upload"
payload := strings.NewReader("{\n \"filename\": \"launch-video.mp4\",\n \"size\": 2,\n \"type\": \"video/mp4\"\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://mallary.ai/api/v1/upload")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"launch-video.mp4\",\n \"size\": 2,\n \"type\": \"video/mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://mallary.ai/api/v1/upload")
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 \"filename\": \"launch-video.mp4\",\n \"size\": 2,\n \"type\": \"video/mp4\"\n}"
response = http.request(request)
puts response.read_body{
"uploadUrl": "<string>",
"mediaUrl": "<string>",
"contentType": "<string>",
"storageKey": "<string>",
"size": 123,
"headers": {}
}
