# Realtime ## Create a realtime streaming ticket `client.realtime.createTicket(RequestOptionsoptions?): RealtimeCreateTicketResponse` **post** `/v2/realtime/ticket` Exchange your API key (or session) for a short-lived ticket that authenticates a connection to the realtime object-change stream. Open a WebSocket to the push endpoint with the returned ticket as the `token` query parameter. The ticket is single-purpose and expires quickly; call this again to obtain a fresh one before reconnecting. ### Returns - `RealtimeCreateTicketResponse` - `expires_in: number` Seconds until the ticket expires. Refresh (call the endpoint again) before reconnecting. - `ticket: string` Short-lived token authenticating a realtime WebSocket connection. Pass as the `token` query parameter when connecting. - `ws_url: string | null` WebSocket URL for this environment (wss://stream.developers[.staging].micro.so). Connect here with the ticket as the `token` query parameter. ### Example ```typescript import Micro from '@micro-so/sdk'; const client = new Micro({ teamID: 'My Team ID', apiKey: process.env['MICRO_API_KEY'], // This is the default and can be omitted }); const response = await client.realtime.createTicket(); console.log(response.expires_in); ``` #### Response ```json { "expires_in": 0, "ticket": "ticket", "ws_url": "ws_url" } ``` ## Domain Types ### Realtime Create Ticket Response - `RealtimeCreateTicketResponse` - `expires_in: number` Seconds until the ticket expires. Refresh (call the endpoint again) before reconnecting. - `ticket: string` Short-lived token authenticating a realtime WebSocket connection. Pass as the `token` query parameter when connecting. - `ws_url: string | null` WebSocket URL for this environment (wss://stream.developers[.staging].micro.so). Connect here with the ticket as the `token` query parameter.