Create subscriptions

Subscribe to Messaging Notifications
Hint

If you are using JavaScript, the Ocelloids Client Library offers a more convenient way to interact with the services.

You can subscribe to any agent that supports messaging delivery channels using any HTTP client to receive real-time notifications.

Currently, Ocelloids supports Telegram as a messaging delivery channel, with Discord, Email, and Element coming soon.

In the examples below, we’ll use curl as the HTTP client. To create a subscription, send a POST request to the /subs endpoint with the appropriate authorization header.

For details on the full data structure, see the Subscription schema .

Example Request

This example subscribes to the OpenGov API and delivers notifications to a Telegram chat.

Please replace <YOUR_API_KEY>1, <YOUR_TELEGRAM_CHAT_ID>2 and <YOUR_TELEGRAM_BOT_TOKEN> with your own values.

Subscribe Request
curl \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-d '{
    "agent": "opengov",
    "id": "my-opengov-telegram-sub",
    "args": {
      "networks": ["urn:ocn:polkadot:0"]
    },
    "channels": [{
      "type": "telegram",
      "chatId": "<YOUR_TELEGRAM_CHAT_ID>",
      "token": "<YOUR_TELEGRAM_BOT_TOKEN>"
    }]
}' \
https://api.ocelloids.net/subs
Receive Polkadot OpenGov proposal updates in Telegram

On success, the server returns HTTP 201, and the Telegram bot will start delivering messages to your chat.

Templates

For Telegram, the default message formatting is MarkdownV2. You can also choose HTML or Markdown in your subscription settings if preferred.

Ocelloids allows you to define custom templates to transform notification messages before delivery. Templates are processed using Handlebars external link , giving you full flexibility to access and format payload data.

If no template is provided, the agent’s default template will be applied (if available). For example, the OpenGov agent has the following default template:

Default OpenGov Template
*Referendum {{payload.id}}*
{{#if payload.content.title}}
_{{escapeMarkdownV2 payload.content.title}}_
{{/if}}

*{{payload.humanized.status}}*

{{chain payload.chainId}}
{{~#if payload.info.origin.value.type}}
 · {{payload.info.origin.value.type}}
{{/if}}

{{~#if payload.timeline.willExecuteAtUtc}}
Execute at {{date payload.timeline.willExecuteAtUtc}}
{{/if}}

{{#if payload.content.link}}
[Open in Subsquare]({{payload.content.link}})
{{/if}}

  1. A valid API token with write permissions is required to create a subscription to the OpenGov API. If you don’t have a token, please contact us ↩︎

  2. You can retrieve your Telegram chat ID by messaging @userinfobot ↩︎