Upload Tokens

In specific cases, there's a need to make requests from the front end. In order to securely achieve this scenario, we've introduced the Delegated Upload Token.

Delegated upload tokens give you the ability to generate disposable temporary upload tokens that expire after a certain amount of time without the need for you to expose your API key on the client side.

Use cases

Common use cases include:

  • Enabling your end-users to upload videos by serving the upload token on the front end or the client side
  • Creating a one-time video uploader

How do upload tokens work?

Generate the upload token

In the example, the request will generate a token that will be valid for an hour

curl --request POST \
     --url https://ws.api.video/upload-tokens \
     --header 'accept: application/json' \
     --header 'authorization: Basic XXYYZZ=' \
     --header 'content-type: application/json' \
     --data '{"ttl":3600}'

Response with the upload token

{
  "token": "toumQA9i1rFpEsGKl4k7Q9Y",
  "ttl": 3600,
  "createdAt": "2023-03-01T16:46:48+00:00",
  "expiresAt": "2023-03-01T17:46:48+00:00"
}

Video upload with delegated token

$ curl  --request POST --url 'https://ws.api.video/upload?token=toumQA9i1rFpEsGKl4k7Q9Y'
 --header 'content-type: multipart/form-data'
 -F [email protected]