Overview

Event subscription is a mechanism that allows clients to receive real-time updates from the server. This is particularly useful for applications that require live data, such as chat applications, stock tickers, or any other application where data changes frequently.

Lifecycle

The following flow represents message exchanges between a client and a server during the subscription process.

Targets

The server can send events to the following targets (highlighted in bold):

Reference

Messages

subscription/add Message

Request to subscribe to a specific event type sent by a client.
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "subscription/add",
  "params": {
    "scope": "revision",
    "scope_id": "0A06AB3A-DD72-4D42-939A-61DC4EF69418",
    "target": "session",
    "target_id": "28E70055-DBB4-4CA8-88BC-133D6CEA68E6",
    "types": [
      "execution_started",
      "execution_ended"
    ]
  }
}
Server is expected to respond with a confirmation message indicating success:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {}
}
Or an error message indicating failure:
{
  "jsonrpc": "2.0",
  "id": 1,
  "error": {
    "code": 403,
    "message": "Access forbidden"
  }
}

subscription/remove Message

Request to unsubscribe from a specific event type sent by a client.
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "subscription/remove",
  "params": {
    "scope": "revision",
    "scope_id": "0A06AB3A-DD72-4D42-939A-61DC4EF69418",
    "target": "session",
    "target_id": "28E70055-DBB4-4CA8-88BC-133D6CEA68E6",
    "types": [
      "execution_started",
      "execution_ended"
    ]
  }
}
Request processing confirmation is delivered back to the client.

subscription/event Message

Notification sent by the server to indicate that an event has occurred.
{
  "jsonrpc": "2.0",
  "method": "subscription/event",
  "params": {
    "scope": "revision",
    "scope_id": "0A06AB3A-DD72-4D42-939A-61DC4EF69418",
    "target": "session",
    "target_id": "28E70055-DBB4-4CA8-88BC-133D6CEA68E6",
    "type": "execution_started",
    "execution": {
      "id": "452CDAC7-2ED0-4D24-8436-C6D45B34B331"
    }
  }
}

Events

Workflow Blob - session Target

{
  "jsonrpc": "2.0",
  "method": "subscription/event",
  "params": {
    "scope": "revision",
    "scope_id": string,
    "target": "session",
    "target_id": string,
    "type": string,
    ...
    }
  }
}