Create Webhook
curl --request POST \
--url https://api.pro.daya.co/public/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"url": "<string>",
"events": [
{}
],
"description": "<string>"
}
'import requests
url = "https://api.pro.daya.co/public/v1/webhooks"
payload = {
"url": "<string>",
"events": [{}],
"description": "<string>"
}
headers = {
"X-Api-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>', events: [{}], description: '<string>'})
};
fetch('https://api.pro.daya.co/public/v1/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.pro.daya.co/public/v1/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' => '<string>',
'events' => [
[
]
],
'description' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <x-api-key>"
],
]);
$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.pro.daya.co/public/v1/webhooks"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"events\": [\n {}\n ],\n \"description\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<x-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.pro.daya.co/public/v1/webhooks")
.header("X-Api-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"events\": [\n {}\n ],\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pro.daya.co/public/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"events\": [\n {}\n ],\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Webhook created successfully",
"data": {
"id": "770e8400-e29b-41d4-a716-446655440000",
"url": "https://example.com/webhooks/daya",
"description": "Order and trade notifications",
"events": ["order.filled", "order.cancelled", "trade.executed"],
"status": "active",
"secret": "a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456",
"failure_count": 0,
"last_success_at": null,
"last_failure_at": null,
"last_failure_reason": null,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
},
"timestamp": "2024-01-15T10:00:00Z"
}
Webhooks API
Create Webhook
Create a new webhook endpoint
POST
/
public
/
v1
/
webhooks
Create Webhook
curl --request POST \
--url https://api.pro.daya.co/public/v1/webhooks \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <x-api-key>' \
--data '
{
"url": "<string>",
"events": [
{}
],
"description": "<string>"
}
'import requests
url = "https://api.pro.daya.co/public/v1/webhooks"
payload = {
"url": "<string>",
"events": [{}],
"description": "<string>"
}
headers = {
"X-Api-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Api-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({url: '<string>', events: [{}], description: '<string>'})
};
fetch('https://api.pro.daya.co/public/v1/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.pro.daya.co/public/v1/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' => '<string>',
'events' => [
[
]
],
'description' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Api-Key: <x-api-key>"
],
]);
$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.pro.daya.co/public/v1/webhooks"
payload := strings.NewReader("{\n \"url\": \"<string>\",\n \"events\": [\n {}\n ],\n \"description\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Api-Key", "<x-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.pro.daya.co/public/v1/webhooks")
.header("X-Api-Key", "<x-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"<string>\",\n \"events\": [\n {}\n ],\n \"description\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pro.daya.co/public/v1/webhooks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"<string>\",\n \"events\": [\n {}\n ],\n \"description\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Webhook created successfully",
"data": {
"id": "770e8400-e29b-41d4-a716-446655440000",
"url": "https://example.com/webhooks/daya",
"description": "Order and trade notifications",
"events": ["order.filled", "order.cancelled", "trade.executed"],
"status": "active",
"secret": "a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456",
"failure_count": 0,
"last_success_at": null,
"last_failure_at": null,
"last_failure_reason": null,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
},
"timestamp": "2024-01-15T10:00:00Z"
}
Overview
Create a new webhook endpoint to receive order, trade, and deposit event notifications. The webhook secret is only returned once at creation, so make sure to store it securely.Pro webhook setup is support-managed. Contact support@daya.co to enable webhook setup or request webhook configuration changes for your Pro account.
Authentication
Your API key with Write scope
X-Api-Key: daya_sk_YOUR_API_KEY
Request Body
Webhook endpoint URL (must be HTTPS in production)Example:
https://example.com/webhooks/dayaEvents to subscribe to (at least one required)Allowed values:
order.created, order.filled, order.partially_filled, order.cancelled, order.rejected, trade.executed, deposit.completed, crypto.deposit.completedOptional description for the webhookExample:
My order notificationsRequest Examples
curl --request POST \
--url 'https://api.pro.daya.co/public/v1/webhooks' \
--header 'X-Api-Key: daya_sk_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"url": "https://example.com/webhooks/daya",
"events": ["order.filled", "order.cancelled", "trade.executed"],
"description": "Order and trade notifications"
}'
const response = await fetch(
'https://api.pro.daya.co/public/v1/webhooks',
{
method: 'POST',
headers: {
'X-Api-Key': 'daya_sk_YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com/webhooks/daya',
events: ['order.filled', 'order.cancelled', 'trade.executed'],
description: 'Order and trade notifications'
})
}
);
const data = await response.json();
// IMPORTANT: Store the secret securely - it's only shown once!
console.log('Webhook secret:', data.data.secret);
import requests
headers = {
'X-Api-Key': 'daya_sk_YOUR_API_KEY',
'Content-Type': 'application/json'
}
payload = {
'url': 'https://example.com/webhooks/daya',
'events': ['order.filled', 'order.cancelled', 'trade.executed'],
'description': 'Order and trade notifications'
}
response = requests.post(
'https://api.pro.daya.co/public/v1/webhooks',
headers=headers,
json=payload
)
result = response.json()
# IMPORTANT: Store the secret securely - it's only shown once!
print(f"Webhook secret: {result['data']['secret']}")
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
payload := map[string]interface{}{
"url": "https://example.com/webhooks/daya",
"events": []string{"order.filled", "order.cancelled", "trade.executed"},
"description": "Order and trade notifications",
}
jsonPayload, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.pro.daya.co/public/v1/webhooks", bytes.NewBuffer(jsonPayload))
req.Header.Set("X-Api-Key", "daya_sk_YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
// IMPORTANT: Store the secret securely - it's only shown once!
fmt.Println("Webhook created:", result["data"])
}
Response
Indicates if the request was successful
Human-readable response message
Created webhook with secret
Show webhook properties
Show webhook properties
Unique webhook identifier (UUID)
Webhook endpoint URL
Webhook description
Events this webhook is subscribed to
Webhook status (will be
active)Signing secret for verifying webhook payloads.
This is only returned once at creation. Store it securely!
ISO 8601 creation timestamp
ISO 8601 last update timestamp
Success Response
{
"success": true,
"message": "Webhook created successfully",
"data": {
"id": "770e8400-e29b-41d4-a716-446655440000",
"url": "https://example.com/webhooks/daya",
"description": "Order and trade notifications",
"events": ["order.filled", "order.cancelled", "trade.executed"],
"status": "active",
"secret": "a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456",
"failure_count": 0,
"last_success_at": null,
"last_failure_at": null,
"last_failure_reason": null,
"created_at": "2024-01-15T10:00:00Z",
"updated_at": "2024-01-15T10:00:00Z"
},
"timestamp": "2024-01-15T10:00:00Z"
}
The
secret is a 64-character hex string (32 bytes). This is the raw secret used for HMAC-SHA256 signature verification.Error Responses
{
"success": false,
"message": "Validation error",
"error": {
"code": "VALIDATION_ERROR",
"message": "URL must be a valid HTTPS URL"
}
}
{
"success": false,
"message": "Validation error",
"error": {
"code": "VALIDATION_ERROR",
"message": "At least one event is required"
}
}
{
"success": false,
"message": "Unauthorized",
"error": {
"code": "API_KEY_INVALID",
"message": "The provided API key is invalid"
}
}
{
"success": false,
"message": "Webhook limit exceeded",
"error": {
"code": "WEBHOOK_LIMIT_EXCEEDED",
"message": "Maximum number of webhooks reached (5)"
}
}
Available Events
| Event | Description |
|---|---|
order.created | New order accepted by matching engine |
order.filled | Order completely filled |
order.partially_filled | Order partially executed |
order.cancelled | Order cancelled |
order.rejected | Order rejected |
trade.executed | Trade executed involving your order |
deposit.completed | NGN bank-transfer deposit settled to your Daya Pro balance |
crypto.deposit.completed | Confirmed on-chain deposit credited to your Daya Pro balance |
Important Notes
Store your webhook secret securely! The
secret field is only returned once when the webhook is created. If you lose it, you’ll need to rotate the secret.Webhook URLs must use HTTPS in production. HTTP is only allowed for local development testing.
Rate Limits
- 100 requests per minute per API key
- Maximum 5 webhooks per account
Next Steps
Webhook Verification
Learn how to verify webhook signatures
Webhook Events
See event payload details
List Webhooks
View all your webhooks
Update Webhook
Update webhook configuration
⌘I