Obtain your Cloudflare account ID and create an API token with Stream permissions (or use your Global API Key).
Initiate a tus upload session by sending a POST request to the Cloudflare Stream tus endpoint for your account, including the Upload-Length header (file size in bytes) and Upload-Metadata header with encoded metadata such as the video name.
Include your Cloudflare API token in the Authorization header (Bearer YOUR_TOKEN) and the required tus version header.
From the 201 response, capture the Location header which contains the unique upload URL for this session.
Use a tus-compatible client library to upload the file bytes to the Location URL in chunks, resuming from the last acknowledged offset if interrupted.
Once the upload completes, retrieve the video's uid from the Stream dashboard or the videos API to construct the playback URL.
Known gotchas
Cloudflare Stream enforces a maximum video duration and file size depending on your plan; verify limits before attempting large uploads.
The tus protocol requires specific headers (Tus-Resumable, Upload-Offset, Content-Type: application/offset+octet-stream) for PATCH requests; use a tus client library to handle protocol compliance.
Videos are not immediately streamable after upload; Cloudflare encodes them asynchronously, so poll the video status or use webhooks before serving to users.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp