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

# Postbacks

> Receiving conversions from affiliate networks: connecting an affiliate, matching by click_id, funnel events, sending to Facebook CAPI and automatic funnel transitions.

A postback is a message from an affiliate network saying that your subscriber performed a target action: signed
up, made a first deposit, topped up again. The affiliate sends such an event server to server, and BotFlow matches
it to a specific subscriber by `click_id` and records it in the conversion history.

The platform records the click and the bot start itself, while only the affiliate knows about a registration or a
deposit. After a postback the event is visible in the subscriber card, in reports and in the Reg2Dep, Click2FTD,
FTD, RD and EPC metrics.

## How it works

**1. You give the subscriber a link with click\_id**

The `click_id` of a specific subscriber is substituted into the advertiser's registration link. It arrives together with the move into the bot (`t.me/<bot>?start=<click_id>`) and stays tied to that person.

**2. The affiliate remembers the click\_id**

At registration the subscriber passes the `click_id` to the affiliate through a parameter of its link. The affiliate stores it next to the client's new account.

**3. The subscriber performs an action**

The subscriber registers, makes a deposit or tops up again on the advertiser's side.

**4. The affiliate sends a postback**

The affiliate sends a request to your postback URL, passing that same `click_id`, the event type and the amount.

**5. The platform matches and records it**

BotFlow finds the subscriber by `click_id`, ties the event to them and to the campaign through which they first came, and writes the conversion into the history. From there it is visible in reports, in the subscriber card and in the metrics.

> [!WARNING]
>
> `click_id` links a future deposit to a specific subscriber and campaign. It is determined at the moment the link
> is sent to the subscriber. It must not be substituted or swapped by hand: somebody else's `click_id` ties the
> money to the wrong subscriber, and a postback with a `click_id` from another company is rejected (the outcome
> `cross_tenant_rejected`).

A conversion belongs to the campaign through which the subscriber first came. If they later follow the link of
another campaign, their registration and deposits still count for the first one. A conversion goes to "Organic" only
when the subscriber first came without a campaign. The attribution has no time limit: a deposit made months after
the subscribe counts for the same campaign.

## Integrations

Receiving postbacks is set up in the tracker, on the **Postbacks** tab. Here you connect an affiliate network, see
its status and check that event reception works.

### Connecting a network

The **Add** button opens the "New integration" page. You choose a template, optionally set a name and check the
`click_id` parameter. After creation the platform shows the ready postback URLs straight away, and you copy them
into the affiliate's dashboard.

The template list has six options: Pocket Option, Quotex, Alfaleads, 1xBet, AdsEmpire and a generic one for any
other network.

> [card] A ready network template
>
> For Pocket Option and the generic template the platform hands you ready postback URLs with the `click_id` parameter substituted. All that is left is to copy them into the affiliate's dashboard.

> [card] The other templates
>
> For Quotex, Alfaleads, 1xBet and AdsEmpire the status mapping is pre-filled: you check it and take the postback URLs for your events.

> [!TIP]
>
> The name is optional, but handy if you connect several affiliates of the same type: the name is how you tell them
> apart in the list and in the conversion log.

### Status and the "Test" button

Every connected affiliate has a status (**Active** or **Disabled**) and a **Test** button. "Test" sends a test
postback with a fake `click_id` and shows the processing outcome: that is how you check the whole path from
accepting the request to writing into the conversion history, without waiting for a real deposit. Next to the
button the platform shows the test `click_id` you can find that run by in the reports.

> [!NOTE]
>
> The affiliate list is filtered by status (All, Active, Disabled) and by name. An empty list simply means no
> affiliates are connected yet.

## The integration page

Clicking an integration in the list opens its page. At the top there is the status and the "Enable" and "Disable"
buttons, and below there are tabs with all the settings.

**1. Overview**

The postback key (part of the public URL) and the `click_id` parameter the affiliate puts the click into. The key can be rotated. Old postback URLs keep being accepted for another 7 days after rotation: that is enough time to replace them in the affiliate's dashboard, after which they stop working.

