Using delegated upload tokens
You can upload videos using the traditional two-step process where you create a video container then upload your video into your container. You can also upload a video using a delegated upload token. This guide explains how to create, list, retrieve, and delete delegated upload tokens, and how to upload videos with them.
In this type of upload, you retrieve a token from the tokens endpoint. You can then directly upload using the token upload endpoint. It's one step, and you don't provide anything except the file. You can update the metadata for the upload later. A benefit of a delegated token is that you define the TTL (time-to-live) value, so it expires only when you need it to. You can always use the token to upload. You can also create delegated tokens for others to use to do uploads.
- Anyone who has a token can make an upload, so be careful how you set and manage tokens.
- You can create as many tokens as you need.
- If you do not include a TTL (time-to-live) value for a token, it lasts until you delete it.
We offer blog content on this topic:
- Delegated uploads - cURL Walk through how to do a delegated upload using cURL.
- Delegated uploads for videos large and small - Python Learn how to do a delegated upload using Python.
Create an account
Before you can start uploading your first video, you need to create an api.video account.
Once you are logged in to the Dashboard, select the environment of your choice (sandbox or production) and copy your API key.
Choose an api.video client
The clients offered by api.video include:
To install your selected client, do the following:
Generate a token for delegated upload
Use this code sample to generate a token for use with a delegated upload. You can include a TTL (time-to-live) if you like. The token will expire after exceeding the set TTL. If you don't send in a TTL, your token will last until you choose to delete it.
Upload a video with delegated tokens
If you do a progressive upload with a delegated token, you have to include the video ID you are uploading to after it comes back from the first request. If the video you're uploading is under 200 MiB, you don't need to worry.
You must first create a token and get the unique token ID to do a delegated upload. Then, you include it in your request as a query parameter. In the body, you place the path to the file you want to upload. If you are uploading a file that's 200 MiB or larger, to do a progressive upload, you will need to break the file into smaller pieces (no smaller than 5 MiB). Then send a request containing the first piece of your upload. Subsequent pieces must be sent with the video ID included in the body along with the file chunk. Retrieve the video ID from the response that comes back after your first request to upload.
List all tokens you created
If a token is compromised, or you want to see how many tokens you have, you will need to retrieve a list of them programmatically. Here is the code sample for that:
Show details about a specific token
Retrieve information about a specific token. To do this, you send a request containing the token ID for the token you need details about.
Delete a token
If you create a token that's compromised, you may want to remove it. Or, you might want to clean up how many tokens you have in general. All you need to do to delete a token is send a request containing the token ID for the token you want to remove.
Delegated upload is a useful method if you want to allow users to upload videos - you can provide them delegated upload tokans that expire. You can also use this method to create one-time video uploader solutions. It's also useful if you want to upload content quickly without worrying about the metadata. Everything is uploaded at once - it's just the video and the title. You can add the metadata later.
Was this page helpful?