> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Client Token to join a room.

> Synchronously create an Client Token to join a Room. Client Token is necessary to join a Telnyx Room. Client Token will expire after `token_ttl_secs`, a Refresh Token is also provided to refresh a Client Token, the Refresh Token expires after `refresh_token_ttl_secs`.



## OpenAPI

````yaml https://telnyx-openapi-ng.s3.us-east-1.amazonaws.com/real-time-communications/video.yml post /rooms/{room_id}/actions/generate_join_client_token
openapi: 3.1.0
info:
  title: Telnyx Video API
  version: 2.0.0
  description: API for Video.
  contact:
    email: support@telnyx.com
servers:
  - url: https://api.telnyx.com/v2
security:
  - bearerAuth: []
paths:
  /rooms/{room_id}/actions/generate_join_client_token:
    post:
      tags:
        - Rooms Client Tokens
      summary: Create Client Token to join a room.
      description: >-
        Synchronously create an Client Token to join a Room. Client Token is
        necessary to join a Telnyx Room. Client Token will expire after
        `token_ttl_secs`, a Refresh Token is also provided to refresh a Client
        Token, the Refresh Token expires after `refresh_token_ttl_secs`.
      operationId: CreateRoomClientToken
      parameters:
        - name: room_id
          in: path
          description: The unique identifier of a room.
          required: true
          schema:
            type: string
            format: uuid
            example: 0ccc7b54-4df3-4bca-a65a-3da1ecc777f0
      requestBody:
        description: Parameters that can be defined during Room Client Token creation.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRoomClientTokenRequest'
      responses:
        '201':
          $ref: '#/components/responses/CreateRoomClientTokenResponse'
        '403':
          $ref: '#/components/responses/Forbidden'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Telnyx from 'telnyx';

            const client = new Telnyx({
              apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
            });

            const response = await client.rooms.actions.generateJoinClientToken(
              '0ccc7b54-4df3-4bca-a65a-3da1ecc777f0',
            );

            console.log(response.data);
        - lang: Python
          source: |-
            import os
            from telnyx import Telnyx

            client = Telnyx(
                api_key=os.environ.get("TELNYX_API_KEY"),  # This is the default and can be omitted
            )
            response = client.rooms.actions.generate_join_client_token(
                room_id="0ccc7b54-4df3-4bca-a65a-3da1ecc777f0",
            )
            print(response.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/team-telnyx/telnyx-go\"\n\t\"github.com/team-telnyx/telnyx-go/option\"\n)\n\nfunc main() {\n\tclient := telnyx.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tresponse, err := client.Rooms.Actions.GenerateJoinClientToken(\n\t\tcontext.TODO(),\n\t\t\"0ccc7b54-4df3-4bca-a65a-3da1ecc777f0\",\n\t\ttelnyx.RoomActionGenerateJoinClientTokenParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", response.Data)\n}\n"
        - lang: Java
          source: >-
            package com.telnyx.sdk.example;


            import com.telnyx.sdk.client.TelnyxClient;

            import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;

            import
            com.telnyx.sdk.models.rooms.actions.ActionGenerateJoinClientTokenParams;

            import
            com.telnyx.sdk.models.rooms.actions.ActionGenerateJoinClientTokenResponse;


            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    TelnyxClient client = TelnyxOkHttpClient.fromEnv();

                    ActionGenerateJoinClientTokenResponse response = client.rooms().actions().generateJoinClientToken("0ccc7b54-4df3-4bca-a65a-3da1ecc777f0");
                }
            }
        - lang: Ruby
          source: >-
            require "telnyx"


            telnyx = Telnyx::Client.new(api_key: "My API Key")


            response =
            telnyx.rooms.actions.generate_join_client_token("0ccc7b54-4df3-4bca-a65a-3da1ecc777f0")


            puts(response)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Telnyx\Client;

            use Telnyx\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API
            Key');


            try {
              $response = $client->rooms->actions->generateJoinClientToken(
                '0ccc7b54-4df3-4bca-a65a-3da1ecc777f0',
                refreshTokenTtlSecs: 3600,
                tokenTtlSecs: 600,
              );

              var_dump($response);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: CLI
          source: |-
            telnyx rooms:actions generate-join-client-token \
              --api-key 'My API Key' \
              --room-id 0ccc7b54-4df3-4bca-a65a-3da1ecc777f0
components:
  schemas:
    CreateRoomClientTokenRequest:
      type: object
      properties:
        token_ttl_secs:
          description: >-
            The time to live in seconds of the Client Token, after that time the
            Client Token is invalid and can't be used to join a Room.
          type: integer
          example: 600
          default: 600
          minimum: 10
          maximum: 3600
        refresh_token_ttl_secs:
          description: >-
            The time to live in seconds of the Refresh Token, after that time
            the Refresh Token is invalid and can't be used to refresh Client
            Token.
          type: integer
          example: 3600
          default: 3600
          minimum: 60
          maximum: 86400
    video_Error:
      required:
        - code
        - title
      properties:
        code:
          type: string
        title:
          type: string
        detail:
          type: string
        source:
          type: object
          properties:
            pointer:
              description: JSON pointer (RFC6901) to the offending entity.
              type: string
            parameter:
              description: Indicates which query parameter caused the error.
              type: string
        meta:
          type: object
          additionalProperties: true
      type: object
  responses:
    CreateRoomClientTokenResponse:
      description: Create room client token response.
      content:
        application/json:
          schema:
            type: object
            properties:
              data:
                type: object
                properties:
                  token:
                    type: string
                    example: >-
                      eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZWxueXhfdGVsZXBob255IiwiZXhwIjoxNTkwMDEwMTQzLCJpYXQiOjE1ODc1OTA5NDMsImlzcyI6InRlbG55eF90ZWxlcGhvbnkiLCJqdGkiOiJiOGM3NDgzNy1kODllLTRhNjUtOWNmMi0zNGM3YTZmYTYwYzgiLCJuYmYiOjE1ODc1OTA5NDIsInN1YiI6IjVjN2FjN2QwLWRiNjUtNGYxMS05OGUxLWVlYzBkMWQ1YzZhZSIsInRlbF90b2tlbiI6InJqX1pra1pVT1pNeFpPZk9tTHBFVUIzc2lVN3U2UmpaRmVNOXMtZ2JfeENSNTZXRktGQUppTXlGMlQ2Q0JSbWxoX1N5MGlfbGZ5VDlBSThzRWlmOE1USUlzenl6U2xfYURuRzQ4YU81MHlhSEd1UlNZYlViU1ltOVdJaVEwZz09IiwidHlwIjoiYWNjZXNzIn0.gNEwzTow5MLLPLQENytca7pUN79PmPj6FyqZWW06ZeEmesxYpwKh0xRtA0TzLh6CDYIRHrI8seofOO0YFGDhpQ
                  token_expires_at:
                    description: ISO 8601 timestamp when the token expires.
                    type: string
                    format: date-time
                    example: '2021-03-26T17:51:59Z'
                  refresh_token:
                    type: string
                    example: >-
                      eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJ0ZWxueXhfdGVsZXBob255IiwiZXhwIjoxNTkwMDEwMTQzLCJpYXQiOjE1ODc1OTA5NDMsImlzcyI6InRlbG55eF90ZWxlcGhvbnkiLCJqdGkiOiJiOGM3NDgzNy1kODllLTRhNjUtOWNmMi0zNGM3YTZmYTYwYzgiLCJuYmYiOjE1ODc1OTA5NDIsInN1YiI6IjVjN2FjN2QwLWRiNjUtNGYxMS05OGUxLWVlYzBkMWQ1YzZhZSIsInRlbF90b2tlbiI6InJqX1pra1pVT1pNeFpPZk9tTHBFVUIzc2lVN3U2UmpaRmVNOXMtZ2JfeENSNTZXRktGQUppTXlGMlQ2Q0JSbWxoX1N5MGlfbGZ5VDlBSThzRWlmOE1USUlzenl6U2xfYURuRzQ4YU81MHlhSEd1UlNZYlViU1ltOVdJaVEwZz09IiwidHlwIjoiYWNjZXNzIn0.gNEwzTow5MLLPLQENytca7pUN79PmPj6FyqZWW06ZeEmesxYpwKh0xRtA0TzLh6CDYIRHrI8seofOO0YFGDhpQ
                  refresh_token_expires_at:
                    description: ISO 8601 timestamp when the refresh token expires.
                    type: string
                    format: date-time
                    example: '2021-03-26T17:51:59Z'
                example:
                  token: >-
                    eyJhbGciOiJFZDI1NTE5IiwidHlwIjoiSldUIn0.eyJhdWQiOiJ0ZWxueXhfYWNjZXNzX3Rva2VuIiwiZXh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c4LWExNjVjNTk0MGQwNyIsIm5iZiI6MTYxOTA5MzY5NCwic3ViIjoibnVsbCIsInR5cCI6InJlZnJlc2gifQ.FHsp7KlVXn1E5tTUiKZzmQ4of39gi57AakeQeqI0oAa8hzjFMVb0RGj-mxWTvHVen4GpgsUW_epqqaxK16viCA
                  refresh_token_expires_at: '2021-04-22T12:15:05Z'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/video_Error'
  securitySchemes:
    bearerAuth:
      scheme: bearer
      type: http

````