> ## Documentation Index
> Fetch the complete documentation index at: https://docs.botflow.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Flow builder API

> External access to a bot by API key: get subscriber data and start a funnel with a callback from your own scripts and services.

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.

**1. Create a key**

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

**2. 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:

| Permission | What it allows |
| - | - |
| **Read subscriber information** | Getting a subscriber's data. |
| **Start the bot** | Starting a funnel in the bot by sending a callback. |

> [!NOTE]
>
> 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:

```text theme={null}
Authorization: Bearer YOUR_KEY
```

The base address of every request:

```text theme={null}
https://botflow.cc/api/v1/bot
```

## 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"

| Parameter | Description |
| - | - |
| `telegram_id` | The subscriber's Telegram ID, an integer. |

```bash theme={null}
curl https://botflow.cc/api/v1/bot/subscribers/123456789 \
  -H "Authorization: Bearer YOUR_KEY"
```

The response:

```json theme={null}
{
  "telegram_id": 123456789,
  "first_name": "Ann",
  "last_name": null,
  "username": "ann",
  "tag": "vip",
  "is_blocked": false,
  "subscribed_at": "2026-08-20T10:00:00+00:00",
  "variables": { "plan": "gold" }
}
```

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"

| Parameter | Description |
| - | - |
| `telegram_id` | The subscriber's Telegram ID, an integer. |
| `callback_text` | The callback value, from 1 to 256 characters. It is caught by "On button press" arrows and by start conditions with the same value. |

```bash theme={null}
curl -X POST https://botflow.cc/api/v1/bot/fire-callback \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"telegram_id": 123456789, "callback_text": "start_promo"}'
```

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:

```json theme={null}
{ "status": "accepted" }
```

### 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:

```text theme={null}
Idempotency-Key: promo-2026-09-27-123456789
```

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.

> [!NOTE]
>
> 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](https://docs.botflow.cc/en/bot-settings.md#activity), 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](https://docs.botflow.cc/en/constructor.md). 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.

| Code | What it means |
| - | - |
| **401** | An invalid or disabled key, or the employee who created the key is deactivated. |
| **403** | The key lacks the required permission. |
| **404** | The subscriber was not found (for the subscriber data request). |
| **409** | The same `Idempotency-Key` arrived with a different request body. |
| **413** | The request body is larger than 64 KB. |
| **422** | Invalid request parameters. |
| **423** | Working with the bot is temporarily unavailable: check the company balance or contact support. |
| **429** | The request rate limit was exceeded. |
| **503** | The request could not be accepted for now, repeat it later. |

## What's next

> [card] [Flow builder](https://docs.botflow.cc/en/constructor.md)
>
> Blocks, conditions and the "Send API request" action, which can also send a callback.

> [card] [Variables](https://docs.botflow.cc/en/variables.md)
>
> Which subscriber data is available and what it is called.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.