Skip to main content
POST
/
webhooks
Register a webhook
curl --request POST \
  --url https://api.leokit.dev/webhooks \
  --header 'Api-Key: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "url": "https://your-server.com/webhooks/leokit",
  "events": [
    "swap.success",
    "swap.failed",
    "swap.refunded"
  ],
  "type": "standard"
}
'
import requests

url = "https://api.leokit.dev/webhooks"

payload = {
"url": "https://your-server.com/webhooks/leokit",
"events": ["swap.success", "swap.failed", "swap.refunded"],
"type": "standard"
}
headers = {
"Api-Key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Api-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://your-server.com/webhooks/leokit',
events: ['swap.success', 'swap.failed', 'swap.refunded'],
type: 'standard'
})
};

fetch('https://api.leokit.dev/webhooks', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.leokit.dev/webhooks",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://your-server.com/webhooks/leokit',
'events' => [
'swap.success',
'swap.failed',
'swap.refunded'
],
'type' => 'standard'
]),
CURLOPT_HTTPHEADER => [
"Api-Key: <api-key>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.leokit.dev/webhooks"

payload := strings.NewReader("{\n \"url\": \"https://your-server.com/webhooks/leokit\",\n \"events\": [\n \"swap.success\",\n \"swap.failed\",\n \"swap.refunded\"\n ],\n \"type\": \"standard\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Api-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.leokit.dev/webhooks")
.header("Api-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://your-server.com/webhooks/leokit\",\n \"events\": [\n \"swap.success\",\n \"swap.failed\",\n \"swap.refunded\"\n ],\n \"type\": \"standard\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.leokit.dev/webhooks")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Api-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://your-server.com/webhooks/leokit\",\n \"events\": [\n \"swap.success\",\n \"swap.failed\",\n \"swap.refunded\"\n ],\n \"type\": \"standard\"\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "url": "<string>",
    "events": [
      "<string>"
    ],
    "is_active": true,
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z",
    "secret": "<string>"
  }
}
{
"message": "<string>",
"code": "<string>"
}
The full lifecycle, payload formats, signature verification, and Discord/Slack auto-detection are documented at Webhooks.
The secret is only returned at creation time. Save it immediately — you’ll need it to verify HMAC signatures on incoming webhook deliveries.

Authorizations

Api-Key
string
header
required

Demo API-Key (Sandbox): 7037d2b3-9c76-4f62-b730-c544f7570fa4

Body

application/json
url
string<uri>
required

HTTPS URL. Discord/Slack URLs are auto-detected.

events
enum<string>[]

Defaults to all 6 events.

Available options:
quote.created,
deposit.initiated,
swap.pending,
swap.success,
swap.failed,
swap.refunded
type
enum<string>

Auto-detected from URL if omitted.

Available options:
standard,
discord,
slack

Response

Webhook created. The secret is only returned once.

data
object
required