Skip to main content

Webhooks

Use webhooks to subscribe to updates on particular events that occur in Goodstack. Each time an event that you have subscribed to occurs, Goodstack submits a POST request to the designated webhook URL with information about the event.

To receive webhook notifications, use the webhook subscriptions API.

Attributes​

At the top level Webhook payloads will contain object and data fields. The data record contains the following fields:

ParameterTypeDescription
idstringId of the event
createdAtstringTimestamp of when the event was created
eventTypestringThe type of the event e.g. validation_request.approved
eventDataobjectData associated with the event

Webhook notifications​

The full list of IP addresses that webhook notifications may come from.

Production environment:

  • 54.76.67.168
  • 34.248.188.89
  • 34.243.152.218

Sandbox environment:

  • 54.76.168.240
  • 99.81.243.145
  • 54.220.118.167

Webhook responses​

To acknowledge receipt of a webhook notification, your endpoint must return a 2xx HTTP status code.

If the webhook is not received successfully then Goodstack will resend the webhook 4 times over the next 14 hours with increasing delays between retries.

The id of the event can be used to uniquely identify the event. We recommend making the processing of these events idempotent. While rare it is possible for multiple webhooks to be sent for the same event.

Verifying webhooks​

To verify that the webhook payload is sent from Goodstack, a header Percent-Signature is included in the request, this signature is generated using HMAC with SHA-256 hashing algorithm and Hex encoded. The webhook subscription secret is used as the key.

You can compute this signature using HMAC with the SHA-256 hash function, using the webhook subscription secret as the key, and the request body as the message. You can then check that the Percent-Signature value matches the computed value, verifying that the webhook was sent from Goodstack.

If you are subscribed to webhook notifications for updates on the status of verification or donation events, you can verify that webhooks sent to your infrastructure are genuine by verifying the webhook signature.

info

Get in contact for support with webhook verification on any systems not listed below

const crypto = require('crypto')
const app = require('express')

const endpointSecret = 'sk_xxxxxxxxxxxxxxxxxxxxxxxx'

const verifySignature = (secret, payload, signature) => {
const hmac = crypto.createHmac('sha256', secret)
hmac.write(payload)
hmac.end()
return hmac.read().toString('hex') === signature
}

app.post('/webhook', bodyParser.raw({type: 'application/json'}), (request, response) => {
const payload = request.body
const sig = request.headers['Percent-Signature']

if (!verifySignature(endpointSecret, payload, sig)) {
response.status(403).send()
}

// perform business logic based on event

response.status(202)
})