Programmatic encoding for Ultra subscribers. Generate
a key under Account → API keys, then call the
endpoints below with Authorization implicit in the URL path.
| Tier | Max upload | API access | Multipart needed? |
|---|---|---|---|
| Free | 5 KB | — | — |
| Pro | 100 MB | — | No (single PUT fits) |
| Ultra | 300 MB | Yes | For files >100 MB |
Cloudflare's edge caps a single request body at 100 MB. Files larger than that must be split into 50 MB parts and uploaded via the multipart endpoints below.
POST https://webhook.binaryphp.com/upload/<api_key>
X-BPHP-Filename: plugin.php # required, .php or .zip
X-BPHP-Domain: app.example.com,*.example.com
X-BPHP-Mac: aa:bb:cc:dd:ee:ff # optional
X-BPHP-Expire: 2027-12-31 # optional
X-BPHP-Webhook: https://you.example.com/wh # optional async notify
<file bytes as request body>
→ 200 {
"job_id": "...",
"download_url": "https://...presigned R2 URL...",
"expires_at": "2026-05-09T...",
"size": 12345,
"license": { "domains": [...], ... }
}
curl one-liner:
curl -X POST https://webhook.binaryphp.com/upload/$API_KEY \
-H "X-BPHP-Filename: plugin.php" \
-H "X-BPHP-Domain: app.example.com" \
--data-binary @plugin.php
Three steps: init → upload each part → complete.
POST https://webhook.binaryphp.com/upload/<api_key>/init
X-BPHP-Filename: bigplugin.zip
X-BPHP-Total-Size: 200000000
→ 200 {
"job_id": "...",
"upload_id": "...", # opaque R2 multipart id
"r2_key": "uploads/<job_id>.zip",
"part_size": 52428800, # 50 MB recommended
"part_count": 4,
"max_part_size": 104857600, # 100 MB hard cap
"parts": [
{ "part_no": 1, "upload_url": "https://...presigned PUT..." },
{ "part_no": 2, "upload_url": "..." },
{ "part_no": 3, "upload_url": "..." },
{ "part_no": 4, "upload_url": "..." }
]
}
upload_urlThe presigned URLs are R2 directly — no Worker bandwidth.
Each PUT response carries an ETag header that you
must capture and include in complete:
PUT <upload_url>
<part_size bytes of file at offset (part_no-1)*part_size>
← 200 OK
ETag: "abc123def456..."
Each part body must be ≥5 MB (except the last) and ≤100 MB.
POST https://webhook.binaryphp.com/upload/<api_key>/complete
Content-Type: application/json
{
"upload_id": "...",
"r2_key": "uploads/<job_id>.zip",
"filename": "bigplugin.zip",
"parts": [
{ "part_no": 1, "etag": "\"abc...\"" },
{ "part_no": 2, "etag": "\"def...\"" },
{ "part_no": 3, "etag": "\"ghi...\"" },
{ "part_no": 4, "etag": "\"jkl...\"" }
],
"domain": "app.example.com",
"mac": "",
"expire": "2027-12-31",
"plugin": "",
"webhook": ""
}
→ 200 { "job_id", "download_url", "expires_at", "size", "license" }
If a part upload fails midway, call /upload/<api_key>/abort
with { upload_id, r2_key } so the partial parts don't
linger in your R2 storage bill.
Set X-BPHP-Webhook (or "webhook" in the
complete body) to receive encode.completed notifications.
Delivery comes from a Cloudflare edge IP, not our origin. The body is
HMAC-SHA256 signed using your API key as the shared secret:
POST <your webhook URL>
X-BinaryPHP-Signature: t=1736208000,v1=<hex>
X-BinaryPHP-Event: encode.completed
Content-Type: application/json
{
"event": "encode.completed",
"job_id": "...",
"download_url": "...",
"expires_at": "...",
"size": 12345,
"license": { ... }
}
Verification (PHP):
$sig_h = $_SERVER['HTTP_X_BINARYPHP_SIGNATURE'] ?? '';
[$tpart, $vpart] = array_pad(explode(',', $sig_h, 2), 2, '');
$ts = (int) substr($tpart, 2);
$got = substr($vpart, 3);
if (abs(time() - $ts) > 300) http_response_code(401);
$body = file_get_contents('php://input');
$expected = hash_hmac('sha256', "$ts.$body", $YOUR_API_KEY);
if (!hash_equals($expected, $got)) http_response_code(401);
ext-curl
only. Auto-detects file size; single-PUT for ≤100 MB, multipart otherwise.
Aborts the R2 multipart on partial failure so you don't get charged for
orphan parts.
API_KEY=bphp_live_xxx php upload.php big.zip --domain=app.example.com
requests only. Same auto-detect + abort logic.
| Status | Meaning | Fix |
|---|---|---|
| 401 | bad / revoked key | Generate a new one under Account → API keys |
| 402 | tier doesn't allow this (zip on Free, etc.) | Upgrade plan |
| 413 | file or Content-Length over tier cap | Use multipart, or upgrade Pro→Ultra for 300 MB |
| 400 | missing/bad filename, parts, etc. | See response body for the specific field |
| 502 | R2 multipart op failed | Retry init; R2 is occasionally flaky for <1% of ops |