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

# Create Client Token

> Mint a short-lived, browser-safe token. With ``conversation_id`` the token continues and reads that thread; without it, the token's first turn creates the thread and binds the token to it.

See [Client tokens](/conversations/client-tokens).


## OpenAPI

````yaml post /v1/conversations/client_tokens
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.trychannel3.com
    description: Production
security: []
paths:
  /v1/conversations/client_tokens:
    post:
      tags:
        - v1
      summary: Create Client Token
      description: >-
        Mint a short-lived, browser-safe token. With ``conversation_id`` the
        token continues and reads that thread; without it, the token's first
        turn creates the thread and binds the token to it.
      operationId: create_client_token_v1_conversations_client_tokens_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateClientTokenRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ClientTokenResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationErrorBody'
        '402':
          description: Payment required
          content:
            application/json:
              examples:
                credits_exhausted:
                  summary: API key out of credits
                  value:
                    detail: >-
                      You have used all of your free credits. Add a payment
                      method to continue.
                mpp_challenge:
                  summary: MPP Tempo payment required
                  value:
                    detail: >-
                      Payment required. Satisfy the MPP Tempo challenge in
                      WWW-Authenticate.
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationErrorBody'
        '422':
          description: Request validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationErrorBody'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationErrorBody'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationErrorBody'
        '503':
          description: Client token service temporarily unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationErrorBody'
      security:
        - APIKeyHeader: []
      x-codeSamples:
        - lang: JavaScript
          source: >-
            import Channel3 from '@channel3/sdk';


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


            const clientTokenResponse = await
            client.conversations.clientTokens.create();


            console.log(clientTokenResponse.token_id);
        - lang: Python
          source: |-
            import os
            from channel3_sdk import Channel3

            client = Channel3(
                api_key=os.environ.get("CHANNEL3_API_KEY"),  # This is the default and can be omitted
            )
            client_token_response = client.conversations.client_tokens.create()
            print(client_token_response.token_id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/channel3-ai/sdk-go\"\n\t\"github.com/channel3-ai/sdk-go/option\"\n)\n\nfunc main() {\n\tclient := channel3go.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tclientTokenResponse, err := client.Conversations.ClientTokens.New(context.TODO(), channel3go.ConversationClientTokenNewParams{\n\t\tCreateClientTokenRequest: channel3go.CreateClientTokenRequestParam{},\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", clientTokenResponse.TokenID)\n}\n"
        - lang: CLI
          source: |-
            channel3 conversations:client-tokens create \
              --api-key 'My API Key'
components:
  schemas:
    CreateClientTokenRequest:
      properties:
        conversation_id:
          anyOf:
            - type: string
              maxLength: 256
              minLength: 1
            - type: 'null'
          title: Conversation Id
        ttl_seconds:
          type: integer
          maximum: 7200
          minimum: 60
          title: Ttl Seconds
          default: 1800
      type: object
      title: CreateClientTokenRequest
    ClientTokenResponse:
      properties:
        token:
          type: string
          title: Token
        token_id:
          type: string
          title: Token Id
        expires_at:
          type: integer
          title: Expires At
        token_type:
          type: string
          const: Bearer
          title: Token Type
          default: Bearer
      type: object
      required:
        - token
        - token_id
        - expires_at
      title: ClientTokenResponse
    ConversationErrorBody:
      properties:
        error:
          $ref: '#/components/schemas/ConversationError'
      type: object
      required:
        - error
      title: ConversationErrorBody
      description: Error envelope for all non-2xx ``/v1/conversations`` responses.
    ErrorResponse:
      properties:
        detail:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
          title: Detail
      type: object
      required:
        - detail
      title: ErrorResponse
    ConversationError:
      properties:
        code:
          $ref: '#/components/schemas/TurnErrorCode'
        message:
          type: string
          title: Message
      type: object
      required:
        - code
        - message
      title: ConversationError
    TurnErrorCode:
      type: string
      enum:
        - invalid_request
        - unauthorized
        - insufficient_credits
        - conversation_not_found
        - turn_conflict
        - rate_limited
        - model_unavailable
        - token_not_found
        - service_unavailable
        - internal
      title: TurnErrorCode
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````