Create a webhook
POST
/webhooks(.:format)
Creates a new webhook. The provided URL should respond with a 200 HTTP status. After
creation, the URL will receive notifications when events on documents in the
administration occur. It is also possible to subscribe to certain events by adding an array
with events you would like to receive notifications from.
We strongly recommend that you use a secure HTTPS endpoint for receiving payload from Moneybird.
If you use unencrypted HTTP, anyone on the network may be able to listen in on sensitive information like contacts and invoices.
Parameters
Parameter
Type
Description
url
String
Required
events
Array[string]
enabled_events
Array[string]
Example: creates a webhook
Request
curl -s -H "Content-Type: application/json" -H "Authorization: Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" \
-XPOST \
-d '{"url":"http://www.mocky.io/v2/5185415ba171ea3a00704eed"}' \
https://moneybird.com/api/v2/123/webhooks.json
data = { :url => "http://www.mocky.io/v2/5185415ba171ea3a00704eed" }
RestClient . post (
"https://moneybird.com/api/v2/123/webhooks.json" , data ,
{ authorization: "Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" }
)
Response
Status: 201 Created
{
"id" : "433546379320624293" ,
"administration_id" : 123 ,
"url" : "http://www.mocky.io/v2/5185415ba171ea3a00704eed" ,
"events" : [
],
"enabled_events" : [
],
"last_http_status" : null ,
"last_http_body" : null ,
"token" : "gX3Bo7mGu39ySHpA84qRUtM1"
}
Example: creates a webhook that is subscribed to events
Request
curl -s -H "Content-Type: application/json" -H "Authorization: Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" \
-XPOST \
-d '{"url":"http://www.mocky.io/v2/5185415ba171ea3a00704eed","events":["contact_created"]}' \
https://moneybird.com/api/v2/123/webhooks.json
data = { :url => "http://www.mocky.io/v2/5185415ba171ea3a00704eed" ,
:events => [ "contact_created" ]}
RestClient . post (
"https://moneybird.com/api/v2/123/webhooks.json" , data ,
{ authorization: "Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" }
)
Response
Status: 201 Created
{
"id" : "433546379401364649" ,
"administration_id" : 123 ,
"url" : "http://www.mocky.io/v2/5185415ba171ea3a00704eed" ,
"events" : [
"contact_created"
],
"enabled_events" : [
"contact_created"
],
"last_http_status" : null ,
"last_http_body" : null ,
"token" : "gyKNevDWjrfaz2QgiZyB9jkH"
}
Example: creates a webhook that is subscribed to enabled_events
Request
curl -s -H "Content-Type: application/json" -H "Authorization: Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" \
-XPOST \
-d '{"url":"http://www.mocky.io/v2/5185415ba171ea3a00704eed","enabled_events":["contact_created"]}' \
https://moneybird.com/api/v2/123/webhooks.json
data = { :url => "http://www.mocky.io/v2/5185415ba171ea3a00704eed" ,
:enabled_events => [ "contact_created" ]}
RestClient . post (
"https://moneybird.com/api/v2/123/webhooks.json" , data ,
{ authorization: "Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" }
)
Response
Status: 201 Created
{
"id" : "433546379495736493" ,
"administration_id" : 123 ,
"url" : "http://www.mocky.io/v2/5185415ba171ea3a00704eed" ,
"events" : [
"contact_created"
],
"enabled_events" : [
"contact_created"
],
"last_http_status" : null ,
"last_http_body" : null ,
"token" : "bdJV1X4gbs37UmJpAiNQJhZ1"
}
Example: returns an error when both events and enabled_events are provided
Request
curl -s -H "Content-Type: application/json" -H "Authorization: Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" \
-XPOST \
-d '{"url":"http://www.mocky.io/v2/5185415ba171ea3a00704eed","events":["contact_created"],"enabled_events":["contact_created"]}' \
https://moneybird.com/api/v2/123/webhooks.json
data = { :url => "http://www.mocky.io/v2/5185415ba171ea3a00704eed" ,
:events => [ "contact_created" ],
:enabled_events => [ "contact_created" ]}
RestClient . post (
"https://moneybird.com/api/v2/123/webhooks.json" , data ,
{ authorization: "Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" }
)
Response
Status: 400 Bad Request
{
"error" : "Cannot provide both 'events' and 'enabled_events', use non-deprecated 'enabled_events'" ,
"symbolic" : {
"events" : "conflict"
}
}
Example: returns an error when fields are not provided
Request
curl -s -H "Content-Type: application/json" -H "Authorization: Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" \
-XPOST \
-d '{}' \
https://moneybird.com/api/v2/123/webhooks.json
data = {}
RestClient . post (
"https://moneybird.com/api/v2/123/webhooks.json" , data ,
{ authorization: "Bearer 84ec207ad0154a508f798e615a998ac1fd752926d00f955fb1df3e144cba44ab" }
)
Response