Skip to content
Last updated

Webhooks

Webhooks are a way for Spense to notify you of events that happen in your account. When an event occurs, we send an HTTP POST request to the specified webhook URL. The body of the request contains a JSON payload with information about the event.

You specify the webhook URLs when you make requests to the API.

SSL: SSL is required for webhooks, and we will not accept webhooks over HTTP.

Whitelisting

All domains for webhooks need to be whitelisted. Please contact tech@spense.no to whitelist any domains that you want to use in your webhook URLs. If a payment creation request specifies domain that is not whitelisted, the payment creation itself won’t fail, but the webhook won’t get called.

Retries

If the webhook does not return a 2xx response code, we will retry the webhook up to 25 times. If the webhook still does not return a 2xx response code, we will stop retrying the webhook.

Back off times are as follows:

  • 5 minutes, for the first 5 retries.
  • 15 minutes, for the next 5 retries.
  • 30 minutes, for the next 5 retries.
  • 60 minutes, for the next 5 retries.
  • 24 hours, for the next 5 retries.

This amounts to a total of 7750 minutes (5 days, 9 hours, and 50 minutes) of retrying.

Setting up webhooks

You set up webhooks when you create a payment. All webhooks are optional.

Warning

The sample below is not complete, but only highlighting the payload required to set up webhooks.

curl -i -X POST \
  https://api.spense.no/api/payments \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -H 'X-Organization-Id: string' \
  -d '{
    "callback": {
      "url": "https://your-whitelisted-domain.com/callback/success",
      "terminal_failure_url": "https://your-whitelisted-domain.com/callback/terminal-failure"
    }
  }'

API Reference