# Realtime

Realtime — Micro TypeScript reference.

Reference for TypeScript SDK **0.14.0**.

[Release source](https://github.com/micro-so/micro-sdk-ts/blob/v0.14.0/api.md) · [Setup and client configuration](/docs/reference/typescript)

## createTicket

`POST /v2/realtime/ticket`

````text
client.realtime.createTicket() -> RealtimeCreateTicketResponse
````

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.

## Parameter and response types

These declarations show the request parameters and response shapes used by the methods above.

### RealtimeCreateTicketResponse

[Source](https://github.com/micro-so/micro-sdk-ts/blob/v0.14.0/src/resources/realtime.ts)

````text
export interface RealtimeCreateTicketResponse {
  /**
   * Seconds until the ticket expires. Refresh (call the endpoint again) before
   * reconnecting.
   */
  expires_in: number;

  /**
   * Short-lived token authenticating a realtime WebSocket connection. Pass as the
   * `token` query parameter when connecting.
   */
  ticket: string;

  /**
   * WebSocket URL for this environment (wss://stream.developers[.staging].micro.so).
   * Connect here with the ticket as the `token` query parameter.
   */
  ws_url: string | null;
}
````


### Realtime

[Source](https://github.com/micro-so/micro-sdk-ts/blob/v0.14.0/src/resources/realtime.ts)

````text
export declare namespace Realtime {
  export { type RealtimeCreateTicketResponse as RealtimeCreateTicketResponse };
}
````
