# Webhook Payload

This section goes over the different types of webhook messages that you can receive.\
**Currently, Connectly only supports WhatsApp messages.**

{% hint style="info" %}
**`callbackData`** — If you set the optional `callbackData` field when sending a message (see [Send session message](/message-api/message-service-api/messageservice/send-session-message.md) and [Send template message](/message-api/message-service-api/messageservice/send-template-message.md)), Connectly echoes it back at the **top level** of webhook events for that message:

* **Delivery status** events — `sent`, `delivered`, `read`, and `delivery_failed`.
* **Inbound replies** that reference the original message — quoted text/media replies, interactive button & list replies, and reactions.

`callbackData` is only present when it was set on the original outbound message. Plain-text replies that don't quote a message do not include it.
{% endhint %}

{% hint style="info" %}
**Business-scoped user IDs (BSUID)** — on WhatsApp numbers with BSUID support enabled, the customer identifier (`sender` on inbound webhooks, `recipient` on delivery-status webhooks) carries `userId` (the customer's BSUID) and `phoneNumber`. For phone-less customers, `id` holds the BSUID and `phoneNumber` is `""`. See Business-scoped user IDs (BSUID).
{% endhint %}

### Payload plain text:

JSON

```json
{
  "timestamp": "1639083206",
  "sender": {
    "id": "+16315555500",
    "channelType": "whatsapp",
    "name": "Vasi from Connectly"
  },
  "recipient": {
    "id": "+16044441234",
    "channelType": "whatsapp",
    "name": "connectlyai"
  },
  "message": {
    "text": "TEST 11"
  }
}
```

### Payload with referral

JSON

```json
{
  "timestamp": "1639083206",
  "sender": {
    "id": "+16315555500",
    "channelType": "whatsapp",
    "name": "Vasi from Connectly"
  },
  "recipient": {
    "id": "+16044441234",
    "channelType": "whatsapp",
    "name": "connectlyai"
  },
  "message": {
    "text": "TEST 11",
    "referral": {
      "ctwaClid": "Click ID generated by Meta for ads that click to WhatsApp",
      "sourceUrl": "AD_OR_POST_FB_URL",
      "sourceId": "ADID",
      "sourceType": "ad or post",
      "headline": "AD_TITLE",
      "body": "AD_DESCRIPTION",
      "mediaType": "image or video",
      "imageUrl": "RAW_IMAGE_URL",
      "videoUrl": "RAW_VIDEO_URL",
      "thumbnailUrl": "RAW_THUMBNAIL_URL"
    }
  }
}
```

### Payload media:

JSON

```json
{
  "timestamp": "1639085537",
  "sender": {
    "id": "+16315555500",
    "channelType": "whatsapp",
    "name": "Vasi from Connectly"
  },
  "recipient": {
    "id": "+16044441234",
    "channelType": "whatsapp",
    "name": "connectlyai"
  },
  "message": {
    "attachments": [
      {
        "type": "video",
        "url": "https://cdn.dev.connectly.ai/asd/asdasdasdasd"
      }
    ]
  }
}
```

### Payload button response

JSON

```json
{
  "timestamp": "1639083206",
  "sender": {
    "id": "+16315555500",
    "channelType": "whatsapp",
    "name": "Vasi from Connectly"
  },
  "recipient": {
    "id": "+16044441234",
    "channelType": "whatsapp",
    "name": "connectlyai"
  },
  "context": {
    "replyToId": "018d62f2-2524-10fa-f857-091ab99c14c8"
  },
  "buttonResponse": {
    "text": "TEST 11",
    "payload": "1"
  },
  "callbackData": {
    "order_id": "12345"
  }
}
```

#### Payload delivery status

JSON

```json
{
  "topic": "delivery_status",
  "timestamp": "1641513098",
  "sender": {
    "id": "+16044441234",
    "channelType": "whatsapp",
    "name": "connectlyai"
  },
  "recipient": {
    "id": "+16315555500",
    "channelType": "whatsapp",
    "name": "Vasi from Connectly"
  },
  "statusUpdate": {
    "id": "01FRRWW2ZAHD9GJ1SWY4VF2GBD",
    "status": "delivered",
    "error": null,
    "metadata": {
      "campaign_name": "<YOUR_CAMPAIGN_NAME>"
    }
  },
  "callbackData": {
    "order_id": "12345"
  }
}
```

#### Payload delivery status error

JSON

```json
{
  "topic": "delivery_status",
  "timestamp": "1641512856",
  "sender": {
    "id": "+16044441234",
    "channelType": "whatsapp",
    "name": "connectlyai"
  },
  "recipient": {
    "id": "+16315555500",
    "channelType": "whatsapp",
    "name": "Vasi from Connectly"
  },
  "statusUpdate": {
    "id": "01FRRWMSAMKNFZAMBPQ65CA7DD",
    "status": "delivery_failed",
    "error": {
      "message": "Message template inputs invalid",
      "type": "ERROR_TYPE_INVALID_REQUEST",
      "code": "ERROR_CODE_MESSAGE_TEMPLATE_INPUT_INVALID",
      "userTitle": "Message template inputs invalid",
      "userMessage": "Pass along the connectly trace id 'cnct_trace_id' to the team for more information.",
      "cntTraceId": "10827968052975079261",
      "details": {
        
      }
    },
    "metadata": {
      "campaign_name": "<YOUR_CAMPAIGN_NAME>"
    }
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.connectly.ai/message-api/webhook-api/webhook-payload.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
