curl -X POST https://api.swiftpay.cx/api/webhooks \
-H "Authorization: Bearer mp_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yoursite.com/webhooks/swiftpay",
"events": [
"checkout.succeeded",
"checkout.failed",
"withdrawal.paid"
],
"description": "Production webhook handler"
}'
const response = await fetch("https://api.swiftpay.cx/api/webhooks", {
method: "POST",
headers: {
Authorization: "Bearer mp_live_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://yoursite.com/webhooks/swiftpay",
events: ["checkout.succeeded", "checkout.failed", "withdrawal.paid"],
description: "Production webhook handler",
}),
});
const webhook = await response.json();
// IMPORTANT: Save the secret securely - it's only shown once!
console.log("Webhook secret:", webhook.data.secret);
import requests
response = requests.post(
'https://api.swiftpay.cx/api/webhooks',
headers={
'Authorization': 'Bearer mp_live_your_api_key',
'Content-Type': 'application/json'
},
json={
'url': 'https://yoursite.com/webhooks/swiftpay',
'events': [
'checkout.succeeded',
'checkout.failed',
'withdrawal.paid'
],
'description': 'Production webhook handler'
}
)
webhook = response.json()
# IMPORTANT: Save the secret securely - it's only shown once!
print(f"Webhook secret: {webhook['data']['secret']}")
{
"success": true,
"data": {
"endpoint": {
"id": "wh_abc123",
"url": "https://yoursite.com/webhooks/swiftpay",
"events": [
"checkout.succeeded",
"checkout.failed",
"withdrawal.paid"
],
"isActive": true,
"description": "Production webhook handler",
"createdAt": "2024-01-15T10:30:00Z"
},
"secret": "whsec_1234567890abcdef"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "URL must be HTTPS",
"requestId": "req_abc123"
}
}
Webhooks
Create Webhook Endpoint
Create a new webhook endpoint to receive event notifications
POST
/
api
/
webhooks
curl -X POST https://api.swiftpay.cx/api/webhooks \
-H "Authorization: Bearer mp_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yoursite.com/webhooks/swiftpay",
"events": [
"checkout.succeeded",
"checkout.failed",
"withdrawal.paid"
],
"description": "Production webhook handler"
}'
const response = await fetch("https://api.swiftpay.cx/api/webhooks", {
method: "POST",
headers: {
Authorization: "Bearer mp_live_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://yoursite.com/webhooks/swiftpay",
events: ["checkout.succeeded", "checkout.failed", "withdrawal.paid"],
description: "Production webhook handler",
}),
});
const webhook = await response.json();
// IMPORTANT: Save the secret securely - it's only shown once!
console.log("Webhook secret:", webhook.data.secret);
import requests
response = requests.post(
'https://api.swiftpay.cx/api/webhooks',
headers={
'Authorization': 'Bearer mp_live_your_api_key',
'Content-Type': 'application/json'
},
json={
'url': 'https://yoursite.com/webhooks/swiftpay',
'events': [
'checkout.succeeded',
'checkout.failed',
'withdrawal.paid'
],
'description': 'Production webhook handler'
}
)
webhook = response.json()
# IMPORTANT: Save the secret securely - it's only shown once!
print(f"Webhook secret: {webhook['data']['secret']}")
{
"success": true,
"data": {
"endpoint": {
"id": "wh_abc123",
"url": "https://yoursite.com/webhooks/swiftpay",
"events": [
"checkout.succeeded",
"checkout.failed",
"withdrawal.paid"
],
"isActive": true,
"description": "Production webhook handler",
"createdAt": "2024-01-15T10:30:00Z"
},
"secret": "whsec_1234567890abcdef"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "URL must be HTTPS",
"requestId": "req_abc123"
}
}
Create Webhook Endpoint
Creates a new webhook endpoint to receive event notifications.Request
Bearer token with your API key
The HTTPS URL where webhook events will be sent
Array of event types to subscribe to
Optional description for this endpoint
Response
Whether the request was successful
Show properties
Show properties
Signing secret for verifying payloads. Only shown once on creation!
curl -X POST https://api.swiftpay.cx/api/webhooks \
-H "Authorization: Bearer mp_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yoursite.com/webhooks/swiftpay",
"events": [
"checkout.succeeded",
"checkout.failed",
"withdrawal.paid"
],
"description": "Production webhook handler"
}'
const response = await fetch("https://api.swiftpay.cx/api/webhooks", {
method: "POST",
headers: {
Authorization: "Bearer mp_live_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
url: "https://yoursite.com/webhooks/swiftpay",
events: ["checkout.succeeded", "checkout.failed", "withdrawal.paid"],
description: "Production webhook handler",
}),
});
const webhook = await response.json();
// IMPORTANT: Save the secret securely - it's only shown once!
console.log("Webhook secret:", webhook.data.secret);
import requests
response = requests.post(
'https://api.swiftpay.cx/api/webhooks',
headers={
'Authorization': 'Bearer mp_live_your_api_key',
'Content-Type': 'application/json'
},
json={
'url': 'https://yoursite.com/webhooks/swiftpay',
'events': [
'checkout.succeeded',
'checkout.failed',
'withdrawal.paid'
],
'description': 'Production webhook handler'
}
)
webhook = response.json()
# IMPORTANT: Save the secret securely - it's only shown once!
print(f"Webhook secret: {webhook['data']['secret']}")
{
"success": true,
"data": {
"endpoint": {
"id": "wh_abc123",
"url": "https://yoursite.com/webhooks/swiftpay",
"events": [
"checkout.succeeded",
"checkout.failed",
"withdrawal.paid"
],
"isActive": true,
"description": "Production webhook handler",
"createdAt": "2024-01-15T10:30:00Z"
},
"secret": "whsec_1234567890abcdef"
}
}
{
"success": false,
"error": {
"type": "validation_error",
"message": "URL must be HTTPS",
"requestId": "req_abc123"
}
}
Available Events
Checkout Events
| Event | Description |
|---|---|
checkout.succeeded | Payment was successful |
checkout.failed | Payment failed |
Withdrawal Events
| Event | Description |
|---|---|
withdrawal.paid | Withdrawal processed and paid |
withdrawal.failed | Withdrawal failed to process |
Save the secret immediately! The webhook signing secret is only returned
when creating the endpoint. Store it securely - you’ll need it to verify
webhook signatures.
⌘I