**2. Postback URL**

The incoming postback URLs, one per event. The affiliate calls them to report a conversion. Copy the one you need and paste it into the postback settings in the affiliate's dashboard.

**3. Mapping**

The status mapping: on the left the status name the affiliate sends, on the right our event (registration, deposit, repeat deposit, withdrawal and others). If the affiliate sends its own status name, set the correspondence here. You can set up to 100 statuses: at the limit the "Add" button switches off and "At most 100 statuses" appears.

**4. Links**

The outgoing links for leads that you hand to subscribers. The platform substitutes the `click_id` into the final URL itself.

**5. Log**

The log of this integration's incoming postbacks: time, `click_id`, status and processing outcome. It shows whether events arrive and whether they match subscribers.

For ready affiliates (Pocket Option, say) the postback URLs and the `click_id` parameter are already configured,
and all that is left is to copy the URLs into the dashboard. When an integration is disabled, the existing links
for leads stop working, but the event history in the subscriber cards is kept.

## The generic template

If there is no ready integration, choose the generic template in the list. In the list of connections such an
integration is marked with the "Custom" type. The logic is the same, you just configure the joining by hand.

**1. Set the click\_id parameter**

Work out which parameter your affiliate writes the `click_id` into. Without that the platform cannot tell which subscriber an event belongs to.

**2. Take the ready postback URLs**

The platform gives you one URL per event. Usually you need three: registration, first deposit and repeat deposit.

**3. Paste the URLs into the affiliate's dashboard**

In the affiliate's postback settings put our `click_id`, the event type and the deposit amount into the matching URL parameters.

A postback URL passes three values: the subscriber's `click_id`, the event type and the deposit amount.

```
https://<your-postback-url>?click_id={click_id}&status=<event>&amount={amount}
```

Here `{click_id}` and `{amount}` are the affiliate's macros, which it replaces with real values at the moment of
sending, while `<event>` is the status the platform maps to its own conversion type.

> [!NOTE]
>
> The `{click_id}` and `{amount}` values in curly braces are the affiliate network's variables, not BotFlow's.
> Check your affiliate's own documentation for what those macros are called: they differ between networks.

## Which events arrive

Every postback carries an event type. The affiliate sends its own status name, and the platform maps it to its own
conversion type.

| Event | What it is |
| - | - |
| **Registration** | The subscriber signed up with the advertiser. |
| **FTD** (deposit) | A first deposit with an amount. |
| **RD** (repeat deposit) | A repeat top-up with an amount. |
| **Withdrawal** | The subscriber withdrew funds. |
| **RevShare** | A repeating event from the affiliate network. |
| **Email confirmation** | The subscriber confirmed their email. |

