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

# Issue MQTT Operator Token

> Issue a short-lived MQTT operator token for Transparency Mode.

Use this endpoint from a trusted backend or server-side operator agent. Pass the project API key in the `license` header. The endpoint has no request body.

The returned token allows the operator to subscribe to user messages and publish replies/presence on the project-scoped transparency MQTT topics.

Use this endpoint to issue a short-lived MQTT operator token for Transparency Mode.

The token lets your backend or operator agent subscribe to user messages and publish replies through the NavTalk hosted MQTT broker. The endpoint does not require a request body. Pass your project API key in the `license` header.

## Python agent usage

The sample operator agent fetches this token automatically when you pass `--api-key`:

```bash theme={null}
python transparent_mqtt_agent.py --api-key YOUR_NAVTALK_PROJECT_API_KEY
```

Internally, the agent calls:

```python theme={null}
import requests

response = requests.post(
    "https://api.navtalk.ai/api/open/v1/mqtt/operator-token",
    headers={"license": "YOUR_NAVTALK_PROJECT_API_KEY"},
    timeout=10,
)
token_data = response.json()["data"]
```

It then uses the returned `brokerUrl`, `projectId`, `prefix`, and `token` to connect to MQTT.

## Topic usage

The response includes ready-to-use topic templates:

* `topics.subscribe`: subscribe to user messages, for example `navtalk/transparent/{projectId}/+/user`
* `topics.reply`: publish operator replies, for example `navtalk/transparent/{projectId}/{sessionId}/reply`
* `topics.presence`: publish operator online/offline status, for example `navtalk/transparent/{projectId}/agent/presence`

When replying, replace `{sessionId}` with the session ID from the user message topic.

## Reply payload

For a final text reply, publish this JSON to the reply topic:

```json theme={null}
{
  "type": "transparent.reply.text",
  "session_id": "SESSION_ID",
  "roomId": "SESSION_ID",
  "source": "operator",
  "text": "Hello, how can I help you?",
  "messageId": "mqtt_agent_1780000000000"
}
```

For streaming replies, publish `transparent.reply.text.delta` messages first, then finish with `transparent.reply.text.done`.

<Warning>
  Do not expose the returned MQTT token in browser code. Fetch it from your backend or run the Python operator agent in a trusted server environment.
</Warning>


## OpenAPI

````yaml POST /api/open/v1/mqtt/operator-token
openapi: 3.1.0
info:
  title: NavTalk API
  description: NavTalk API for AI avatar management, file uploads, and video generation
  version: 1.0.0
servers:
  - url: https://api.navtalk.ai
    description: NavTalk Production Environment Server
  - url: https://qaapi.navtalk.ai
    description: NavTalk QA Environment Server
  - url: https://devapi.navtalk.ai
    description: NavTalk Development Environment Server
security:
  - navtalkLicenseAuth: []
paths:
  /api/open/v1/mqtt/operator-token:
    post:
      tags:
        - Realtime Chat
      summary: Issue MQTT Operator Token
      description: >-
        Issue a short-lived MQTT operator token for Transparency Mode.


        Use this endpoint from a trusted backend or server-side operator agent.
        Pass the project API key in the `license` header. The endpoint has no
        request body.


        The returned token allows the operator to subscribe to user messages and
        publish replies/presence on the project-scoped transparency MQTT topics.
      operationId: issueMqttOperatorToken
      parameters: []
      responses:
        '200':
          description: MQTT operator token issued successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MqttOperatorTokenResponse'
              example:
                code: 200
                message: SUCCESS
                data:
                  brokerUrl: mqtts://mqtt.navtalk.ai:8883
                  projectId: project_123
                  prefix: navtalk/transparent
                  authType: mqtt_operator
                  token: eyJhbGciOi...
                  expiresAt: '2026-07-04T10:00:00Z'
                  expiresInSeconds: 604800
                  args:
                    broker-url: mqtts://mqtt.navtalk.ai:8883
                    token: eyJhbGciOi...
                    prefix: navtalk/transparent
                  topics:
                    subscribe: navtalk/transparent/project_123/+/user
                    reply: navtalk/transparent/project_123/{sessionId}/reply
                    presence: navtalk/transparent/project_123/agent/presence
                  scriptCommand: >-
                    python transparent_mqtt_agent.py --broker-url
                    mqtts://mqtt.navtalk.ai:8883 --token eyJhbGciOi... --prefix
                    navtalk/transparent
        '400':
          description: License validation failed or token issue error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NavtalkErrorResponse'
              example:
                code: 400
                message: Invalid license key
      security:
        - navtalkLicenseAuth: []
components:
  schemas:
    MqttOperatorTokenResponse:
      type: object
      properties:
        code:
          type: integer
          example: 200
        message:
          type: string
          example: SUCCESS
        data:
          $ref: '#/components/schemas/MqttOperatorTokenData'
    NavtalkErrorResponse:
      type: object
      properties:
        code:
          type: integer
          example: 400
        message:
          type: string
          example: Invalid license key
    MqttOperatorTokenData:
      type: object
      properties:
        brokerUrl:
          type: string
          description: Public MQTT broker URL used by the operator agent.
          example: mqtts://mqtt.navtalk.ai:8883
        projectId:
          type: string
          description: Sanitized project ID used in transparency MQTT topics.
          example: project_123
        prefix:
          type: string
          description: MQTT topic prefix for Transparency Mode.
          example: navtalk/transparent
        authType:
          type: string
          description: Token type.
          example: mqtt_operator
        token:
          type: string
          description: Short-lived MQTT operator token. Use it as the MQTT password.
          example: eyJhbGciOi...
        expiresAt:
          type: string
          format: date-time
          description: Token expiration time.
          example: '2026-07-04T10:00:00Z'
        expiresInSeconds:
          type: integer
          format: int64
          description: Token TTL in seconds.
          example: 604800
        args:
          type: object
          additionalProperties:
            type: string
          description: >-
            Command-line arguments that can be passed to the Python operator
            agent.
          example:
            broker-url: mqtts://mqtt.navtalk.ai:8883
            token: eyJhbGciOi...
            prefix: navtalk/transparent
        topics:
          type: object
          additionalProperties:
            type: string
          description: >-
            MQTT topic templates for subscribing to user messages and publishing
            replies/presence.
          example:
            subscribe: navtalk/transparent/project_123/+/user
            reply: navtalk/transparent/project_123/{sessionId}/reply
            presence: navtalk/transparent/project_123/agent/presence
        scriptCommand:
          type: string
          description: Ready-to-run command for the Python sample agent.
          example: >-
            python transparent_mqtt_agent.py --broker-url
            mqtts://mqtt.navtalk.ai:8883 --token eyJhbGciOi... --prefix
            navtalk/transparent
  securitySchemes:
    navtalkLicenseAuth:
      type: apiKey
      in: header
      name: license
      description: NavTalk API license key (e.g. sk_navtalk_...)

````