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

# Live resource subscriptions

> Native WebSocket. Send `{ op: "subscribe", id, resource, input }`, `{ op: "unsubscribe", id }`, or `{ op: "ping" }`; receive `{ id, type: "ready" | "event" | "error" }` or `{ type: "pong" }`.



## OpenAPI

````yaml https://api.tembo.io/public-api/openapi/public get /v1/live
openapi: 3.1.0
info:
  title: Tembo Public API
  description: >-
    Manage agents, sessions, repositories, and organization resources with the
    Tembo API.
  version: 1.0.0
servers:
  - url: https://api.tembo.io
    description: Tembo API
  - url: https://{deployment-origin}/api/public-api
    description: Self-hosted Tembo
    variables:
      deployment-origin:
        default: tembo.example.com
        description: Hostname of your self-hosted Tembo deployment
security: []
paths:
  /v1/live:
    get:
      tags:
        - Live
      summary: Live resource subscriptions
      description: >-
        Native WebSocket. Send `{ op: "subscribe", id, resource, input }`, `{
        op: "unsubscribe", id }`, or `{ op: "ping" }`; receive `{ id, type:
        "ready" | "event" | "error" }` or `{ type: "pong" }`.
      operationId: liveConnection
      parameters:
        - in: query
          name: ticket
          schema:
            type: string
            minLength: 1
          required: true
          description: >-
            Short-lived connection ticket returned by liveConnectionTicket. Used
            to authenticate the native WebSocket connection.
      responses:
        '101':
          description: Authorized native WebSocket
        '401':
          description: Invalid or expired live ticket
      x-codeSamples:
        - lang: typescript
          label: TypeScript SDK
          source: |
            import Tembo from '@tembo-io/sdk';

            const client = new Tembo();

            const { ticket } = await client.live.authorize();
            const connection = client.live.connect({ ticket });

            try {
              for await (const message of connection) {
                if (message.type === 'ready' && message.id === undefined) {
                  connection.send({
                    op: 'subscribe',
                    id: 'events',
                    resource: 'sessions.events',
                    input: { scope: { sessionId: 'sessionId' } },
                  });
                }
                console.log(message);
              }
            } finally {
              connection.close();
            }
        - lang: rust
          label: Rust SDK
          source: |
            use tembo_rs::*;

            let client = Tembo::from_env()?;

            let ticket = client.live().authorize().send().await?.ticket;
            let mut connection = client.live().connect(ticket).open().await?;

            while let Some(message) = connection.recv().await {
                let message = message?;
                if message["type"] == "ready" && message.get("id").is_none() {
                    connection
                        .send(&serde_json::json!({
                            "op": "subscribe",
                            "id": "events",
                            "resource": "sessions.events",
                            "input": { "scope": { "sessionId": "sessionId" } },
                        }))
                        .await?;
                }
                println!("{message:?}");
            }

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.