Events

Events endpoints

This document contains the endpoints for the Events category.

Subscribe to event notifications via WebSocket:

This endpoint upgrades the HTTP connection to WebSocket and subscribes to event notifications. Authentication is required via Authorization header (Bearer token) or X-Api-Key header.

Parameters
event_types query
Request examples
/v1/ws/subscribe Authorized
curl --location 'http://localhost/api/v1/ws/subscribe' 
--header 'Authorization ••••••'

var client = new HttpClient();

var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/api/v1/ws/subscribe");
request.Headers.Add("Authorization", "••••••");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var responseString = await response.Content.ReadAsStringAsync();

package main

import (
  "fmt"
  "net/http"
  "strings"
  "io"
)

func main() {
  url := "http://localhost/api/v1/ws/subscribe"
  method := "get"
  client := &http.Client{}
  req, err := http.NewRequest(method, url, payload)
  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")

  req.Header.Add("Authorization", "••••••")
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()
  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

Responses
{
  "code": "int",
  "message": "string",
  "stack": [
    {
      "code": "int",
      "description": "string",
      "error": "string",
      "path": "string"
    }
  ]
}
{
  "code": "int",
  "message": "string",
  "stack": [
    {
      "code": "int",
      "description": "string",
      "error": "string",
      "path": "string"
    }
  ]
}
{
  "code": "int",
  "message": "string",
  "stack": [
    {
      "code": "int",
      "description": "string",
      "error": "string",
      "path": "string"
    }
  ]
}
{
  "code": "int",
  "message": "string",
  "stack": [
    {
      "code": "int",
      "description": "string",
      "error": "string",
      "path": "string"
    }
  ]
}
Unsubscribe from specific event types:

Unsubscribe an active WebSocket client from specific event types without disconnecting. The client must belong to the authenticated user.

Parameters
body Unsubscribe request with client ID and event types body
{
  "client_id": "string",
  "event_types": "[]string",
  "user_id": "string"
}
Request examples
/v1/ws/unsubscribe Authorized
curl --location 'http://localhost/api/v1/ws/unsubscribe' 
--header 'Authorization ••••••'
--header 'Content-Type: application/json' 
--data '{
  "client_id": "string",
  "event_types": "[]string",
  "user_id": "string"
}'

var client = new HttpClient();

var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/api/v1/ws/unsubscribe");
request.Headers.Add("Authorization", "••••••");
request.Headers.Add("Content-Type", "application/json");
request.Content = new StringContent("{
  "client_id": "string",
  "event_types": "[]string",
  "user_id": "string"
}");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
var responseString = await response.Content.ReadAsStringAsync();

package main

import (
  "fmt"
  "net/http"
  "strings"
  "io"
)

func main() {
  url := "http://localhost/api/v1/ws/unsubscribe"
  method := "post"
  payload := strings.NewReader(`{
  "client_id": "string",
  "event_types": "[]string",
  "user_id": "string"
}`)
  client := &http.Client{}
  req, err := http.NewRequest(method, url, payload)
  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")

  req.Header.Add("Authorization", "••••••")
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()
  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

Responses
{
  "code": "int",
  "message": "string",
  "stack": [
    {
      "code": "int",
      "description": "string",
      "error": "string",
      "path": "string"
    }
  ]
}
{
  "code": "int",
  "message": "string",
  "stack": [
    {
      "code": "int",
      "description": "string",
      "error": "string",
      "path": "string"
    }
  ]
}
{
  "code": "int",
  "message": "string",
  "stack": [
    {
      "code": "int",
      "description": "string",
      "error": "string",
      "path": "string"
    }
  ]
}
{
  "code": "int",
  "message": "string",
  "stack": [
    {
      "code": "int",
      "description": "string",
      "error": "string",
      "path": "string"
    }
  ]
}