Stream Video Serverless

Setup

  1. Deploy this serverless function using Vercel:

Deploy with Vercel

  1. Set Environment Variables with your Stream Video SDK's API_KEY and API_SECRET.
image

Create Token API

Description

This api allows for the creation of a token for the specified user. The token might be used for authentication, session management, or other purposes (as dictated by the underlying service).

It's crucial to ensure you provide the correct API key in the header and specify the appropriate user ID in the request body to successfully create a token.

Request

  • Method

    POST

  • URL

    {your vercel app endpoint}/api/create-token

  • Headers

    • content-type: application/json
    • api-key: {your api key}
  • Body (JSON):

    {
      "userId": "USER_ID_TO_LOGIN"
    }

    Replace USER_ID_TO_LOGIN with the appropriate user ID value.

Expected Responses:

  • 200 OK: Success! Returns token details.
    {
        "userId": "userId",
        "token": "created token"
    }
  • 400 Bad Request: Malformed request or validation errors.
  • 401 Unauthorized: Invalid or missing API key.
  • 500 Internal Server Error: Unexpected errors on the server side.