Manage Webhooks

List Webhook

You can list all the webhooks within your organization by making a GET request to the endpoint:
{{baseUrl}}/api/v1/webhooks

Sample Request to list all webhook in an organization

curl --request GET \
     --url https://api.sandbox.getanchor.co/api/v1/webhooks \
     --header 'accept: application/json' \
     --header 'x-anchor-key: <API Key>'

Fetch Webhook

You can fetch a specific webhook by calling the endpoint {{baseUrl}}/webhooks/{webhookId}

VerbURL
GET{{baseUrl}}/api/v1/webhooks/{webhookId}

Below are sample payload to fetch s webhook by id and the sample response.

curl --request GET \
     --url https://api.sandbox.getanchor.co/api/v1/webhooks/16947894433490-anc_wk \
     --header 'accept: application/json' \
     --header 'x-anchor-key: <API Key>'
{
  "data": {
    "id": "16947894433490-anc_wk",
    "type": "Webhook",
    "attributes": {
      "createdAt": "2023-09-15T14:50:43",
      "allEventsEnabled": false,
      "deliveryMode": "AtLeastOnce",
      "secretToken": "123123",
      "enabledEvents": [
        "nip.transfer.initiated",
        "nip.transfer.failed",
        "nip.transfer.successful",
        "nip.incomingTransfer.received",
        "nip.transfer.reversed"
      ],
      "label": "Test",
      "url": "https://webhook.site/f97dc7a1-1eb1-4c19-a8c6-214ac42ca972",
      "status": "Enabled",
      "supportIncluded": true
    }
  }
}

Delete Webhook

You may delete a webhook at any time by making a DELETE request to the endpoint {{baseURL}}/api/v1/webhooks/{webhookId} and pass the webhook Id.

curl --request DELETE \
     --url https://api.sandbox.getanchor.co/api/v1/webhooks/169679338650118-anc_wk \
     --header 'accept: application/json' \
     --header 'x-anchor-key: <API Key>'

Retry Webhook

In certain situations, webhook requests can be delivered multiple times. This can occur, for example, when Anchor does not receive a 200 response and retries the delivery. It is important for your application to be able to handle these duplicate requests effectively. One approach is to implement a check on the event ID to ensure that duplicate requests are appropriately managed.

📘

We have a delivery backoff policy of 26 times. This means that When AtLeastOnce is selected when creating a webhook, we will try to send a webhook to you 26 times before backing off.

Send Sample Event to a Webhook

Sample Request to resend a webhook event

curl --request POST \
     --url https://api.sandbox.getanchor.co/api/v1/webhooks/verify/16947894433490-anc_wk \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'x-anchor-key: <API Key>' \
     --data '
{
  "data": {
    "type": "Webhook",
    "attributes": {
      "eventType": "virtualNuban.closed"
    }
  }
}
'
{
    "data": {
        "id": "0",
        "attributes": {
            "request": {
                "id": "012345678901249-anc_et",
                "type": "virtualNuban.closed",
                "attributes": {
                    "createdAt": "2024-05-24T14:29:10.80233"
                },
                "relationships": {
                    "settlementAccount": {
                        "data": {
                            "id": "0004702294260-anc_acc",
                            "type": "DepositAccount"
                        }
                    },
                    "virtualAccount": {
                        "data": {
                            "id": "0000002334070-anc_va",
                            "type": "VirtualNuban"
                        }
                    }
                }
            },
            "response": "\"Error reaching client's webhook endpoint\"",
            "responseCode": 504
        }
    }
}