Upload media with tus
Use this guide to upload a video, image, audio file or document into a workspace and wait until PlayTelly has processed it. For every field and route, see the Media API. To upload in the web app instead, see Upload media in the Media Library. To then play the file on a display, see Play uploaded media on a display with the API.
Before you begin¶
- You have an access token for a user with
workspace:media:upload(andworkspace:media:viewto follow progress) in the workspace. See Authentication. - You know the workspace ID,
<WORKSPACE_ID>. - You have a tus client (for example
tus-js-client) and the tus upload address for your environment,<TUS_ENDPOINT>. Ask your PlayTelly contact for it. - You know which transcoding profile to use, or you use none and the file is stored as it is.
Steps¶
-
Pick a transcoding profile. List the profiles for the file's category and note the
IDof the one you want.curl "https://<API_HOST>/api/v1/media/<WORKSPACE_ID>/transcoding-profiles?category=video" \ -H "Authorization: Bearer <ACCESS_TOKEN>"You get
200 OKwith the profiles, for example{ "ID": 3, "code": "VIDEO-STD-3RUNG", … }. An audio file needs anaudioprofile. -
Prepare the upload.
curl -X POST "https://<API_HOST>/api/v1/media/<WORKSPACE_ID>/prepare" \ -H "Authorization: Bearer <ACCESS_TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "title": "Lobby welcome", "originalName": "lobby-welcome.mp4", "mediaType": "video", "mimeType": "video/mp4", "fileSize": 6533201, "transcodingProfileId": 3 }'fileSizeis the exact size of the file in bytes. You get201 Created:{ "success": true, "data": { "token": "<UPLOAD_TOKEN>", "uploadId": 311, "expiresAt": "2026-11-16T10:30:00Z" } }Keep
tokenanduploadId. The token lasts at least 30 minutes and longer for larger files; it stays valid while bytes keep arriving. -
Send the file with tus. Pass the token as upload metadata, with the file name and type.
import { Upload } from "tus-js-client"; const upload = new Upload(file, { endpoint: "<TUS_ENDPOINT>", chunkSize: 50 * 1024 * 1024, retryDelays: [0, 1000, 3000, 5000, 10000, 30000, 60000], metadata: { uploadToken: "<UPLOAD_TOKEN>", filename: file.name, filetype: file.type }, onSuccess: () => console.log("uploaded"), }); upload.start();The client's
onSuccessfires when the last byte is stored. If the connection drops, a tus client resumes from the server's offset. -
Find out when the file became media. Poll Get an upload with the
uploadIdevery few seconds.curl "https://<API_HOST>/api/v1/media/<WORKSPACE_ID>/uploads/311" \ -H "Authorization: Bearer <ACCESS_TOKEN>"While the file travels you get
"state": "waiting","uploading"or"stalled". When it is done: -
Wait for processing. Poll Get a media object with
mediaId.curl "https://<API_HOST>/api/v1/media/<WORKSPACE_ID>/4521" \ -H "Authorization: Bearer <ACCESS_TOKEN>"The media is usable when
statusisready. A video is fully processed whentranscodingStageisdone; until thenmanifestUrlmay be empty.
Verify¶
The response of the last call has "status": "ready", "transcodingStage": "done" and complete URLs. Open
manifestUrl in an HLS player, or url for the source file.
Troubleshooting¶
| Symptom | Cause | Fix |
|---|---|---|
400 on prepare with audio transcoding profiles can only be used with audio media |
An audio profile with a non-audio file, or the reverse. | Use a profile of the file's category. |
403 on prepare |
Your role lacks workspace:media:upload. |
Ask an administrator to grant it. |
Upload state is stalled |
No bytes arrived for more than 3 minutes. | Resume the tus upload. If you gave up, dismiss it with Dismiss an upload. |
transcodingStage is failed |
The ladder failed. The source file is still playable. | Read transcodingError, then call Retry a transcode. |
| tus rejects the upload | The token expired or was dismissed. | Prepare a new upload. |