Webhook POST

URI

https://{DATACENTER}.brightpearl.com/public-api/{ACCOUNT}
/integration-service/webhook

Refer to our documentation on URI syntax for more information on how to construct URIs.

Description

This message enables you to create a new webhook. Once created, all matching resource events will be sent to the registered host using the parameters defined here:

Field description

Field Data type Description Required Notes
subscribeTo String Event specifier yes See the help site for a list of available events.
httpMethod String One of "GET", "POST", "PUT" or "DELETE" yes Note that only "POST" and "PUT" allow a body.
uriTemplate String Your public URL to use as the destination for webhook events. yes Can be templated as describe in this document.
bodyTemplate String HTTP request body to send as part of the webhook event. yes if httpMethod is "POST" or "PUT", otherwise no Can be templated as describe in this document.
contentType String HTTP "Content-Type" header to send as part of the webhook event. yes if httpMethod is "POST" or "PUT", otherwise no
idSetAccepted Boolean Set if webhook events should be sent with IDSET or individually. no defaults to false. It is recommended to set this to true.
qualityOfService Integer Sets the retry policy:
  • 0 = at-most-once delivery
  • 1 = at-least-once delivery
no defaults to 0. It is recommended to set this to 1.

There are two retry policies, determined by the quality of service requested:

  • QoS = 0: a failed request is retried only if the system returned 503 status code
  • QoS = 1: a failed request is always retried except for 4xx status codes
More information about the quality of service is available in the help documents.

Example

Creating a webhook which will listen to all resource messages for the Product resource it will then send a HTTP POST to http://www.example.com/callback.

Request URI

/webhook

Request body

{
	"subscribeTo": "product",
	"httpMethod": "POST",
	"uriTemplate": "http://www.example.com/callback",
	"bodyTemplate": "{ \"accountCode\": \"${account-code}\", \"resourceType\": \"${resource-type}\", \"id\": \"${resource-id}\", \"lifecycleEvent\": \"${lifecycle-event}\", \"fullEvent\": \"${full-event}\", \"raisedOn\": \"${raised-on}\", \"brightpearlVersion\": \"${brightpearl-version}\" }",
	"contentType": "application/json",
	"idSetAccepted": true,
	"qualityOfService": 0
}

Response

{
	"response": 7
}