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

# fact_campaign_sends

> Every outbound campaign message with its full delivery lifecycle.

# fact\_campaign\_sends

Each row is one outbound message of a campaign to one recipient, with its complete delivery lifecycle: scheduled → sent → delivered → responded, or the exact failure reason. This replaces the legacy `fact_deployment_status`.

## What questions does it answer?

* What is the delivery and response rate of each campaign?
* Which specific recipients failed, and why?
* How long does the journey scheduled → delivered → responded take?
* Which sends were retried?
* How much traffic comes from each channel — API, file uploads, CRM integrations (`origin`)?

## Columns

| Column              | Type       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `deployment_id`     | String     | Unique identifier of the send (56-character hex)                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `company_id`        | Int32      | Your company (filtered automatically)                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `batch_id`          | String     | The batch this send belongs to (one campaign execution)                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `status`            | String     | Current lifecycle status. Success path: `DELIVERED`, `SUCCESS` (sent, delivery not yet confirmed). In flight: `RECEIVED`, `RECEIVED_BY_WORKER`, `RETRY`. Cancelled: `REVOKED`. Rejected before sending: `INVALID_PHONE`, `INVALID_POLL`, `MISSING_PARAMETER`, `PARAMETER_MISMATCH`, `VALIDATION_ERROR`. Failed: `FAILURE` and the `FAILURE_BY_*` family (`_UNABLE_TO_CONTACT`, `_DISABLED_HSM`, `_META_CHOSE_NOT_DELIVER`, `_HUMAN_HANDOVER`, `_OPTOUT_CONTACT`, `_RATE_LIMIT`, and others) |
| `retries`           | Int32      | Number of retry attempts                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `poll_id`           | Int32      | Flow the campaign triggers                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `poll_name`         | String     | Flow name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `origin`            | String     | Where the send came from: `API`, `CSV` (file upload in the platform), `SIMPLE` (direct send from the platform), `APP_INTEGRATION`, `HELPDESK_INTEGRATION`                                                                                                                                                                                                                                                                                                                                   |
| `origin_id`         | Int32      | Identifier of the origin: the platform user who launched it (`CSV`/`SIMPLE`), the integration that triggered it (`APP_INTEGRATION`/`HELPDESK_INTEGRATION`), or the id provided by the API caller; `0` when not set                                                                                                                                                                                                                                                                          |
| `scheduled_at`      | DateTime64 | When the send was scheduled                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `received_at`       | DateTime64 | When WhatsApp accepted the message; `NULL` if it didn't happen                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `delivered_at`      | DateTime64 | When it reached the user's phone; `NULL` if it didn't happen                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `responded_at`      | DateTime64 | When the user replied; `NULL` if they didn't                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `failed_at`         | DateTime64 | When it failed; `NULL` on success                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `succeeded_at`      | DateTime64 | When it was confirmed successful; `NULL` otherwise                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `cellphone`         | String     | Recipient's phone number                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `country_code`      | String     | Recipient's country code                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `treble_id`         | String     | Contact identity (country code + cellphone)                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `business_scope_id` | String     | WhatsApp business-scoped user id, when available                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `username`          | String     | WhatsApp username, for contacts without a phone number                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `scheduled`         | Bool       | `true` if the send was scheduled for a future time instead of sent immediately                                                                                                                                                                                                                                                                                                                                                                                                              |
| `synced_at`         | DateTime64 | When this row was last written/corrected                                                                                                                                                                                                                                                                                                                                                                                                                                                    |

<Note>
  Statuses keep changing while a campaign is in flight. Per [the data contract](/en/docs/data-warehouse-v2/welcome#the-data-contract), a day's figures consolidate fully within 48 hours — the warehouse updates each row in place as its status advances.
</Note>

## Example queries

### Campaign scorecard

```sql theme={null}
SELECT
    poll_name,
    count()                                   AS sends,
    countIf(delivered_at IS NOT NULL)         AS delivered,
    countIf(responded_at IS NOT NULL)         AS responded,
    round(100.0 * delivered / sends, 1)       AS delivery_pct,
    round(100.0 * responded / delivered, 1)   AS response_of_delivered_pct
FROM fact_campaign_sends
WHERE scheduled_at >= today() - 30
GROUP BY poll_name
ORDER BY sends DESC
```

### Failed recipients of one batch

```sql theme={null}
SELECT cellphone, status, retries, failed_at
FROM fact_campaign_sends
WHERE batch_id = '{your_batch_id}'
  AND failed_at IS NOT NULL
ORDER BY failed_at
```

### Time to response

```sql theme={null}
SELECT
    poll_name,
    round(avg(dateDiff('minute', delivered_at, responded_at)), 1) AS avg_minutes_to_reply
FROM fact_campaign_sends
WHERE scheduled_at >= today() - 30
  AND delivered_at IS NOT NULL
  AND responded_at IS NOT NULL
GROUP BY poll_name
```
