API documentation

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 limits

TierMax uploadAPI accessMultipart 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.

Single-PUT upload (≤100 MB)

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

Multipart upload (any size, mandatory >100 MB)

Three steps: init → upload each part → complete.

1. Init

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": "..." }
    ]
  }

2. PUT each part to its upload_url

The 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.

3. Complete

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" }

Abort (optional)

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.

Webhook delivery

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);

Ready-to-use clients

Common errors

StatusMeaningFix
401bad / revoked key Generate a new one under Account → API keys
402tier doesn't allow this (zip on Free, etc.) Upgrade plan
413file or Content-Length over tier cap Use multipart, or upgrade Pro→Ultra for 300 MB
400missing/bad filename, parts, etc. See response body for the specific field
502R2 multipart op failed Retry init; R2 is occasionally flaky for <1% of ops