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

# Mint a subscriber token

> Mints a short-lived client token scoped to channels and capabilities, for use by browser subscribers connecting over the realtime WebSocket. Requires scope: realtime:tokens



## OpenAPI

````yaml /api-specs/services.json post /realtime/v1/tokens
openapi: 3.1.0
info:
  title: Voyant Cloud REST API
  version: 1.0.0
  description: >-
    Public REST API for Voyant Cloud products: Vault, SMS, Email, Verification,
    Video, Realtime, and Browser. All requests authenticate with an API token
    passed as an HTTP bearer token in the Authorization header. Each operation
    requires a specific token scope, documented in the operation description.
servers:
  - url: https://api.voyant.travel
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Vault
    description: >-
      Encrypted secret storage and envelope/per-call cryptography scoped to an
      organization vault.
  - name: SMS
    description: Send SMS messages and inspect message history and phone numbers.
  - name: Email
    description: Send transactional email and inspect message history.
  - name: Verification
    description: >-
      Start and check one-time-code verifications across SMS, call, email, and
      WhatsApp.
  - name: Video
    description: >-
      Upload, manage, caption, and watermark videos, and mint signed playback
      tokens.
  - name: Realtime
    description: >-
      Publish messages to realtime channels, inspect history and presence, and
      mint short-lived subscriber tokens.
  - name: Browser
    description: >-
      Headless browser rendering, scraping, structured extraction, crawling, and
      interactive sessions.
paths:
  /realtime/v1/tokens:
    post:
      tags:
        - Realtime
      summary: Mint a subscriber token
      description: >-
        Mints a short-lived client token scoped to channels and capabilities,
        for use by browser subscribers connecting over the realtime WebSocket.
        Requires scope: realtime:tokens
      operationId: mintRealtimeToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MintRealtimeTokenInput'
      responses:
        '200':
          description: Minted token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RealtimeTokenSummary'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/ServerError'
        '503':
          $ref: '#/components/responses/ServiceUnavailable'
      x-codeSamples:
        - lang: typescript
          label: SDK
          source: >-
            import { createVoyantCloudClient } from "@voyant-travel/cloud-sdk";


            const cloud = createVoyantCloudClient({ apiKey:
            process.env.VOYANT_API_KEY });


            const token = await cloud.realtime.tokens.mint({
              "clientId": "user_42",
              "capabilities": {
                "orders:org_123": [
                  "subscribe",
                  "presence"
                ]
              },
              "ttlSeconds": 123
            });
        - lang: bash
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.voyant.travel/realtime/v1/tokens \
              --header 'Authorization: Bearer <token>' \
              --header 'Content-Type: application/json' \
              --data '{
              "clientId": "user_42",
              "capabilities": {
                "orders:org_123": [
                  "subscribe",
                  "presence"
                ]
              },
              "ttlSeconds": 123
            }'
        - lang: javascript
          label: Node
          source: >-
            const response = await
            fetch("https://api.voyant.travel/realtime/v1/tokens", {
              method: "POST",
              headers: {
                "Content-Type": "application/json",
                "Authorization": "Bearer <token>"
              },
              body: JSON.stringify({
                "clientId": "user_42",
                "capabilities": {
                  "orders:org_123": [
                    "subscribe",
                    "presence"
                  ]
                },
                "ttlSeconds": 123
              }),
            });


            const data = await response.json();
        - lang: python
          label: Python
          source: |-
            import requests

            response = requests.post(
                "https://api.voyant.travel/realtime/v1/tokens",
                headers={
                    "Authorization": "Bearer <token>"
                },
                json={
                    "clientId": "user_42",
                    "capabilities": {
                        "orders:org_123": [
                            "subscribe",
                            "presence"
                        ]
                    },
                    "ttlSeconds": 123
                }
            )

            data = response.json()
components:
  schemas:
    MintRealtimeTokenInput:
      type: object
      required:
        - clientId
        - capabilities
      properties:
        clientId:
          type: string
          description: Stable subscriber identity; surfaces as the presence clientId.
          example: user_42
        capabilities:
          type: object
          description: >-
            Capability grants keyed by channel name or trailing-wildcard pattern
            (e.g. admin:*).
          additionalProperties:
            type: array
            items:
              $ref: '#/components/schemas/RealtimeCapability'
          example:
            orders:org_123:
              - subscribe
              - presence
        ttlSeconds:
          type: integer
          maximum: 86400
          description: Token lifetime in seconds. Default 3600, max 86400.
    RealtimeTokenSummary:
      type: object
      required:
        - token
        - expiresAt
      properties:
        token:
          type: string
        expiresAt:
          type: string
          format: date-time
    RealtimeCapability:
      type: string
      enum:
        - subscribe
        - publish
        - presence
    Error:
      type: object
      properties:
        error:
          type: string
    RateLimitError:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        retryAfterMs:
          type: integer
          description: Milliseconds to wait before retrying.
  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication is missing, invalid, revoked, or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: The API token does not include a scope required for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    TooManyRequests:
      description: Rate limit exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
    ServerError:
      description: An unexpected error occurred.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ServiceUnavailable:
      description: >-
        A required dependency (for example the platform database) is not
        available.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Voyant Cloud API token, passed as `Authorization: Bearer <token>`. Each
        token carries a fixed set of scopes; an operation rejects tokens missing
        its required scope.

````