# Registering webhooks in Truto for Customer.io

> Source: https://truto.one/docs/integration-guides/customerio/registering-webhooks/

1. If you have not already, register a webhook in Truto. Follow this [guide](https://truto.one/docs/guides/webhooks/creating-a-webhook) to create a webhook in Truto. Please make sure it is subscribed to the following events
   - `record:created`
   - `record:updated`
   - `record:deleted`

   ![Truto webhook setup](https://docs-assets.truto.one/customerio-truto-webhook-setup.png)

2. Please make a note of the integrated account ID of the Customer.io account you'd like to register the  webhook for. Next, head on over to the Customer.io interface to create a webhook. You can find it under `Journeys > Data & Integrations > Reporting webhooks`. Click the `Add reporting webhook` button.

    ![New webhook](https://docs-assets.truto.one/customerio-new-webhook.png)

3. Enter a name for the webhook and paste the following URL into the `Webhook URL` field. Replace `{{INTEGRATED_ACCOUNT_ID}}` with the integrated account ID you noted in step 2.
   ```
   https://api.truto.one/integrated-account-webhook/{{INTEGRATED_ACCOUNT_ID}}
   ```
4. Select the events you'd like to receive notifications for.
   
   ![Enter webhook url](https://docs-assets.truto.one/customerio-enter-webhook-url.png)
   
5. Save the webhook.
6. In the webhook list screen, click the 3-dots icon for the webhook you just registered and click `Copy signing key`.

    ![Copy signing key](https://docs-assets.truto.one/customerio-copy-signing-key.png)

7. Head on over to the integrated account details page in Truto and click `Edit varaibles` button in the Variables section of the Details tab. Click `Add variable` and enter `webhook_secret` under the `Name` field and paste the signing key you copied in step 6 under the `Value` field. Click `Save`.

    ![Click edit variables](https://docs-assets.truto.one/customerio-click-edit-variables.png)

    ![Enter webhook secret](https://docs-assets.truto.one/customerio-enter-webhook-secret.png)

8. You're all set! Truto will now send notifications to the webhook URL you registered in Customer.io whenever a record is created, updated, or deleted in the integrated account.

## Example webhook event

```json
{
  "id": "64fbf363-7ba3-4745-8c7b-730c0fdbf40d",
  "event": "record:created",
  "payload": {
    "resource": "customerio/events",
    "records": [
      {
        "data": {
          "action_id": 42,
          "campaign_id": 23,
          "content": "Welcome to the club, we are with you.",
          "customer_id": "user-123",
          "delivery_id": "RAECAAFwnUSneIa0ZXkmq8EdkAM==",
          "headers": {
            "Custom-Header": [
              "custom-value"
            ]
          },
          "identifiers": {
            "id": "user-123"
          },
          "recipient": "test@example.com",
          "subject": "Thanks for signing up"
        },
        "event_id": "01E2EMRMM6TZ12TF9WGZN0WJQT",
        "metric": "sent",
        "object_type": "email",
        "timestamp": "2024-02-16T14:27:36.000Z"
      }
    ],
    "integrated_account_id": "37440f42-0e20-442e-a98d-04b2766247cc",
    "raw_event_type": "email.sent",
    "raw_payload": {
      "data": {
        "action_id": 42,
        "campaign_id": 23,
        "content": "Welcome to the club, we are with you.",
        "customer_id": "user-123",
        "delivery_id": "RAECAAFwnUSneIa0ZXkmq8EdkAM==",
        "headers": {
          "Custom-Header": [
            "custom-value"
          ]
        },
        "identifiers": {
          "id": "user-123"
        },
        "recipient": "test@example.com",
        "subject": "Thanks for signing up"
      },
      "event_id": "01E2EMRMM6TZ12TF9WGZN0WJQT",
      "metric": "sent",
      "object_type": "email",
      "timestamp": 1708093656
    }
  },
  "environment_id": "ac15abdc-b38e-47d0-97a2-69194017c177",
  "created_at": "2024-02-16T14:27:36.805Z",
  "webhook_id": "15d12ab3-64a8-450e-a185-ead081cee0e4"
}
```
