Set up a webhook destination
To receive webhooks for all events across the Layer1 platform, you need to set up at least one webhook destination.
For the complete list of all possible webhook events that can be sent to your destination, see the Webhooks section of the guides. It also includes a guide on validating those webhooks.
To create a destination address to which all webhooks of a specific subscribed event will be sent, send the POST /notification/v1/destinations request with the following body parameters:
{
"url": "https://hooks.slack.com/services/T88HSLB/B08360RN3/sh6EydWDblDf",
"type": "SLACK",
"events": [
"layer1:crypto:address:created",
"layer1:crypto:deposit:status-change",
"layer1:crypto:withdrawal:status-change",
"layer1:crypto:consolidation:status-change",
"layer1:notification"
]
}
Within the events array, the following events are available for subscription and triggered when:
- A new trade conversion is created:
layer1:trade:conversion:created. - The state of a trade conversion changes:
layer1:trade:conversion:state-changed. - A new address is created at a trading venue:
layer1:trade:venue:address:created. - A new withdrawal is created at a trading venue:
layer1:trade:venue:withdrawal:created. - The state of a withdrawal changes at a trading venue:
layer1:trade:venue:withdrawal:state-changed. - A new address is created:
layer1:crypto:address:created. - The status of a deposit changes:
layer1:crypto:deposit:status-change. - The status of a withdrawal changes:
layer1:crypto:withdrawal:status-change. - The status of a consolidation changes:
layer1:crypto:consolidation:status-change. - The balance is updated:
layer1:digital:balance:updated.
You can add any number of these events to a destination, and create as many destinations as you need to.
Here is how an example request might look:
curl --location 'https://api.sandbox.layer1.com/notification/v1/destinations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJhbG...QQ73OA' \
--data '{
"url": "https://webhook.site/52847769-cf41-4f94-8bec-57bfad257770",
"type": "WEB",
"events": [
"layer1:trade:conversion:created",
"layer1:trade:conversion:state-changed",
"layer1:trade:venue:address:created",
"layer1:trade:venue:withdrawal:created",
"layer1:trade:venue:withdrawal:state-changed",
"layer1:crypto:address:created",
"layer1:crypto:deposit:status-change",
"layer1:crypto:withdrawal:status-change",
"layer1:crypto:consolidation:status-change",
"layer1:digital:balance:updated"
]
}'
Upon successfully submitting the request, you'll receive a response like the following:
{
"url": "https://webhook.site/52847769-cf41-4f94-8bec-57bfad257770",
"type": "WEB",
"eventCodes": [
"layer1:trade:venue:withdrawal:created",
"layer1:crypto:address:created",
"layer1:trade:conversion:state-changed",
"layer1:trade:venue:address:created",
"layer1:crypto:consolidation:status-change",
"layer1:crypto:deposit:status-change",
"layer1:trade:conversion:created",
"layer1:digital:balance:updated",
"layer1:trade:venue:withdrawal:state-changed",
"layer1:crypto:withdrawal:status-change"
],
"publicKey": "MFYwEAYHKoZIzj0CAQYFK4EEAAoDQgAE+t4UzaqR68OQb/XnE1DjLk8AiD8bD69fbYZt+44fqRbnywMynzOZFqQWribhQDmdDc8gL6NzBODS1HtZSUIIJw=="
}
Pay special attention to your publicKey when validating the webhooks sent to the listed URL.
To get the publicKey again, or see what current events you are subscribed to across multiple destinations, send the GET /notification/v1/destinations request. It retrieves the destination created on the previous page, as well as any other destinations on your account.