Send a webhook action from Customer.io to a public api
A custom webhook can pass data to just about any public API on the internet. You can use it to send a text message, update a CRM or take just about any action on a customer that you’d want to do.
With a little trial and error, you should be able to connect Customer.io to another service you’re using. This guide will give you some basics to help you get started.
Creating a webhook action
In the workflow for a campaign, you can click to Add workflow item…

…and choose a webhook from the resulting modal:

After adding a Webhook, click Add Request to go into the message composer.

HTTP Request Types
Customer.io webhook actions support 4 common HTTP request types for RESTful APIs:
- GET
- POST
- PUT
- DELETE
The one you use is dependent on what the API you’re using is expecting. Post is most likely to be used and is the default.
Headers
You can customize the headers that Customer.io sends with each request in order to support things like:
- Specifying the Content-Type
- Supporting other types of Authentication
- Setting other specific headers required for a specific API
By default, we pre-fill: Content-Type: application/json
Other example “Content-Type”s are: x-www-form-urlencoded, text/plain, text/xml.
We’d recommend working with APIs using Content-Type: application/json if possible for readability.
Headers: Basic Auth If your API requires Basic Authentication, you’ll add the username and password to the request like: https://user:pass@api.example.com
Structuring content for a webhook (JSON)
If you’re using Content-Type: application/json, you’ll want to make sure you’re using fully formed JSON.
A good place to test this is:
A simple example for valid JSON is:
{
"id":"1",
"email":"win@customer.io"
}You’d create something like this by putting this text in to the editor:
{
"id":"{{customer.id}}",
"email":"{{customer.email}}"
}
Then clicking “Preview”
A slightly more advanced example is:
{
"customer":
{{ customer | replace: "=>", ":"}}
}That will output the entire customer object in JSON format.
Structuring content for a webhook (Form encoded)
If you want to send a form encoded webhook, you’ll set the Content-type header as: x-www-form-urlencoded
Then, the body needs to be valid form encoded text. Something like:
id=1&email=win@customer.io&custom_attribute=value The downside of form encoded is that it’s a bit harder to structure and read since there are no line breaks and separation other than the “&” characters that join everything together.
Testing your requests
If you’d like to test the format of your requests before pointing them at the correct API, you could se a service like Requestbin. You’d create a Bin URL on the RequestBin site and paste that in to Customer.io as the URL.
More ideas & examples
If you’re looking to see some real world examples, take a look at some of our walk throughs.