Upload & Process
Error Handling
AntCDN APIs use standard HTTP status codes and return structured error bodies for validation and runtime failures.
What to Check First
- Status code:
4xxmeans the request needs changing;5xxmeans retry/backoff. - Request IDs / logs: If you have server logs, log the status + response body.
- Clock drift: For signed URLs, make sure your system clock is reasonably correct.
Common Status Codes
| Status | Meaning | Typical causes |
|---|---|---|
400 | Bad Request | Missing fields, invalid enum values |
401 | Unauthorized | Missing/invalid X-Api-Key |
403 | Forbidden | API key doesn’t have access to that org/env/video |
404 | Not Found | Wrong IDs or resource doesn’t exist |
409 | Conflict | Repeated or invalid state transition |
429 | Rate limited | Too many requests; backoff |
500 | Server error | Temporary error; retry |
Retry Strategy
- Safe to retry: Most
GETs, and idempotent operations. - Use exponential backoff: e.g. 250ms → 500ms → 1s → 2s (cap at ~10s).
- Don’t retry forever: Use a max attempts/time budget.
Upload-Specific Errors
POST /videos/upload-url succeeds but the upload fails
- Network failures,
408,429or5xxonresumableUploadURL: Ask how many bytes are stored and continue from there. Nothing already uploaded is lost. See Uploading With a Pre-Signed URL. 404or410onresumableUploadURL: The session expired one week after it was created. Request new upload URLs and upload again.403onsignedURL: TheContent-Typeheader is missing or differs fromcontentTypein the upload-url response, or the URL is more than a week old.- Network failures on
signedURL: ThePUTmust restart from byte 0. UseresumableUploadURLfor large files instead.
Processing takes a while
Processing time depends on file size, source codec complexity, and quality settings. Poll video details and wait for status.ready.
Example: Robust Fetch Wrapper (JavaScript)
async function antcdnFetch(url, init) { const res = await fetch(url, init); const text = await res.text(); let payload; try { payload = text ? JSON.parse(text) : null; } catch { payload = text; }
if (!res.ok) { const detail = payload && typeof payload === "object" && "detail" in payload ? payload.detail : undefined; const msg = detail ? String(detail) : `Request failed: ${res.status}`; const err = new Error(msg); err.status = res.status; err.payload = payload; throw err; }
return payload;}