> The index of all pages is at https://docs.afffast.com/llms.txt.

# Destinations

Send your conversions and events to Google Sheets, BigQuery, Slack or Google Analytics 4.

A destination sends the conversion changes and the events of your workspace to another system. A webhook sends a request to your own server. A destination sends data to a tool that you already use. You set it up one time, and the API does the rest.

## Types

Read the types and their fields with `GET /v1/destination_types`. Each type has `config_fields` (settings) and `credential_fields` (secrets).

| Type               | What it does                                                                | Fields                                                                                                 |
| ------------------ | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| Google Sheets      | Writes one row for each conversion. A change updates the row.               | `spreadsheet_id`, `sheet_name`, `events_sheet_name`. Credential: `service_account_json`.               |
| BigQuery           | Appends one row for each change of a conversion.                            | `project_id`, `dataset`, `table`, `location`, `create_if_missing`. Credential: `service_account_json`. |
| Slack              | Posts a message for each change and event. It can also post a daily digest. | `channel`. Credential: `bot_token` (starts with `xoxb-`; the app needs the scope `chat:write`).        |
| Google Analytics 4 | Sends conversions as events with the Measurement Protocol.                  | `measurement_id`, `event_name`, `client_id_subid`, `region`. Credential: `api_secret`.                 |

The `GET /v1/destination_types` response is the source of truth. It has the description and the options of each field.

## Make a destination

You need an API key with the scope `destinations:write`.

```bash
curl -X POST https://api.afffast.com/v1/destinations \
  -H "Authorization: Bearer $AFFFAST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "slack",
    "label": "Conversions channel",
    "config": { "channel": "C0123456789" },
    "credentials": { "bot_token": "xoxb-..." }
  }'
```

The API checks `config` and `credentials` with the fields of the type. It encrypts the credentials. It never returns them. The response shows `credentials_fields_set`: the names of the credential fields that have a value.

A destination has the mode of your key. A test key makes a destination that gets test data only.

## What a destination gets

- By default: `conversion.created`, `conversion.status_changed` and `conversion.updated`. Use `event_types` to choose other event types. See [Webhooks](https://docs.afffast.com/docs/webhooks.md) for the list.
- A conversion with a click gets one more `conversion.updated` item when the click context is joined (usually within minutes, up to 48 hours). This item has the page and the site of the click.
- Only the changes that come **after** you make the destination. Use a backfill to send old conversions.
- `filters` limit the data. You can filter by networks and by sites.

## Test a destination

`POST /v1/destinations/{id}/test` sends one test item. The response is always 200. `ok` says if the destination accepted the item. When `ok` is `false`, `reason` says why. The test does not change the status of the destination.

## Delivery

- Delivery is **at least once**. A destination can get an item two times. Use the ID of the change (`cev_...`) or the ID of the event (`evt_...`) to remove duplicates. Google Sheets updates the row of the conversion. BigQuery appends a row for each version.
- The API sends the items in the order of their commit. A new item reaches the destination in seconds.
- When the destination fails, the API tries again with a growing wait (15 seconds at first, doubled for each attempt, 8 attempts). After the last attempt the status is `failed`. The API then sends nothing more.
- A failed destination writes the event `destination.failed`. The owners and admins get an email.
- To start again, fix the problem. Send new credentials, or send `PATCH /v1/destinations/{id}` with `"status": "active"`.
- `"status": "paused"` stops the delivery. A paused destination keeps its place and gets the items that came in the time of the pause.

## Backfill

A backfill sends the current state of each conversion of a date range, one time. Use it for a new Google Sheet or BigQuery table.

```bash
curl -X POST https://api.afffast.com/v1/destinations/dest_.../backfill \
  -H "Authorization: Bearer $AFFFAST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "from": "2026-01-01", "to": "2026-11-21" }'
```

- The range is 366 days at most.
- The destination must select a conversion event type.
- While the backfill runs, the live delivery waits. The changes that come in this time go out after the last page, so no change is lost.
- Only one backfill runs for a destination. A second request returns 409.
- Slack does not take a backfill. It would post one message for each old conversion. Google Analytics 4 takes only the last 72 hours.
- Read the progress in the field `backfill` of the destination. You can also send `backfill` when you make the destination.

## Daily digest

A type that supports it can send a daily digest. Only Slack supports it now. Use the field `digest` when you make or change a destination. Read `digest` of the destination type to see if the type supports it.
