In this article, I will explain how to create, enable/disable and delete webhooks in Firmhouse. You can view all available webhook events in our developer documentation.
Setting up webhooks in Firmhouse
Creating a webhook in Firmhouse is a simple three-step process.
Get the webhook URL from the application you want the data sent to.
Use that URL in the webhook section in Firmhouse.
Set up what events you want your webhook to listen to and notify you about when it occurs.
To show how this works, we will be using RequestBin to receive the data sent via Firmhouse webhooks.
Creating a RequestBin endpoint
Steps:
Go to RequestBin and click Create a public bin instead. This will generate an endpoint URL.
Copy the endpoint URL from the page. This is the webhook URL your payload is going to be sent to.
Create a webhook in Firmhouse
Listed below are the steps to set up a webhook in Firmhouse.
Steps:
Navigate to Apps in the sidebar.
Find the Webhooks app and click Configure.
Click New outgoing webhook on the top-right.
Enter a Name for the webhook, such as "Activated subscription"
In the Endpoint url field enter the URL you want to receive the web hook. For this example we will be using the URL we copied earlier from RequestBin (Note that we are using RequestBin just to test how Webhooks work). This is where the data will be sent once the webhook is triggered. The URL will receive an HTTP POST request when the selected event happens.
If you intend to use Basic authentication to secure your webhook, provide the Username and Password of the HTTP Basic auth otherwise leave Authentication type on None.
From the Event dropdown, select the event you want to be notified about. In this case, I want to be notified when a subscription is activated. Choose Subscription activated.
In the Template field, paste the following snippet:
{
"event": "subscription activated",
"id": {{subscription.id}}
}
Note that the example above uses a JSON format and Liquid tag for the payload. You can also use XML or other format to configure your template. Learn more about Liquid tags in Firmhouse here.
Click Save to save the outgoing webhook.
Next, start a subscription in Firmhouse via your regular checkout and activate the subscription to trigger your saved webhook.
Return to Requestbin and click on the new Post option to see the information that Firmhouse sent over from the outgoing webhook.
Enable or disable a webhook
You can decide to enable or disable your outgoing webhook temporarily without having to delete the webhook itself or it’s content.
Steps:
Navigate to Apps in the sidebar.
Find the Webhooks app and click Configure to open a list of already saved outgoing webhooks.
Click on the particular webhook you want to enable/disable and click edit.
To enable or disable the webhook, you need to check or uncheck the Enable checkbox, respectively.
Click Save to save the outgoing webhook.
Editing a webhook
Firmhouse allows you to edit the configuration of your webhooks.
Steps:
Navigate to Apps in the sidebar.
Find the Webhooks app and click Configure to display a list of already saved outgoing webhooks.
Click on the webhook that you want to edit and click on the Edit button.
Make the necessary changes to the configuration fields of the webhook.
Click Save to save the changes.
Deleting a webhook
Firmhouse allows you to delete webhooks you no longer need.
Steps:
Navigate to Apps in the sidebar.
Find the Webhooks app and click Configure to display a list of already saved outgoing webhooks.
Click on the Remove button on the far right of the webhook that you want to delete.
You will get a prompt “ Are you sure you want to remove this outgoing webhook? “ , click Ok to confirm delete action.