Skip to main content

Setup

To configure a static webhook destination, specify the Webhook URL and Authorization type in the webhook integration setup page.

Profile Requirements

To deliver an HTTP request, Courier must be provided with a destination.

Dynamic Destination

If you need to specify the webhook destination on a per-recipient basis, choose “Dynamic Destination” and pass the information in the recipient profile as webhook.
{
  "message": {
    "to": {
      "webhook": {
        "url": "https://www.example.com",
        "method": "POST",
        "headers": {
          "Content-Type": "application/json"
        },
        "authentication": {
          "mode": "basic",
          "username": "AzureDiamond",
          "password": "hunter2"
        },
        "profile": "expanded"
      }
    }
  }
}

Authentication

The webhooks provider supports basic and bearer authentication. Set authentication.mode to basic or bearer and provide the credentials. Authentication defaults to none if not provided.
{
  "mode": "basic",
  "username": "AzureDiamond",
  "password": "hunter2"
}
{
  "mode": "bearer",
  "token": "ABCDEFG123456"
}

Expanded Profile

You can control what profile information is included in the request payload by setting profile to either limited or expanded. The default is limited, which only includes profile data provided when the send API was called. Setting expanded includes profile data merged from the profile database.

Request Payload

Based on how the profile is configured, the webhook provider sends the following payload using what was passed into the send method.
{
  "message": {
    "template": "NOTIFICATION_TEMPLATE_ID",
    "to": {
      "email": "stan.pines@mysteryshack.com",
      "phone_number": "+12025550165"
    },
    "data": {
      "name": "Stan Pines",
      "location": "Gravity Falls, OR"
    }
  }
}

Overrides

You can use a provider override to replace what Courier sends to the destination. The url, method, headers, and body fields are all overridable.
{
  "message": {
    "template": "NOTIFICATION_TEMPLATE_ID",
    "data": {
      "hello": "world"
    },
    "providers": {
      "webhook": {
        "override": {
          "url": "https://www.example.com",
          "method": "PUT",
          "headers": {
            "X-Custom-Header": "Hello from Courier"
          },
          "body": {
            "key": "value"
          }
        }
      }
    }
  }
}