Deposit events (FTD and RD) carry an amount, which is exactly what the deposit amounts and EPC are calculated from. Internal
funnel events (a subscribe to the bot, a subscriber's first message, a landing view) are recorded by the platform
itself and need no postback.

> [!NOTE]
>
> Don't confuse a landing click with a bot start. A landing click is a hit on the promo page, and it may never
> reach the bot. Starting the bot with `/start` creates a subscriber and opens the funnel. A postback, meanwhile,
> attaches to a subscriber through their `click_id`. Every subscriber who came by a campaign has one, the subscribers
> of the campaigns without clicks (Telegram, "Invite link", "Organic") too: the platform issues it on the subscribe,
> though the metrics do not count it as a click. For more on the click's path see [Tracker: overview](https://docs.botflow.cc/en/tracker.md).

## Automatic funnel transitions on a postback

Besides being written into the history, a postback can move a subscriber along the funnel straight away. When an
event arrives, it is immediately available to arrows in the flow builder: if a block has an arrow set on that
event, the subscriber moves to the right step automatically. No operator is needed for that, and the AI continues
the conversation already knowing that the subscriber signed up or made a deposit.

In the [Flow builder](https://docs.botflow.cc/en/constructor.md), on an arrow between blocks, the affiliate's system events are available.
They are inserted into the arrow's condition from the "System events" list:

| Trigger event | When it fires |
| - | - |
| **Registration** | A registration postback arrived. |
| **Deposit** | A first deposit (FTD) postback arrived. |
| **Repeat deposit** | A repeat deposit (RD) postback arrived. |
| **Withdrawal** | A withdrawal postback arrived. |
| **RevShare** | A repeating event from the network arrived. |
| **Email confirmation** | The subscriber confirmed their email. |

A typical scenario: after a registration the subscriber moves to the "help them make a first deposit" step, after an
FTD to the "bring them to a repeat deposit" step, and the AI runs the conversation taking into account what has
already happened.

An arrow with a timeout does not take an event: it goes on to the "Start condition" and "Fallback" blocks. For a
transition on an event, keep the arrow without a timeout; more in
[System events and conversions](https://docs.botflow.cc/en/constructor.md#system-events-and-conversions).

> [!WARNING]
>
> An automatic transition works only for a subscriber who has a `click_id` and a funnel running in private messages
> with the bot. If the subscriber never came through a tracking link, there is nothing to match the postback
> against.

## Sending events to Facebook (CAPI)

For FB campaigns postbacks can be sent further, back to Facebook, through the Conversion API. That way the ad
algorithm learns about real deposits and optimises buying towards paying clients.

The list of events to send is set on the "Tracking" step when creating a campaign: both events from the bot
(subscribe, contact) and accepted affiliate postbacks (registration, FTD, RD). Exactly what goes to Facebook and
how to set it up is described in [Campaigns](https://docs.botflow.cc/en/campaigns.md). Setting up the domain and proxy for sending is in
[Domains and proxies](https://docs.botflow.cc/en/domains-proxies.md).

Event delivery is visible on the campaign page, the "Facebook CAPI delivery" block, and in the "Conversions"
report on the "Outgoing" tab: the statuses "Sending", "Delivered", "Failed".

## Checking and debugging

When the affiliate says "we sent an FTD" and you don't see it, there are two tools.

> [card] The «Test» button
>
> Sends a test postback and shows the processing outcome. A quick way to confirm that event reception works at all.

> [card] The «Conversions» report
>
> In the tracker, on the "Reports" tab, the log shows both incoming postbacks and outgoing events to Facebook. The search is by an exact `click_id`.

For every incoming postback the log shows the processing outcome:

| Outcome | What it means |
| - | - |
| `success` | The event was matched to a subscriber and recorded. |
| `no_click_match` | The `click_id` was not found: check that the affiliate passes the right parameter. |
| `duplicate` | Such an event already arrived and is not recorded again. |
| `invalid_status` | The event type was not mapped: check the status setup at the affiliate. |
| `invalid_token` | The postback arrived with the wrong affiliate key. |
| `rejected_transition` | An invalid order of events for this click. |
| `rate_limited` | The affiliate sent events too often and some were not accepted. |
| `cross_tenant_rejected` | The `click_id` belongs to another company. |
| `error` | The event could not be processed. Details are visible in the log row. |

> [!TIP]
>
> Most often "the postback never arrived" actually means "it arrived, but with no click match". Check the
> "Conversions" log by `click_id` first: if the row is there with the outcome `no_click_match`, the problem is the
> `click_id` parameter on the affiliate's side rather than reception.

## What's next

> [card] [S2S Postbacks](https://docs.botflow.cc/en/s2s-postbacks.md)
>
> Sending conversion events further to external services: the source tracker or your CRM.

> [card] [Tracker: overview](https://docs.botflow.cc/en/tracker.md)
>
> Campaigns, tracking links, the click's path, metrics and reports.

> [card] [Flow builder](https://docs.botflow.cc/en/constructor.md)
>
> Trigger arrows on postback events and building the funnel.

> [card] [Reports](https://docs.botflow.cc/en/reports.md)
>
> Conversion and click logs with filters and CSV export.


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