Emails
Upload File
Upload a file to the cache for use as an attachment or inline image across multiple emails.
POST
/
v1
/
files
Upload File
curl --request POST \
--url https://api.unosend.co/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"file": {}
}'import requests
url = "https://api.unosend.co/v1/files"
payload = { "file": {} }
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({file: {}})
};
fetch('https://api.unosend.co/v1/files', 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.unosend.co/v1/files",
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([
'file' => [
]
]),
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.unosend.co/v1/files"
payload := strings.NewReader("{\n \"file\": {}\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.unosend.co/v1/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.unosend.co/v1/files")
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 \"file\": {}\n}"
response = http.request(request)
puts response.read_bodyUpload files to Unosend’s file cache and reuse them across multiple email sends without re-uploading. Cached files are referenced by their
file_cache_key in subsequent API calls.
string
required
The filename including extension (e.g.,
logo.png, invoice.pdf).binary
required
The file content as multipart/form-data.
Request
curl -X POST "https://api.unosend.co/v1/files?name=logo.png" \
-H "Authorization: Bearer un_xxxxxxxxxx" \
-F "file=@/path/to/logo.png"
const formData = new FormData();
formData.append('file', fileBlob, 'logo.png');
await fetch('https://api.unosend.co/v1/files?name=logo.png', {
method: 'POST',
headers: {
'Authorization': 'Bearer un_xxxxxxxxxx'
},
body: formData
});
import requests
with open('logo.png', 'rb') as f:
requests.post(
'https://api.unosend.co/v1/files?name=logo.png',
headers={'Authorization': 'Bearer un_xxxxxxxxxx'},
files={'file': ('logo.png', f, 'image/png')}
)
Response
200
{
"message": "OK",
"data": {
"file_cache_key": "fc_1a2b3c4d5e6f",
"name": "logo.png",
"size": 24576,
"content_type": "image/png",
"created_at": "2026-01-15T10:30:00.000Z"
}
}
Using Cached Files in Emails
Reference thefile_cache_key when sending emails:
{
"from": {"address": "hello@yourdomain.com", "name": "Your App"},
"to": [{"email_address": {"address": "user@example.com"}}],
"subject": "Your Invoice",
"htmlbody": "<p>Please find your invoice attached.</p>",
"attachments": [
{
"file_cache_key": "fc_1a2b3c4d5e6f",
"name": "invoice.pdf"
}
]
}
Inline Images
Usecid to embed images inline in HTML:
{
"htmlbody": "<img src='cid:logo' />",
"inline_images": [
{
"file_cache_key": "fc_1a2b3c4d5e6f",
"cid": "logo"
}
]
}
- Maximum file size: 10 MB
- Total email size (headers + body + attachments): 15 MB
- Cached files are stored for 30 days from last use
⌘I
Upload File
curl --request POST \
--url https://api.unosend.co/v1/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"file": {}
}'import requests
url = "https://api.unosend.co/v1/files"
payload = { "file": {} }
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({file: {}})
};
fetch('https://api.unosend.co/v1/files', 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.unosend.co/v1/files",
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([
'file' => [
]
]),
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.unosend.co/v1/files"
payload := strings.NewReader("{\n \"file\": {}\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.unosend.co/v1/files")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"file\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.unosend.co/v1/files")
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 \"file\": {}\n}"
response = http.request(request)
puts response.read_body