Create an upload
Returns a signed URL for files larger than 100 MB. Send the file as the body of a PUT to url, then call POST /v1/convert with upload_id. Supports Idempotency-Key.
https://api.switchfile.io/v1/uploadsExample
curl "https://api.switchfile.io/v1/uploads" \
-H "Authorization: Bearer $SWITCHFILE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"filename": "lecture.mov",
"size": 734003200
}'const res = await fetch("https://api.switchfile.io/v1/uploads", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
filename: "lecture.mov",
size: 734003200
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());<?php
$ch = curl_init('https://api.switchfile.io/v1/uploads');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'filename' => 'lecture.mov',
'size' => 734003200,
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('SWITCHFILE_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
if ($status >= 400) {
throw new RuntimeException("HTTP $status: $response");
}
print_r(json_decode($response, true));import os
import requests
res = requests.post(
"https://api.switchfile.io/v1/uploads",
headers={"Authorization": f"Bearer {os.environ['SWITCHFILE_API_KEY']}"},
json={
"filename": "lecture.mov",
"size": 734003200,
},
)
res.raise_for_status()
print(res.json())Parameters
Headers
Idempotency-Keystring1 to 255 visible ASCII characters, for example a UUID. Send the request again with the same key after a timeout: nothing is created twice. Kept for 24 hours.
example: 6f1c2b8e-1d8e-4c55-9f0e-3f3f0b0a8f21
X-End-UserstringService keys only: an ID for the visitor you act for (1 to 128 characters: letters, digits and . _ : @ -). Quotas and rate limits then count per visitor.
X-End-User-IpstringRequired with X-End-User: the IP address of the visitor.
Request body
filenamestringFile name. Its extension sets the input format
1 to 255 characters
sizestring (integer) | integerSize in bytes, if known. Over the limit, this request fails with 413 FILE_TOO_LARGE
at least 0
Responses
201Created
expires_atstringrequiredThe upload_id works until this time
headersmap of stringrequiredHeaders the PUT request must send (usually none)
keys match ^(.*)$
max_file_sizestring (integer) | integerrequiredmethodstringrequiredone of "PUT"
upload_idstring (uuid)requiredurlstringrequiredSend the file as the body of a PUT request to this URL
url_expires_atstringrequiredStart the PUT before this time
201 application/json{ "upload_id": "7d1f0f7e-0b55-4a8e-8c5b-9d8e3f1a2b3c", "method": "PUT", "url": "https://api.switchfile.io/v1/uploads/7d1f0f7e-0b55-4a8e-8c5b-9d8e3f1a2b3c/content?expires=1762538401&signature=3f9c2a7d41e8b6c05d1f9e2a7b4c8d3e6f0a1b2c3d4e5f60718293a4b5c6d7e8", "headers": {}, "max_file_size": 1073741824, "url_expires_at": "2026-11-06T18:15:00+00:00", "expires_at": "2026-11-07T18:00:00+00:00" }401The API key is missing or not valid
UNAUTHENTICATED401 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-unauthenticated", "title": "Unauthenticated", "status": 401, "code": "UNAUTHENTICATED", "detail": "Missing or invalid API key." }403Not allowed: a signed URL is wrong or expired, or X-End-User was sent without a service key
END_USER_NOT_ALLOWED403 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-end-user-not-allowed", "title": "End user not allowed", "status": 403, "code": "END_USER_NOT_ALLOWED", "detail": "The X-End-User header is only allowed with a service key." }404Does not exist for this account
NOT_FOUND404 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-not-found", "title": "Not found", "status": 404, "code": "NOT_FOUND", "detail": "Conversion not found." }409Conflict with the current state
IDEMPOTENCY_KEY_IN_USE409 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-idempotency-key-in-use", "title": "Idempotency key in use", "status": 409, "code": "IDEMPOTENCY_KEY_IN_USE", "detail": "A request with this Idempotency-Key is still running." }411The request has a body but no Content-Length header
LENGTH_REQUIRED411 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-length-required", "title": "Length required", "status": 411, "code": "LENGTH_REQUIRED", "detail": "A Content-Length header is required for this request." }413size is over max_file_size
FILE_TOO_LARGE413 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-file-too-large", "title": "File too large", "status": 413, "code": "FILE_TOO_LARGE", "detail": "The file is larger than the allowed maximum." }422Invalid data. errors names the fields
INVALID_DATA422 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-invalid-data", "title": "Invalid data", "status": 422, "code": "INVALID_DATA", "detail": "The request contains invalid data.", "errors": { "to": [ "Expected string" ] } }429Too many requests or a daily quota is used up. See Retry-After
RATE_LIMIT_EXCEEDED429 application/problem+json{ "type": "https://switchfile.io/docs/api/v1#errors-rate-limit-exceeded", "title": "Rate limit exceeded", "status": 429, "code": "RATE_LIMIT_EXCEEDED", "detail": "Too many requests. Try again in 12 seconds." }