Skip to content
Go to Micro

Create a realtime streaming ticket

client.Realtime.NewTicket(ctx) (*RealtimeNewTicketResponse, error)
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.

ReturnsExpand Collapse
type RealtimeNewTicketResponse struct{…}
ExpiresIn int64

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.

WsURL string

WebSocket URL for this environment (wss://stream.developers[.staging].micro.so). Connect here with the ticket as the token query parameter.

Create a realtime streaming ticket

package main

import (
  "context"
  "fmt"

  "github.com/micro-so/micro-sdk-go"
  "github.com/micro-so/micro-sdk-go/option"
)

func main() {
  client := micro.NewClient(
    option.WithAPIKey("My API Key"),
    option.WithTeamID("My Team ID"),
  )
  response, err := client.Realtime.NewTicket(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.ExpiresIn)
}
{
  "expires_in": 0,
  "ticket": "ticket",
  "ws_url": "ws_url"
}
Returns Examples
{
  "expires_in": 0,
  "ticket": "ticket",
  "ws_url": "ws_url"
}