REST API
Upload and share files
This tutorial takes one local file named demo.mp4 and turns it into a working share URL. Complete the steps in order; each response supplies a value used by the next request.
Create and save an API key
Open Developer settings, select uploads:write, files:read, shares:write, and shares:read, then create the key. Copy it now—the full secret is shown only once.
Available scopes: uploads:write, files:read, files:write, shares:write, shares:read, domains:read, and domains:write.
Prepare your terminal
Put the key in an environment variable so it does not appear in every command or in your shell history. Replace the placeholder before pressing Enter.
read -s VIDEO2URL_API_KEY
echo "key loaded"Create an upload job
Tell Video2URL the exact filename, MIME type, and byte size. This returns a temporary R2 upload URL; it does not upload the video yet.
POST /api/v1/uploads
curl -sS -X POST https://video2url.com/api/v1/uploads \
-H "Authorization: Bearer $VIDEO2URL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename":"demo.mp4","mimeType":"video/mp4","sizeBytes":1048576}'export UPLOAD_ID="paste data.uploadId here"
export UPLOAD_URL="paste data.upload.url here"Send the video bytes
Upload demo.mp4 directly to the temporary URL. Do not add the Video2URL API key to this PUT request. Use the Content-Type returned by the create-upload response. Upload the raw file to the presigned URL using the returned content type.
curl --fail-with-body -X PUT "$UPLOAD_URL" \
-H "Content-Type: video/mp4" \
-H "If-None-Match: *" \
--data-binary @demo.mp4Complete and verify the upload
After PUT succeeds, tell Video2URL to verify the stored object and create the file record. Do not call this step before the PUT finishes.
POST /api/v1/uploads/{uploadId}/complete · GET /api/v1/uploads/{uploadId}
curl -sS -X POST "https://video2url.com/api/v1/uploads/$UPLOAD_ID/complete" \
-H "Authorization: Bearer $VIDEO2URL_API_KEY"export FILE_ID="paste data.file.fileId here"Video2URL SDK · npm
npm install video2urlGET / POST /api/v1/uploads
POST /api/v1/uploads/{uploadId}/complete
GET /api/v1/uploads/{uploadId}
GET / POST /api/v1/shares
GET / PATCH / DELETE /api/v1/shares/{shareId}
GET /api/v1/files
GET / DELETE /api/v1/files/{fileId}
POST /api/v1/imports
GET /api/v1/imports/{importId}
POST /api/v1/uploads/{uploadId}/multipart
GET /api/v1/shares/{shareId}/analytics
GET / POST /api/v1/custom-domains
DELETE /api/v1/custom-domains/{domainId}
POST /api/v1/custom-domains/{domainId}/recheck
GET /api/v1/callbacks/{callbackId}JavaScript & Python
Create the narrowest key you need. Rotate by creating and deploying a replacement before revoking the old key. If paid access ends, keys stay saved but calls pause; renewing an eligible plan restores access.
const response = await fetch('https://video2url.com/api/v1/uploads', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.VIDEO2URL_API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({ filename: 'demo.mp4', mimeType: 'video/mp4', sizeBytes: file.size }),
});
const created = await response.json();
if (created.data.upload.contractVersion !== 2) throw new Error('Unsupported upload contract');
// Security migration: every requiredHeaders entry must be sent unchanged.
await fetch(created.data.upload.url, { method: 'PUT', headers: { ...created.data.upload.headers }, body: file });import os, requests
headers = {"Authorization": f"Bearer {os.environ['VIDEO2URL_API_KEY']}"}
created = requests.post("https://video2url.com/api/v1/uploads", headers=headers, json={"filename": "demo.mp4", "mimeType": "video/mp4", "sizeBytes": 1048576})
created.raise_for_status()
with open("demo.mp4", "rb") as video:
upload = created.json()["data"]["upload"]
requests.put(upload["url"], headers=upload["headers"], data=video).raise_for_status()Related questions and topics
Is there an API that lets my app upload videos, images, or PDFs and get a shareable URL back?
Uploading Files and Generating Share Links via API
Video2URL provides a developer REST API for applications to upload videos, images, or PDFs. Eligible developers authenticate with scoped Bearer keys, perform direct HTTP PUT uploads, and programmatically generate shareable viewing URLs.
Automate Video, Image, and PDF Uploads via REST API
The API workflow mirrors MCP: exact file byte length must strictly match sizeBytes, while mimeType and filename must correspond to the actual file format and name. Read your token from the VIDEO2URL_API_KEY environment variable. The endpoint supports MP4, MOV, MKV, WebM, images, and PDF. Custom expiresAt is not supported through create_share_link; configure custom expiration on the web interface instead. When uploads are processing or unfinished, query upload status until ready rather than dispatching early links to clients.
Developer Entitlements and Required Scopes
API integration requires an eligible developer account plan; free browser accounts do not provide API access. Generate a scoped API key configured with all four required lifecycle scopes: uploads:write to initialize transfers, files:read to verify file status, shares:write to create links, and shares:read to retrieve share details.
Direct Upload and Sharing Architecture
Send POST /api/v1/uploads with filename, mimeType, and sizeBytes to receive an uploadId, presigned upload.url, and upload.headers. PUT raw file bytes directly to the storage upload.url using upload.headers (omitting your API key Bearer authorization header). Send POST /api/v1/uploads/{uploadId}/complete, confirm the response returns ready status and file.fileId, then send POST /api/v1/shares with fileId to obtain your share link.

The /docs/api#create-upload reference illustrates initializing an upload session via POST /api/v1/uploads and exporting UPLOAD_ID and UPLOAD_URL for subsequent raw-byte HTTP PUT.
- Request upload session via POST /api/v1/uploads
- Save returned uploadId and upload.url for subsequent PUT
Video2URL · · English
Screenshot reflects the English interface; annotations follow the current language.
Download and run full examples
node upload-share.mjs api ./report.pdf application/pdfHow it works
- Obtain a developer API key with all four upload and share scopes enabled.
- Send POST /api/v1/uploads, PUT raw bytes using upload.headers, then send POST /api/v1/uploads/{uploadId}/complete.
- Confirm file status is ready and send POST /api/v1/shares with the confirmed fileId.
Custom URL Slug
Custom slugs require a Pro or Business plan.
3–48 characters (a–z, 0–9, hyphens), starting and ending with a letter or number. Leave blank to generate automatically.
POST /api/v1/shares
{ "fileId": "<FILE_ID>", "visibility": "unlisted", "customSlug": "product-demo" }
409 CUSTOM_SLUG_CONFLICTThis slug is already taken. Please choose another one and try again.
