Browse developer docs

Video2URL ·

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.

1

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.

Expected result:You have a secret that begins with the Video2URL key prefix. Keep it private.
2

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.

Terminal
read -s VIDEO2URL_API_KEY
echo "key loaded"
Expected result:The command prints key loaded, not the secret itself.
3

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
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}'
Expected result:A JSON response containing data.uploadId and data.upload.url. Save both values for the next steps.
Save response values
export UPLOAD_ID="paste data.uploadId here"
export UPLOAD_URL="paste data.upload.url here"
4

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 · PUT
curl --fail-with-body -X PUT "$UPLOAD_URL" \
  -H "Content-Type: video/mp4" \
  -H "If-None-Match: *" \
  --data-binary @demo.mp4
Expected result:The upload server returns HTTP 200. An empty response body is normal.
5

Complete 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
curl -sS -X POST "https://video2url.com/api/v1/uploads/$UPLOAD_ID/complete" \
  -H "Authorization: Bearer $VIDEO2URL_API_KEY"
Expected result:The response contains data.file.fileId. Save FILE_ID; it identifies the completed file.
Save FILE_ID
export FILE_ID="paste data.file.fileId here"
6

Create the final share URL

Create an unlisted link from FILE_ID. Unlisted means anyone with the URL can open it, but it is not placed in a public directory.

  • Title is optional.
  • Password is optional.
  • Visibility is optional.
  • Visibility defaults to unlisted.

POST /api/v1/shares · GET / DELETE /api/v1/shares/{shareId}

curl
curl -sS -X POST https://video2url.com/api/v1/shares \
  -H "Authorization: Bearer $VIDEO2URL_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"fileId\":\"$FILE_ID\",\"visibility\":\"unlisted\"}"
Expected result:The response contains the share record and URL. Open SHARE_URL in a private browser window to verify it.
Open SHARE_URL
export SHARE_URL="paste the returned share URL here"
open "$SHARE_URL" # macOS; use xdg-open on Linux

Video2URL SDK · npm

npm
npm install video2url
REST API
GET / 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}
README

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.

JavaScript
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 });
Python
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.

  1. Request upload session via POST /api/v1/uploads
  2. 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/pdf

How it works

  1. Obtain a developer API key with all four upload and share scopes enabled.
  2. Send POST /api/v1/uploads, PUT raw bytes using upload.headers, then send POST /api/v1/uploads/{uploadId}/complete.
  3. 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.

REST API
POST /api/v1/shares
{ "fileId": "<FILE_ID>", "visibility": "unlisted", "customSlug": "product-demo" }

409 CUSTOM_SLUG_CONFLICT

This slug is already taken. Please choose another one and try again.