Skip to main content
The flow builder API lets you reach a bot from your scripts and services with a key. Two actions are available right now: get a subscriber’s data, and start a funnel in the bot by sending a callback on the subscriber’s behalf.

Key and access

Keys are created in the bot settings, in the “API keys” section. The section is available to administrators.

Create a key

Open “Bot settings” → “API keys” → “Add API key”. Choose the permissions, set a name and press “Generate”.

Copy the value

Copy the key and paste it into your request. The value can always be viewed later with the copy button in the list.
A key’s permissions are chosen at creation and cannot be wider than your own: you cannot issue a key for reading subscriber data if that data is shown to you masked, and you cannot issue a key for starting the bot if you are not allowed to start funnels in this bot. The scopes decide which requests the key can make:
A read-only key will not work for starting a funnel. Starting needs the “Start the bot” permission.
The key is passed in the Authorization header:
The base address of every request:

Get a subscriber

Returns the data of this bot’s subscriber: name, username, tag, variables and subscription date.
  • Method and path: GET /subscribers/{telegram_id}
  • Permission: “Read subscriber information”
The response:
If the bot has no subscriber with that telegram_id, a 404 response arrives.

Start a funnel with a callback

Sends a callback into the bot on the subscriber’s behalf, as if they had pressed an inline button. That is how you start the branch of the funnel you need from your own service.
  • Method and path: POST /fire-callback
  • Permission: “Start the bot”
The response is always the same: the request is accepted. If the subscriber already exists in the target bot, the funnel starts right away; if they do not exist yet, the callback waits for them:

Repeated requests

If your service repeats a request on a timeout or a dropped connection, add an Idempotency-Key header with your own unique value per operation:
With the same key and the same body the platform returns the stored response and the funnel does not start a second time. The same key with a different body is a different operation, and such a request gets a 409 response. Without the header the behaviour is unchanged: every request starts the funnel.
A callback does not create a subscriber. If the subscriber does not exist in the target bot yet, the callback waits and fires once they message the bot, for up to 14 days. If the bot is off, its block on this callback adds and removes tags and sends API requests, but sends no messages to the subscriber, and the callback does not wait for a subscriber who is not in the bot yet. What happens to an unmatched callback, and which variables are available in the target bot, is described under Constructor, the “Another bot” action. A funnel started through the API cannot fire a callback in another bot.

Errors

On an error you get the matching response code and a body with an explanation.

What’s next

Flow builder

Blocks, conditions and the “Send API request” action, which can also send a callback.

Variables

Which subscriber data is available and what it is called.