API documentation
Upload a file once, send it to the file hosts you pick, and get one share link back — from your own code.
Updated
A versioned REST API: upload a file in chunks, send it to the hosts you choose, and every copy is gathered on one share page with live status.
- Base URL
- https://api.mirroruploadx.com/api/v1
- Authentication
- x-api-key: mux_…
1Open a session
POST /
api/ v1/ upload-sessions filename + sizeBytes; get sessionId and chunkSize
2Send chunks
PATCH /
api/ v1/ upload-sessions/ {id}/ chunks raw bytes in order; the reply that completes the file has fileId
3Distribute
POST /
api/ v1/ mirror-tasks/ start fileId + providerSlugs; then poll the job
Create a key on the API keys page. Full walkthrough with code in Upload and distribute.
Authentication
Create a key on the API keys page of your dashboard. The full key (it starts with mux_) is shown only once, so store it right away. Send it in the x-api-key header on every request; Authorization: Bearer mux_… is accepted the same way for clients that only speak bearer tokens.
Keys are scoped: a key only reaches the endpoints its scopes cover, and a call with the wrong scope returns 403 INSUFFICIENT_SCOPE with the needed scope in the message. Account settings, key management and webhooks are not reachable with an API key at all (API_KEY_NOT_ALLOWED).
| Scope | Reaches |
|---|---|
upload:write | Upload sessions (create, chunks, complete, cancel), your upload quota, holding or changing an upload's automatic distribution (hold-distribution, distribution-intent), remote URL uploads, starting distribution |
file:read | Listing files, file details, mirror and job status |
file:write | Share settings on a file |
file:delete | Deleting a file and its mirrors |
Endpoints
Everything an API key can reach, plus the public endpoints that need no key. When a scope column lists two scopes, either one is enough. Request and response schemas for each are in the API reference.
| Method | Path | Scope | What it does |
|---|---|---|---|
| POST | / | upload:write | Open an upload session (optionally with a distribution plan) |
| PATCH | / | upload:write | Send the next chunk of bytes |
| HEAD | / | upload:write | Where to resume: the Upload-Offset header |
| GET | / | upload:writefile:read | Session status: bytes received, fileId, finalizable |
| GET | / | upload:writefile:read | Your upload limits, usage and unfinished sessions |
| POST | / | upload:write | Finish an upload whose final reply was lost (safe to retry) |
| POST | / | upload:write | Stop a deferred distribution from starting on its own |
| PUT | / | upload:write | Replace the distribution plan of an upload |
| DELETE | / | upload:write | Cancel an unfinished upload and free its slot |
| POST | / | upload:write | Fetch files from http(s) URLs into your account |
| POST | / | upload:write | One-request upload for ShareX: send the file, get the share link |
| GET | / | upload:write | The hosts used when you name none (your default selection) |
| POST | / | upload:write | Send a file to the hosts you pick |
| GET | / | upload:writefile:read | Job status, every host and the share link (shareTakenDown flags a removed page) |
| GET | / | file:read | List your files (cursor pagination, search, filters) |
| GET | / | file:read | One file: size, checksum, job, share settings, stats |
| GET | / | file:read | Every copy of a file: host, link, health, clicks |
| PATCH | / | file:write | Share password, expiry, visibility |
| DELETE | / | file:delete | Delete a file and (by default) its copies on hosts |
| GET | / | none (public) | Current limits: largest file, hosts per file, URL upload caps |
| GET | / | none (public) | The host catalogue, with the slugs you send in providerSlugs |
| GET | / | none (public) | Measured upload success per host |
| GET | / | none (public) | Platform totals for the last 30 days: files, live mirrors, success rate |
Upload a file and distribute it
- Open a session with
POST /api/v1/upload-sessions.filenameandsizeBytes(the exact byte length) are required;mimeTypeand a UUIDidempotencyKeyare optional — repeating a request with the same key returns the existing session instead of opening a second one. The reply carriesdata.sessionId(notid) anddata.chunkSize. - Send the bytes with
PATCH /api/v1/upload-sessions/{id}/chunks: raw bytes, content typeapplication/offset+octet-stream, and the chunk's start position in theupload-offsetheader. Chunks go in order, or up tomaxChunksAheadchunks ahead; sending in order, usedata.uploadedBytesfrom each reply as the next offset. Send chunks ofchunkSizebytes; every chunk except the last must be at least 5 MiB, and an upload can have at most 10 000 chunks. The reply that completes the file carriesdata.fileId. For more speed you may keep 2–3 chunks of the same file in flight. Send the first chunk alone; its reply gives the realdata.maxChunksAhead(4 once the first chunk was a wholechunkSizeslice, 0 = in order only). If the first chunk was a wholechunkSizeslice, every later chunk must be one too (in order or ahead): it starts at a multiple ofchunkSizeand is exactlychunkSizebytes (the last one: the rest of the file). A chunk sent ahead ofuploadedBytesmust be such a slice and start at mostdata.maxChunksAheadchunks ahead, otherwise it gets409 CHUNK_MISALIGNEDor409 CHUNK_OUT_OF_WINDOW.uploadedBytescounts only the bytes received without a gap, and whichever chunk completes the file gets the reply withfileId. Re-sending a chunk that already arrived is a harmless success. - Distribute with
POST /api/v1/mirror-tasks/start:fileIdandproviderSlugsare required (slugs come fromGET /api/v1/providers). Optional:minSuccess(default 1 — how many hosts must accept the file for the job not to fail; it iscompletedonly when every host also took it, otherwisepartially_completed. Hosts that refuse this file type are not counted),sharePassword,expiresInDaysorexpiresAt. The reply hasuploadJobId,taskCount,shareSlug,alreadyStartedandskipped[]— a host that cannot take this file is skipped, not failed, so readskipped[](reasons are listed below). One file can go to at most 50 hosts right now. - Watch it finish with
GET /api/v1/mirror-tasks/{uploadJobId}every few seconds untildata.terminalistrue. The reply lists every host intasks[](providerSlug,status,mirrorUrl,errorCode) and the share link indata.shareUrl.data.shareTakenDownistruewhen that share page was taken down and no longer opens.
The largest file accepted right now is 5.00 GB.
bash, needs jq
set -euo pipefail
API=https://api.mirroruploadx.com
FILE=clip.mp4
SIZE=$(wc -c < "$FILE" | tr -d ' ')
# 1. Open an upload session
SESSION_JSON=$(curl -sS --fail-with-body -X POST "$API/api/v1/upload-sessions" \
-H "x-api-key: $MUX_API_KEY" -H "content-type: application/json" \
-d '{"filename":"clip.mp4","sizeBytes":'"$SIZE"',"mimeType":"video/mp4"}')
SESSION=$(echo "$SESSION_JSON" | jq -r .data.sessionId)
CHUNK=$(echo "$SESSION_JSON" | jq -r .data.chunkSize)
# 2. Send the bytes in order, one chunk per request
OFFSET=0
while [ "$OFFSET" -lt "$SIZE" ]; do
dd if="$FILE" of=part.bin bs="$CHUNK" skip=$((OFFSET / CHUNK)) count=1 status=none
REPLY=$(curl -sS --fail-with-body -X PATCH "$API/api/v1/upload-sessions/$SESSION/chunks" \
-H "x-api-key: $MUX_API_KEY" \
-H "upload-offset: $OFFSET" \
-H "content-type: application/offset+octet-stream" \
--data-binary @part.bin)
OFFSET=$(echo "$REPLY" | jq -r .data.uploadedBytes)
done
FILE_ID=$(echo "$REPLY" | jq -r .data.fileId)
# 3. Distribute to the hosts you pick
JOB=$(curl -sS --fail-with-body -X POST "$API/api/v1/mirror-tasks/start" \
-H "x-api-key: $MUX_API_KEY" -H "content-type: application/json" \
-d '{"fileId":"'"$FILE_ID"'","providerSlugs":["gofile","pixeldrain"],"minSuccess":1}' \
| jq -r .data.uploadJobId)
# 4. Poll until the job is terminal, then print the share link
until curl -sS --fail-with-body "$API/api/v1/mirror-tasks/$JOB" \
-H "x-api-key: $MUX_API_KEY" > job.json \
&& [ "$(jq -r .data.terminal job.json)" = "true" ]; do
sleep 5
done
jq -r '.data.status, .data.shareUrl' job.jsonrequests
import os, time, requests
API = "https://api.mirroruploadx.com"
H = {"x-api-key": os.environ["MUX_API_KEY"]}
def call(method, path, headers=None, **kw):
r = requests.request(method, API + path, headers={**H, **(headers or {})}, timeout=120, **kw)
body = r.json()
if not body.get("success"):
err = body["error"]
raise RuntimeError(f'{r.status_code} {err["code"]}: {err["message"]}')
return body["data"]
path = "clip.mp4"
size = os.path.getsize(path)
# 1. Open an upload session
s = call("POST", "/api/v1/upload-sessions",
json={"filename": os.path.basename(path), "sizeBytes": size, "mimeType": "video/mp4"})
session, chunk = s["sessionId"], s["chunkSize"]
# 2. Send the bytes in order; the reply says where to continue
offset, last = 0, None
with open(path, "rb") as f:
while offset < size:
f.seek(offset)
last = call("PATCH", f"/api/v1/upload-sessions/{session}/chunks",
headers={"upload-offset": str(offset),
"content-type": "application/offset+octet-stream"},
data=f.read(chunk))
offset = last["uploadedBytes"]
file_id = last["fileId"]
# 3. Distribute
job = call("POST", "/api/v1/mirror-tasks/start",
json={"fileId": file_id, "providerSlugs": ["gofile", "pixeldrain"], "minSuccess": 1})
for sk in job["skipped"]:
print("skipped", sk["slug"], sk["reason"], sk["detail"])
# 4. Poll until terminal
job_id = job["uploadJobId"]
while True:
st = call("GET", f"/api/v1/mirror-tasks/{job_id}")
if st["terminal"]:
break
time.sleep(5)
print(st["status"], st["shareUrl"])
for t in st["tasks"]:
print(t["providerSlug"], t["status"], t["mirrorUrl"] or t["errorCode"])Node.js 18+, fetch
// Node.js 18+ (global fetch), ES module
import { open, stat } from 'node:fs/promises';
import { basename } from 'node:path';
const API = 'https://api.mirroruploadx.com';
const KEY = process.env.MUX_API_KEY;
async function call(method, path, { json, body, headers = {} } = {}) {
const res = await fetch(API + path, {
method,
headers: { 'x-api-key': KEY, ...(json ? { 'content-type': 'application/json' } : {}), ...headers },
body: json ? JSON.stringify(json) : body,
});
const out = await res.json();
if (!out.success) throw new Error(`${res.status} ${out.error.code}: ${out.error.message}`);
return out.data;
}
const path = 'clip.mp4';
const { size } = await stat(path);
// 1. Open an upload session
const { sessionId, chunkSize } = await call('POST', '/api/v1/upload-sessions', {
json: { filename: basename(path), sizeBytes: size, mimeType: 'video/mp4' },
});
// 2. Send the bytes in order; the reply says where to continue
const fh = await open(path);
let offset = 0;
let last;
while (offset < size) {
const buf = Buffer.alloc(Math.min(chunkSize, size - offset));
await fh.read(buf, 0, buf.length, offset);
last = await call('PATCH', `/api/v1/upload-sessions/${sessionId}/chunks`, {
headers: { 'upload-offset': String(offset), 'content-type': 'application/offset+octet-stream' },
body: buf,
});
offset = last.uploadedBytes;
}
await fh.close();
// 3. Distribute
const job = await call('POST', '/api/v1/mirror-tasks/start', {
json: { fileId: last.fileId, providerSlugs: ['gofile', 'pixeldrain'], minSuccess: 1 },
});
for (const s of job.skipped) console.log('skipped', s.slug, s.reason, s.detail);
// 4. Poll until terminal
let st;
do {
await new Promise((r) => setTimeout(r, 5000));
st = await call('GET', `/api/v1/mirror-tasks/${job.uploadJobId}`);
} while (!st.terminal);
console.log(st.status, st.shareUrl);
for (const t of st.tasks) console.log(t.providerSlug, t.status, t.mirrorUrl ?? t.errorCode);PHP 8.1+, ext-curl
<?php
// PHP 8.1+, built-in ext-curl and ext-json only (no Composer)
declare(strict_types=1);
const API = 'https://api.mirroruploadx.com';
function call(string $method, string $path, ?array $json = null, ?string $body = null, array $headers = []): array
{
$h = ['x-api-key: ' . getenv('MUX_API_KEY'), 'expect:']; // no 100-continue round trip
if ($json !== null) {
$h[] = 'content-type: application/json';
$body = json_encode($json, JSON_THROW_ON_ERROR);
}
foreach ($headers as $k => $v) {
$h[] = "$k: $v";
}
$ch = curl_init(API . $path);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $h,
CURLOPT_RETURNTRANSFER => true,
// no total cap (a large part can take minutes); give up on a stalled transfer instead
CURLOPT_TIMEOUT => 0,
CURLOPT_CONNECTTIMEOUT => 15,
CURLOPT_LOW_SPEED_LIMIT => 1024, // bytes per second
CURLOPT_LOW_SPEED_TIME => 60,
]);
if ($body !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
$raw = curl_exec($ch);
if ($raw === false) {
throw new RuntimeException('network error: ' . curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$out = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
if (empty($out['success'])) {
$err = $out['error'];
throw new RuntimeException("$status {$err['code']}: {$err['message']}");
}
return $out['data'];
}
$path = 'clip.mp4';
$size = filesize($path);
// 1. Open an upload session
$s = call('POST', '/api/v1/upload-sessions',
json: ['filename' => basename($path), 'sizeBytes' => $size, 'mimeType' => 'video/mp4']);
$session = $s['sessionId'];
$chunk = $s['chunkSize'];
// 2. Send the bytes in order, one chunk in memory at a time; the reply says where to continue
$fh = fopen($path, 'rb');
$offset = 0;
$last = null;
while ($offset < $size) {
fseek($fh, $offset);
$last = call('PATCH', "/api/v1/upload-sessions/$session/chunks", body: fread($fh, $chunk), headers: [
'upload-offset' => (string) $offset,
'content-type' => 'application/offset+octet-stream',
]);
$offset = $last['uploadedBytes'];
}
fclose($fh);
$fileId = $last['fileId'];
// 3. Distribute
$job = call('POST', '/api/v1/mirror-tasks/start',
json: ['fileId' => $fileId, 'providerSlugs' => ['gofile', 'pixeldrain'], 'minSuccess' => 1]);
foreach ($job['skipped'] as $sk) {
echo "skipped {$sk['slug']} {$sk['reason']} {$sk['detail']}\n";
}
// 4. Poll until terminal
$jobId = $job['uploadJobId'];
do {
sleep(5);
$st = call('GET', "/api/v1/mirror-tasks/$jobId");
} while (!$st['terminal']);
echo "{$st['status']} {$st['shareUrl']}\n";
foreach ($st['tasks'] as $t) {
echo $t['providerSlug'], ' ', $t['status'], ' ', $t['mirrorUrl'] ?? $t['errorCode'], "\n";
}Example responses
Opening a session answers 201. Every chunk but the last answers { uploadedBytes, completed: false, expiresAt }; the last one carries the file. distribution is there only when you passed a plan when opening the session (see below). Each chunk reply also carries maxChunksAhead: how many whole chunks past uploadedBytes you may send right now (0 = in order only). Read it from every reply instead of assuming a number. Every expiresAt the API returns is a full ISO 8601 date-time in UTC ending in Z, for example 2027-01-31T23:59:59.000Z.
{
"success": true,
"data": {
"sessionId": "…",
"uploadedBytes": 0,
"chunkSize": 8388608,
"maxChunksAhead": 0
}
}{
"success": true,
"data": {
"uploadedBytes": 10485760,
"completed": true,
"fileId": "…",
"scan": "skipped",
"distributable": true,
"distribution": {
"started": true,
"uploadJobId": "…",
"taskCount": 2,
"shareSlug": "…",
"skipped": []
}
}
}{
"success": true,
"data": {
"uploadJobId": "…",
"taskCount": 2,
"shareSlug": "…",
"skipped": [],
"alreadyStarted": false
}
}{
"success": true,
"data": {
"uploadJobId": "…",
"status": "completed",
"terminal": true,
"shareSlug": "…",
"shareUrl": "https://mirroruploadx.com/f/…",
"shareTakenDown": false,
"minSuccess": 1,
"scan": "skipped",
"tasks": [
{
"provider": "Gofile",
"providerSlug": "gofile",
"status": "succeeded",
"attempts": 1,
"errorCode": null,
"viaOwnAccount": false,
"errorMessage": null,
"mirrorUrl": "https://gofile.io/d/…",
"mirrorHidden": false
},
{
"provider": "Pixeldrain",
"providerSlug": "pixeldrain",
"status": "succeeded",
"attempts": 1,
"errorCode": null,
"viaOwnAccount": false,
"errorMessage": null,
"mirrorUrl": "https://pixeldrain.com/u/…",
"mirrorHidden": false
}
]
}
}A first, successful start answers 202; calling it again for a job that is already running answers 200 with alreadyStarted: true. When a host's link is kept private by policy, mirrorUrl is null and mirrorHidden is true — the share page still lists it.
Skip the second call
Pass distribution when you open the session and the server starts distributing as soon as the file is complete. Check data.distribution in the reply that completes the file: started: true means the job is queued (uploadJobId, shareSlug). With started: false and deferred: true nothing is queued yet on purpose — see below. With started: false and no deferred, the upload still succeeded but the distribution could not start (error says why): call POST /api/v1/mirror-tasks/start with the fileId. An error together with deferred: true means a temporary failure (for example, every host is busy or in maintenance): do not call start or upload the file again — the server will retry starting the distribution itself from autoStartAt (up to 5 attempts). Call hold-distribution to stop it.
curl -sS -X POST "https://api.mirroruploadx.com/api/v1/upload-sessions" \
-H "x-api-key: $MUX_API_KEY" -H "content-type: application/json" \
-d '{
"filename": "clip.mp4",
"sizeBytes": 10485760,
"mimeType": "video/mp4",
"distribution": { "providerSlugs": ["gofile", "pixeldrain"], "minSuccess": 1 }
}'
# The reply to the final chunk then carries data.distribution:
# { "started": true, "uploadJobId": "…", "taskCount": 2, "shareSlug": "…", "skipped": [] }
# or { "started": false, "error": { "code": "…", "message": "…" } }Add deferred: true to distribution for a grace period: the final reply is { started: false, deferred: true, autoStartAt } and the server starts the distribution itself at autoStartAt (about 2 minutes later) unless you call start first. To stop the automatic start, call POST /api/v1/upload-sessions/{id}/hold-distribution (no body; autoStartAt becomes null and you start it yourself). To change the plan instead, call PUT /api/v1/upload-sessions/{id}/distribution-intent with the same fields as distribution (providerSlugs, minSuccess, expiresInDays, sharePassword): it replaces the plan and lifts a hold, and once the upload has finished the automatic start moves to at least 2 minutes after the call. If the distribution has already started, both reply 200 and distribution-intent says alreadyStarted: true.
Start within 30 minutes. When an upload finishes and no distribution is started, our copy of the file is removed after 30 minutes (with a distribution plan still waiting for hosts to become available, after at most 72 hours; remote URL uploads are not affected). After that, start and distribution-intent answer 409 SOURCE_GONE and the file has to be uploaded again.
If the final reply is lost
Call GET /api/v1/upload-sessions/{id}: a fileId means the file exists; finalizable: true means every byte arrived and POST /api/v1/upload-sessions/{id}/complete finishes it. That call is safe to retry and never creates a second file. A mismatched offset gets 409 CHUNK_OFFSET_CONFLICT — send HEAD on the session and resume from its Upload-Offset header. Calling start again for a running job is not an error: you get 200 with alreadyStarted: true.
Upload from a URL
POST /api/v1/remote-uploads takes { "urls": [...] } and fetches each file for you (scope upload:write). Only http and https links are fetched, private network addresses are refused, and only a limited number of redirects is followed. One request carries at most 10 URLs (returned by GET /api/v1/platform); split longer lists.
The size limit per file depends on the source. When it reports the file's size, each file can be up to 5.00 GB (limits.remoteUploadPassthroughMaxBytes); when it does not, up to 100.0 MB (limits.remoteUploadMaxBytes). The file name comes from the source's Content-Disposition header when it sends one; a name without an extension gets one from the file's type.
The request waits while the files download. If the connection drops first, the file still lands in your account — find it with GET /api/v1/files. Each fileId is then distributed with POST /api/v1/mirror-tasks/start, as above. Or add distribution to the request (the same fields as when opening a session: providerSlugs, minSuccess, expiresInDays, sharePassword): each file is then distributed as soon as its download finishes, even if the connection drops. Each entry of results[] then carries distribution: started: true with uploadJobId, taskCount, shareSlug and skipped[], or started: false with error (code, message) — the file is still in your account, so call POST /api/v1/mirror-tasks/start with its fileId. An entry with ok: false carries code and error; those codes are in the error table.
When the service is busy, the whole request gets 503 TEMPORARILY_UNAVAILABLE with details.reason: "staging_full" and a Retry-After header; details.reason: "owner_staging_full" means too many of your earlier files are still being distributed — retry after a few minutes. If only one URL does not fit, that entry in results[] has ok: false and the same code; a per-URL result has no header, so the wait in seconds is in details.retryAfter.
curl -sS -X POST "https://api.mirroruploadx.com/api/v1/remote-uploads" \
-H "x-api-key: $MUX_API_KEY" -H "content-type: application/json" \
-d '{"urls":["https://example.com/files/archive.zip"]}'
# One result per URL, in order. A failed URL does not fail the batch:
# {"success":true,"data":{"results":[
# {"url":"https://example.com/files/archive.zip","ok":true,
# "fileId":"…","scan":…,"distributable":true}
# ]}}
# or {"url":"…","ok":false,"code":"REMOTE_TOO_LARGE","error":"…"}
#
# Then distribute each fileId with POST /api/v1/mirror-tasks/start.PHP 8.1+, ext-curl
<?php
// PHP 8.1+, built-in ext-curl and ext-json only (no Composer)
$ch = curl_init('https://api.mirroruploadx.com/api/v1/remote-uploads');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['x-api-key: ' . getenv('MUX_API_KEY'), 'content-type: application/json'],
CURLOPT_POSTFIELDS => json_encode(['urls' => ['https://example.com/files/archive.zip']], JSON_THROW_ON_ERROR),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 0, // the request waits while the files download
]);
$raw = curl_exec($ch);
if ($raw === false) {
throw new RuntimeException('network error: ' . curl_error($ch));
}
$out = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
if (empty($out['success'])) {
throw new RuntimeException("{$out['error']['code']}: {$out['error']['message']}");
}
// One result per URL, in order. A failed URL does not fail the batch.
foreach ($out['data']['results'] as $r) {
echo $r['ok']
? "{$r['url']} -> {$r['fileId']}\n"
: "{$r['url']} failed: {$r['code']} {$r['error']}\n";
}
// Then distribute each fileId with POST /api/v1/mirror-tasks/start.Manage files
Your files stay in your account after the upload. List them with GET /api/v1/files (limit up to 100; pass the reply's nextCursor as cursor for the next page, q searches by name). GET /api/v1/files/{id} returns one file with its job, share settings and view stats; GET /api/v1/files/{id}/mirrors lists every copy with its link, health and clicks.
PATCH /api/v1/files/{id}/share (scope file:write) changes the share page: password (4–128 characters, null removes it — it is never returned, only passwordProtected), expiresAt (ISO date, null for no expiry), visibility and hideDownloadCount. Send only the fields you want to change. DELETE /api/v1/files/{id} (scope file:delete) removes the file and queues its copies on hosts for deletion; add ?keepMirrors=true to keep them. Some hosts do not support deletion, so a copy may remain there. Send expiresAt as a full ISO 8601 date-time in UTC ending in Z, for example 2027-01-31T23:59:59Z.
bash, needs jq; set FILE_ID
API=https://api.mirroruploadx.com
H="x-api-key: $MUX_API_KEY"
# List your files, newest first (20 per page; pass ?cursor=<nextCursor> for more)
curl -sS "$API/api/v1/files?limit=20" -H "$H" | jq '.data.items[] | {id, name, mirrorCount, shareSlug}'
# One file, then every copy of it
curl -sS "$API/api/v1/files/$FILE_ID" -H "$H"
curl -sS "$API/api/v1/files/$FILE_ID/mirrors" -H "$H" | jq '.data.mirrors[] | {providerSlug, status, url}'
# Share settings: a password and an expiry date (null removes either)
curl -sS -X PATCH "$API/api/v1/files/$FILE_ID/share" -H "$H" -H "content-type: application/json" \
-d '{"password":"correct-horse","expiresAt":"2026-12-31T23:59:59Z"}'
# Delete the file and its copies on hosts (?keepMirrors=true keeps the copies)
curl -sS -X DELETE "$API/api/v1/files/$FILE_ID" -H "$H"requests; set FILE_ID
import os, requests
API = "https://api.mirroruploadx.com"
H = {"x-api-key": os.environ["MUX_API_KEY"]}
file_id = os.environ["FILE_ID"]
def call(method, path, **kw):
body = requests.request(method, API + path, headers=H, timeout=60, **kw).json()
if not body.get("success"):
raise RuntimeError(f'{body["error"]["code"]}: {body["error"]["message"]}')
return body["data"]
# List your files, page by page
cursor = None
while True:
page = call("GET", "/api/v1/files", params={"limit": 100, **({"cursor": cursor} if cursor else {})})
for f in page["items"]:
print(f["id"], f["name"], f"{f['mirrorCount']}/{f['mirrorTotal']} mirrors")
cursor = page["nextCursor"]
if not cursor:
break
# One file, then every copy of it
print(call("GET", f"/api/v1/files/{file_id}")["share"])
for m in call("GET", f"/api/v1/files/{file_id}/mirrors")["mirrors"]:
print(m["providerSlug"], m["status"], m["url"])
# Share settings: a password and an expiry date (None removes either)
print(call("PATCH", f"/api/v1/files/{file_id}/share",
json={"password": "correct-horse", "expiresAt": "2026-12-31T23:59:59Z"}))
# Delete the file and its copies on hosts
print(call("DELETE", f"/api/v1/files/{file_id}")["note"])Node.js 18+, ES module; set FILE_ID
const API = 'https://api.mirroruploadx.com';
const KEY = process.env.MUX_API_KEY;
const fileId = process.env.FILE_ID;
async function call(method, path, json) {
const res = await fetch(API + path, {
method,
headers: { 'x-api-key': KEY, ...(json ? { 'content-type': 'application/json' } : {}) },
body: json ? JSON.stringify(json) : undefined,
});
const out = await res.json();
if (!out.success) throw new Error(`${res.status} ${out.error.code}: ${out.error.message}`);
return out.data;
}
// List your files, page by page
let cursor = null;
do {
const page = await call('GET', `/api/v1/files?limit=100${cursor ? `&cursor=${cursor}` : ''}`);
for (const f of page.items) console.log(f.id, f.name, `${f.mirrorCount}/${f.mirrorTotal} mirrors`);
cursor = page.nextCursor;
} while (cursor);
// One file, then every copy of it
console.log((await call('GET', `/api/v1/files/${fileId}`)).share);
for (const m of (await call('GET', `/api/v1/files/${fileId}/mirrors`)).mirrors) {
console.log(m.providerSlug, m.status, m.url);
}
// Share settings: a password and an expiry date (null removes either)
console.log(await call('PATCH', `/api/v1/files/${fileId}/share`, {
password: 'correct-horse',
expiresAt: '2026-12-31T23:59:59Z',
}));
// Delete the file and its copies on hosts
console.log((await call('DELETE', `/api/v1/files/${fileId}`)).note);PHP 8.1+, ext-curl; set FILE_ID
<?php
// PHP 8.1+, built-in ext-curl and ext-json only (no Composer)
declare(strict_types=1);
const API = 'https://api.mirroruploadx.com';
$fileId = getenv('FILE_ID');
function call(string $method, string $path, ?array $json = null, ?string $body = null, array $headers = []): array
{
$h = ['x-api-key: ' . getenv('MUX_API_KEY'), 'expect:']; // no 100-continue round trip
if ($json !== null) {
$h[] = 'content-type: application/json';
$body = json_encode($json, JSON_THROW_ON_ERROR);
}
foreach ($headers as $k => $v) {
$h[] = "$k: $v";
}
$ch = curl_init(API . $path);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $h,
CURLOPT_RETURNTRANSFER => true,
// no total cap (a large part can take minutes); give up on a stalled transfer instead
CURLOPT_TIMEOUT => 0,
CURLOPT_CONNECTTIMEOUT => 15,
CURLOPT_LOW_SPEED_LIMIT => 1024, // bytes per second
CURLOPT_LOW_SPEED_TIME => 60,
]);
if ($body !== null) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
$raw = curl_exec($ch);
if ($raw === false) {
throw new RuntimeException('network error: ' . curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$out = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
if (empty($out['success'])) {
$err = $out['error'];
throw new RuntimeException("$status {$err['code']}: {$err['message']}");
}
return $out['data'];
}
// List your files, page by page (http_build_query drops a null cursor)
$cursor = null;
do {
$page = call('GET', '/api/v1/files?' . http_build_query(['limit' => 100, 'cursor' => $cursor]));
foreach ($page['items'] as $f) {
echo "{$f['id']} {$f['name']} {$f['mirrorCount']}/{$f['mirrorTotal']} mirrors\n";
}
$cursor = $page['nextCursor'];
} while ($cursor);
// One file, then every copy of it
print_r(call('GET', "/api/v1/files/$fileId")['share']);
foreach (call('GET', "/api/v1/files/$fileId/mirrors")['mirrors'] as $m) {
echo "{$m['providerSlug']} {$m['status']} {$m['url']}\n";
}
// Share settings: a password and an expiry date (null removes either)
print_r(call('PATCH', "/api/v1/files/$fileId/share",
json: ['password' => 'correct-horse', 'expiresAt' => '2026-12-31T23:59:59Z']));
// Delete the file and its copies on hosts
echo call('DELETE', "/api/v1/files/$fileId")['note'], "\n";{
"success": true,
"data": {
"stagingDeleted": true,
"mirrorsQueued": true,
"mirrorsPurgeDeferred": false,
"note": "File removed. Copies on providers are being deleted; some may remain on providers that do not support deletion."
}
}Webhooks
Add an endpoint on the Webhooks page. The URL must use https://; its signing secret (whsec_…) is shown once, when you create it. An endpoint with no events selected receives all of them.
| Event | When |
|---|---|
upload.completed | Every host accepted the file, and at least minSuccess did — hosts that refused this file (rejected) or were cancelled are not counted |
upload.partially_completed | At least minSuccess hosts accepted the file, but at least one other host failed |
upload.failed | Fewer than minSuccess hosts accepted the file (minSuccess 0 counts as 1) |
upload.quarantined | The malware scan flagged the file (only when scanning is enabled) |
provider.upload_succeeded | One host accepted the file — sent once per host |
provider.upload_failed | One host gave up on the file — sent once per host |
webhook.test | You pressed Test on the Webhooks page |
Each delivery is one POST with a JSON body and the headers X-MUX-Event and X-MUX-Signature. Any 2xx answer within 10 seconds counts as delivered; redirects are not followed. A failed delivery (network error, timeout, 408, 425, 429 or 5xx) is retried after 1, 5 and 30 minutes with the same body; other 4xx and redirects are not. Each try carries X-MUX-Delivery-Attempt (1–4) and a fresh signature, so deduplicate on the body. Delivery order is not guaranteed (a retried event can arrive after a newer one); compare data and createdAt before acting on it. Use GET /api/v1/mirror-tasks/{uploadJobId} to catch up. After 15 deliveries in a row whose last try failed, or an hour of failures without a single success, the endpoint is paused; turning it back on resets the count. A webhook.test delivery (the Test button) is sent once, with X-MUX-Delivery-Attempt: 1, and is never retried.
{
"event": "provider.upload_succeeded",
"createdAt": "2026-09-25T12:00:00.000Z",
"data": {
"uploadJobId": "…",
"fileId": "…",
"provider": "gofile",
"providerName": "Gofile",
"status": "succeeded",
"mirrorUrl": "https://…"
}
}upload.* events carry uploadJobId, fileId and status; provider.upload_failed carries errorCode instead of mirrorUrl. provider.upload_succeeded carries mirrorUrl; when that host's link is kept private by policy, mirrorUrl is null and mirrorHidden is true.
Verifying the signature
The header looks like t=1727265600,v1=5f2b…: t is the signing time in Unix seconds, v1 is the hex HMAC-SHA256 of <t>.<raw body> keyed with your endpoint secret. Hash the raw bytes exactly as received, compare in constant time, and reject timestamps more than 5 minutes old.
Express
import express from 'express';
import { createHmac, timingSafeEqual } from 'node:crypto';
function verify(rawBody, header, secret, toleranceSec = 300) {
const parts = Object.fromEntries(
header.split(',').map((kv) => {
const i = kv.indexOf('=');
return [kv.slice(0, i).trim(), kv.slice(i + 1).trim()];
}),
);
const t = Number(parts.t);
if (!Number.isFinite(t) || !parts.v1) return false;
if (Math.abs(Date.now() / 1000 - t) > toleranceSec) return false; // too old: replay
const expected = createHmac('sha256', secret).update(`${parts.t}.`).update(rawBody).digest();
const got = Buffer.from(parts.v1, 'hex');
return got.length === expected.length && timingSafeEqual(got, expected);
}
const app = express();
// Raw bytes, not parsed JSON: the signature covers the body exactly as sent.
app.post('/hooks/mirroruploadx', express.raw({ type: 'application/json' }), (req, res) => {
if (!verify(req.body, req.get('x-mux-signature') ?? '', process.env.MUX_WEBHOOK_SECRET)) {
return res.sendStatus(401);
}
const { event, data } = JSON.parse(req.body);
console.log(event, data.uploadJobId);
res.sendStatus(204); // any 2xx counts as delivered
});
app.listen(3000);Flask
import hashlib, hmac, os, time
from flask import Flask, abort, request
def verify(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
parts = dict(kv.strip().split("=", 1) for kv in header.split(",") if "=" in kv)
t, v1 = parts.get("t", ""), parts.get("v1", "")
if not t.isdigit() or not v1 or abs(time.time() - int(t)) > tolerance:
return False
expected = hmac.new(secret.encode(), t.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, v1)
app = Flask(__name__)
@app.post("/hooks/mirroruploadx")
def hook():
# get_data(): the raw bytes, exactly as signed
if not verify(request.get_data(), request.headers.get("X-MUX-Signature", ""),
os.environ["MUX_WEBHOOK_SECRET"]):
abort(401)
payload = request.get_json()
print(payload["event"], payload["data"].get("uploadJobId"))
return "", 204 # any 2xx counts as deliveredplain PHP 8.1+
<?php
// Plain PHP 8.1+ endpoint, e.g. public/hooks/mirroruploadx.php
declare(strict_types=1);
function verify(string $rawBody, string $header, string $secret, int $tolerance = 300): bool
{
$parts = [];
foreach (explode(',', $header) as $kv) {
[$k, $v] = array_pad(explode('=', $kv, 2), 2, '');
$parts[trim($k)] = trim($v);
}
$t = $parts['t'] ?? '';
$v1 = $parts['v1'] ?? '';
if (!ctype_digit($t) || $v1 === '' || abs(time() - (int) $t) > $tolerance) {
return false; // malformed, or too old: replay
}
$expected = hash_hmac('sha256', "$t.$rawBody", $secret);
return hash_equals($expected, $v1);
}
// php://input: the raw bytes, exactly as signed (not $_POST, not re-encoded JSON)
$raw = file_get_contents('php://input');
if (!verify($raw, $_SERVER['HTTP_X_MUX_SIGNATURE'] ?? '', (string) getenv('MUX_WEBHOOK_SECRET'))) {
http_response_code(401);
exit;
}
$payload = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
error_log($payload['event'] . ' ' . ($payload['data']['uploadJobId'] ?? ''));
http_response_code(204); // any 2xx counts as deliveredRate limits
Limits are counted per API key, not per IP address. Every response on a limited endpoint carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (epoch seconds). Going over returns 429 RATE_LIMITED with a Retry-After header — wait that many seconds. Chunk uploads get a wide budget; the narrow limits are on opening sessions and starting distributions.
| Bucket | Endpoints | Per key | Window |
|---|---|---|---|
| Starting uploads | POST /POST /DELETE / | 60 | 1 minute |
| Uploading chunks | PATCH / | 600 | 1 minute |
| Polling progress | GET /HEAD /GET /GET /GET / | 600 | 1 minute |
| Distribution settings for an upload | POST /PUT / | 300 | 1 minute |
| Starting distribution | POST /POST / | 30 | 1 minute |
| Remote (URL) uploads | POST / | 20 | 10 minutes |
| Reading files | GET /GET /GET / | 300 | 1 minute |
| Changing files | PATCH /DELETE / | 60 | 1 minute |
| Public catalogue | GET /GET /GET /GET / | 300 | 1 minute |
These are the default numbers. The operator can change them, so the headers above are always the source of truth. The exact numbers for your keys, and how much of each you have used right now, are on the API keys page. Requests without a key are counted per IP address and get smaller budgets for starting uploads (10 instead of 60), uploading chunks (300 instead of 600), polling progress (300 instead of 600), distribution settings for an upload (60 instead of 300), starting distribution (10 instead of 30), and the same budget for remote (URL) uploads and public catalogue. Reading files and changing files always need a key.
Errors
Successful replies are { "success": true, "data": … }. Errors use one shape, next to the HTTP status. code is stable — branch on it; message is for people and may change. details is added when there is more context, retryable says whether trying the same request again can help, and requestId helps us find your request if you contact support.
{
"success": false,
"error": {
"code": "INSUFFICIENT_SCOPE",
"message": "This endpoint needs one of these API key scopes: upload:write.",
"requestId": "…",
"retryable": false
}
}| Code | HTTP | Retry? | Meaning |
|---|---|---|---|
NO_TOKEN | 401 | No | No API key was sent |
INVALID_API_KEY | 401 | No | The key is wrong or revoked |
INSUFFICIENT_SCOPE | 403 | No | The key lacks the scope this endpoint needs |
API_KEY_NOT_ALLOWED | 403 | No | This endpoint cannot be used with an API key |
EMAIL_NOT_VERIFIED | 403 | No | Verify the account email first; open sessions keep working |
SESSION_REVOKED | 401 | No | The sign-in session was ended (password reset or change, sign-out); sign in again |
ACCOUNT_INACTIVE | 403 | No | The account is suspended or scheduled for deletion |
ACCOUNT_DISABLED | 401 / 409 | No | The account was suspended: 401 on the key check, 409 if it changed while the request was running |
ACCOUNT_PENDING_DELETION | 409 | No | The account became scheduled for deletion while the request was running; nothing new is started |
VALIDATION_ERROR | 400 | No | The body or a parameter is invalid; see details |
FILE_REJECTED | 400 | No | The file type or size is not allowed; details.reason says which |
TOO_MANY_MIRRORS | 400 | No | More hosts than one file may have |
NO_CONNECTED_PROVIDERS | 400 | No | Every selected host needs your own account and none is connected |
PROVIDER_REJECTS_FILE | 400 | No | No selected host accepts this file type or size |
NO_AVAILABLE_PROVIDERS | 400 | No | None of the selected hosts is taking uploads right now; pick others or try later. `details.waiting` lists hosts that are only paused, and `details.retryAt` (ISO time) says when the first of them is expected to accept uploads again: retrying after that works even though `retryable` is false |
NO_VALID_PROVIDERS | 400 | No | No providerSlugs value matches an enabled host; see GET /api/v1/providers |
INVALID_JOB_STATE | 400 | No | The job cannot be started in its current state |
JOB_NOT_READY | 400 | No | The file has no distribution job yet |
FILE_TOO_LARGE_FOR_UPLOAD | 400 | No | The file cannot fit in 10 000 chunks of the session chunk size; details.limitBytes |
MISSING_OFFSET | 400 | No | A chunk was sent without a numeric upload-offset header |
RAW_BODY_REQUIRED | 400 | No | A chunk body must be raw bytes with content-type application/offset+octet-stream |
TOO_MANY_URLS | 400 | No | More URLs in one remote-uploads request than allowed |
FILE_NOT_FOUND | 404 | No | No such file in your account (or it was deleted) |
JOB_NOT_FOUND | 404 | No | No such distribution job in your account |
SESSION_NOT_FOUND | 404 | No | No such upload session in your account |
SHARE_NOT_FOUND | 404 | No | The file has no share page yet |
QUOTA_EXCEEDED | 409 | No | A daily or concurrent upload limit; details.retryAt says when it frees up |
CHUNK_OFFSET_CONFLICT | 409 | No | upload-offset does not match the bytes received; resume from HEAD |
CHUNK_TOO_SMALL | 409 | No | A chunk other than the last is under 5 MiB |
CHUNK_TOO_MANY_PARTS | 409 | No | More than 10 000 chunks; send larger ones |
CHUNK_MISALIGNED | 409 | No | The chunk is not a whole chunkSize slice starting at a multiple of chunkSize: required for a chunk sent ahead and, if the first chunk was a whole chunkSize slice, for every later chunk too (in order or ahead); or a chunk was sent ahead in a session that takes chunks only in order |
CHUNK_OUT_OF_WINDOW | 409 | No | A chunk starts more than maxChunksAhead chunks past uploadedBytes, or past it at all before the first chunk has been accepted; send it again after the earlier ones |
CHUNK_EXCEEDS_DECLARED_SIZE | 409 | No | The chunk goes past the file size declared when the session was created |
CHUNK_EMPTY | 409 | No | The chunk has no bytes |
CHUNK_NOT_RECEIVABLE | 409 | No | The session no longer takes data (it was completed, cancelled or has expired); open a new one |
SESSION_EXPIRED | 409 | No | The upload session expired; open a new one |
SESSION_NOT_RECEIVABLE | 409 | No | The session was cancelled or expired and takes no more changes |
SESSION_COMPLETED | 409 | No | The upload already finished; delete the file instead |
UPLOAD_INCOMPLETE | 409 | No | Not every byte has arrived; send the remaining chunks first (details has the counts) |
IDEMPOTENCY_KEY_CONFLICT | 409 | No | This idempotencyKey is already used by another upload; use a unique key per upload |
SOURCE_GONE | 409 | No | Our copy of the file was already removed, so it cannot be sent to hosts it has not been tried on; upload it again for those. Our copy is removed as soon as a distribution job finishes (completed, partially completed or failed), and an upload whose distribution is never started is removed 30 minutes after it finishes (up to 72 hours when its distribution plan is still waiting for hosts; remote URL uploads excepted). Calling mirror-tasks/start again for a finished job with only hosts it already tried just applies the share settings (alreadyStarted: true) |
JOB_NOT_DISTRIBUTABLE | 409 | No | The job failed, was cancelled or is in a state that can no longer be distributed |
SHARE_TAKEN_DOWN | 409 | No | The file's share page was taken down, so it cannot be sent to more hosts |
FINALIZING | 409 | Yes | Another request is assembling the file; ask again in a few seconds |
CONFLICT | 409 | Yes | Collided with another change in progress; retry the same request |
TEMPORARILY_UNAVAILABLE | 503 | Yes, after Retry-After | The server is busy right now; retry after the Retry-After delay. details.reason "staging_full": the service is busy and no new upload was accepted (Retry-After about 10 minutes); "owner_staging_full": too many of your earlier files are still being distributed — retry in a few minutes. Uploads already in progress keep working |
PAYLOAD_TOO_LARGE | 413 | No | The request body (or one chunk) is larger than the server accepts |
REMOTE_TOO_LARGE | per URL | No | In a remote-uploads result: the file is over the URL upload limit |
REMOTE_REJECTED | per URL | No | In a remote-uploads result: the URL was refused |
REMOTE_HTTP_ERROR | per URL | No | In a remote-uploads result: the source answered with an HTTP error |
REMOTE_NOT_A_FILE | per URL | No | In a remote-uploads result: the link returns a web page, not a file; use a direct file link |
REMOTE_TIMEOUT | per URL | No | In a remote-uploads result: the source did not answer, or the download took too long |
REMOTE_TOO_SLOW | per URL | No | In a remote-uploads result: the source sent data too slowly to finish the download |
REMOTE_UNREACHABLE | per URL | No | In a remote-uploads result: the source could not be reached or closed the connection |
REMOTE_TLS_ERROR | per URL | No | In a remote-uploads result: the source's HTTPS certificate could not be verified |
REMOTE_EMPTY | per URL | No | In a remote-uploads result: the source returned an empty file |
REMOTE_IN_PROGRESS | per URL | No | In a remote-uploads result: the same link is still being downloaded for you; try again in a moment |
REMOTE_FAILED | per URL | No | In a remote-uploads result: the download failed for another reason |
DISTRIBUTION_FAILED | per URL | No | In `distribution.error` of a remote-uploads result or of the reply that completes an upload: the file was saved but its distribution could not start; call mirror-tasks/start with its fileId |
RATE_LIMITED | 429 | Yes, after Retry-After | Too many requests for this bucket |
INTERNAL_ERROR | 500 | Yes | Server error; details are logged, never returned |
MAINTENANCE | 503 | Yes, after Retry-After | New uploads are paused for now; reads keep working |
UPLOADS_TEMPORARILY_UNAVAILABLE | 503 | Yes, after Retry-After | Our upload counter could not be read; no session was opened |
SHUTTING_DOWN | 503 | Yes, after Retry-After | The server is restarting (Retry-After 5 seconds); wait and send the same request again — nothing was processed |
Why a host was skipped
These are not errors: they arrive in skipped[].reason of a successful start (and of distribution in the reply that completes the file). The other hosts still get the file. Only when no selected host can take it does the call fail: PROVIDER_REJECTS_FILE (none accepts this file), NO_CONNECTED_PROVIDERS (every one needs your own account), NO_AVAILABLE_PROVIDERS (none is taking uploads right now) or NO_VALID_PROVIDERS (no slug matches an enabled host).
| Reason | Meaning |
|---|---|
UNKNOWN_PROVIDER | No host with this slug exists — check the spelling against GET /api/v1/providers |
PROVIDER_DISABLED | The host is turned off or in maintenance right now |
ACCOUNT_REQUIRED | The host only takes uploads to your own account — connect it on the Connections page |
GUEST_UPLOAD_OFF | The host is not taking uploads right now and cannot be connected to an account |
DAILY_LIMIT_REACHED | The host's daily limit for uploads without an account is used up for now (up to 24 h) — connect your own account for it to upload anyway |
FILE_TOO_LARGE | The file is over this host's size limit |
MIME_NOT_ALLOWED | The host does not accept this file type |
ALREADY_ATTEMPTED | This host was already tried for this file, so it is not sent there again |
ACCOUNT_STORAGE_FULL | Your own connected account on this host does not have enough free space for this file — free up space there and upload again |
The API reference lists the codes each endpoint can return.