Secure Upload
Upload a media file once and reference it on downstream jobs using a short-lived token, instead of hosting the file at a public URL. The Secure Upload API pairs with endpoints like Create Detection and Run Intelligence, which both accept a media_token in place of url.
Use a secure upload when:
- You do not want to host source media on the public internet.
- You need to send a local file to the API without spinning up your own storage.
- You are submitting a large batch and want uploads and detection jobs to run in parallel.
Workflow
- Upload the file via
POST /secure_uploadsand capture the returnedtoken. - Call the downstream endpoint (e.g.
POST /detect) withmedia_tokenset to that token. - Poll or wait on the returned job as usual. Tokens are single-purpose and tied to the uploaded file; the media stays private to your team.
Tokens expire 1 hour after issuance. If you need to re-run detection after expiry, upload the file again.
Upload Endpoint
POST https://app.resemble.ai/api/v2/secure_uploads
Headers
Request Body
Example Request
Response
The returned token is a JWT that securely references the uploaded file. Pass it as media_token on any endpoint that accepts it.
Using the Token with Detect
For a video such as the .mp4 uploaded above, pass face_only: true to focus visual detection on faces:
All other single-file /detect parameters (callback_url, visualize, frame_length, face_only, detect_watermark, zero_retention_mode, etc.) behave exactly as they do with a url input. Face-only mode is effective only for video inputs that include visual analysis; incompatible inputs return an effective value of false.
When detect_watermark=true, the secure-upload token does not bypass Watermark decoder limits: the referenced source must be no larger than 25 MB for audio/image or 100 MB for video. The returned Detect includes a conditional watermark object, and callbacks or Prefer: wait wait until that analysis is completed or failed. Watermark analysis is not supported by POST /detect/batch or zip uploads.
Python Example — Batch Detect with Secure Upload
The following script walks a folder of local media files, uploads each via the Secure Upload API, submits a detect job against the returned token, and polls until every job reaches a terminal state. Uploads and polling run in a small thread pool so a batch of dozens of files completes well within the 1-hour token window.
Security Considerations
- Tokens are valid for 1 hour after creation; use them promptly or re-upload.
- Always use HTTPS when uploading so files are encrypted in transit.
- Keep your API key secret — treat it like a password.
- Uploaded files are never publicly accessible; only holders of a valid token (and your team) can reference them.
Error Handling
Both the upload and downstream endpoints return standard HTTP status codes with JSON error bodies. Common failures include:
Always check the response status and body for detailed error information before retrying.
