Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xentfi.com/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Why Use Webhooks?

⚡ Real-time Updates

Receive notifications instantly when events happen, not minutes later

🔄 Automatic Retries

Failed deliveries are automatically retried with exponential backoff

🔒 Secure Verification

Every webhook includes a signature to verify authenticity

📊 Event Logging

Complete history of all webhook deliveries for debugging

🎯 Selective Events

Subscribe only to the events you care about

🚀 Scalable

Handle high-volume event streams without performance impact

How Webhooks Work

Event Types

Payment Events

EventTriggerDescription
payment.createdPayment link openedPayment intent created, awaiting customer action
payment.processingPayment submittedTransaction broadcast to blockchain
payment.completedTransaction confirmedPayment successfully processed
payment.failedPayment failedTransaction failed (insufficient funds, etc.)
payment.expiredSession timeoutPayment session expired (deposit method)

Settlement Events

EventTriggerDescription
settlement.createdRule triggeredAuto-settlement rule activated
settlement.processingTransfer initiatedSettlement transaction broadcast
settlement.completedTransfer confirmedFunds moved to destination
settlement.failedTransfer failedSettlement failed (gas, network)
settlement.sweptBatch completeBatch settlement finished

Transfer & Swap Events

EventTriggerDescription
transfer.quotedQuote generatedTransfer quote created
transfer.startedExecution startedTransfer initiated
transfer.confirmedTransaction confirmedTransfer completed on source chain
transfer.completedCross-chain doneBridge transfer fully complete
transfer.failedTransfer failedExecution failed

Wallet Events

EventTriggerDescription
wallet.createdNew walletMaster wallet created
address.createdNew addressDeposit address generated
monitoring.enabledMonitoring onAddress monitoring activated
monitoring.disabledMonitoring offAddress monitoring deactivated

Compliance Events

EventTriggerDescription
aml.screeningAddress checkAML screening performed
aml.blockedSanctions matchAddress blocked due to sanctions
aml.reviewRisk alertHigh-risk address requires review

Webhook Payloads

Payment Completed Example

{
    "id": "evt_123e4567-e89b-12d3-a456-426614174000",
    "type": "payment.completed",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "data": {
        "paymentIntent": {
            "id": "intent_123",
            "paymentLinkId": "link_456",
            "amount": "100",
            "currency": "USD",
            "tokenAmount": "0.02857",
            "asset": "ETH",
            "blockchain": "eth-mainnet",
            "status": "completed",
            "transactionHash": "0xabc123def456...",
            "senderAddress": "0xSender...",
            "recipientAddress": "0xRecipient..."
        }
    }
}

Settlement Completed Example

{
    "id": "evt_789",
    "type": "settlement.completed",
    "createdAt": "2024-01-15T10:35:00.000Z",
    "data": {
        "settlement": {
            "id": "settle_123",
            "ruleId": "rule_456",
            "sourceAddress": "0xSource...",
            "destinationAddress": "0xDest...",
            "amount": "500",
            "asset": "USDC",
            "transactionHash": "0xdef456...",
            "gasUsed": "0.002",
            "gasPrice": "25"
        }
    }
}

Compliance Alert Example

{
    "id": "evt_789",
    "type": "aml.blocked",
    "createdAt": "2024-01-15T10:40:00.000Z",
    "data": {
        "screening": {
            "address": "0xSanctionedAddress...",
            "riskScore": 100,
            "riskLevel": "CRITICAL",
            "reason": "OFAC sanctions match",
            "identifications": [
                {
                    "category": "sanctions",
                    "name": "Entity Name",
                    "description": "OFAC sanctions designation"
                }
            ]
        }
    }
}

Setting Up Webhooks

Create Webhook Endpoint

First, create an endpoint in your application to receive webhooks:
// Node.js example
app.post('/webhooks/xentfi', (req, res) => {
  const signature = req.headers['x-webhook-signature'];
  const payload = req.body;

  // Verify signature
  if (!verifySignature(payload, signature)) {
    return res.status(401).send('Invalid signature');
  }

  // Process webhook
  switch(payload.type) {
    case 'payment.completed':
      handlePaymentCompleted(payload.data);
      break;
    case 'settlement.completed':
      handleSettlementCompleted(payload.data);
      break;
    default:
      console.log(`Unhandled event: ${payload.type}`);
  }

  res.status(200).send('OK');
});

Register Webhook

curl -X POST https://api.xentfi.com/v1/webhooks \
  -H "apiKey: your-api-key" \
  -H "orgId: your-org-id" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhooks/xentfi",
    "events": ["payment.completed", "settlement.completed", "aml.blocked"],
    "secret": "your-webhook-secret"
  }'
{
    "success": true,
    "data": {
        "id": "webhook_123e4567",
        "url": "https://yourapp.com/webhooks/xentfi",
        "events": [
            "payment.completed",
            "settlement.completed",
            "aml.blocked"
        ],
        "secret": "whsec_abc123...",
        "isActive": true,
        "createdAt": "2024-01-15T10:30:00.000Z"
    }
}

Signature Verification

Why Verify Signatures?

Webhook signatures ensure that requests truly come from XentFi and not an imposter.

Verification Process

Verification Code Example

const crypto = require('crypto');

function verifyWebhookSignature(payload, signature, secret) {
  const expectedSignature = crypto
    .createHmac('sha256', secret)
    .update(JSON.stringify(payload))
    .digest('hex');

  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expectedSignature)
  );
}

Retry Logic

Retry Schedule

AttemptDelayTotal Wait
1Immediate0 seconds
25 seconds5 seconds
330 seconds35 seconds
45 minutes5 minutes 35 seconds
530 minutes35 minutes 35 seconds
61 hour1 hour 35 minutes
72 hours3 hours 35 minutes
86 hours9 hours 35 minutes

Retry Headers

HeaderDescription
X-Retry-CountCurrent retry attempt number
X-Retry-DelaySeconds until next retry
X-Previous-ResponseHTTP status from last attempt

Managing Webhooks

List Webhooks

curl -X GET https://api.xentfi.com/v1/webhooks \
  -H "apiKey: your-api-key" \
  -H "orgId: your-org-id"

Update Webhook

curl -X PUT https://api.xentfi.com/v1/webhooks/{webhookId} \
  -H "apiKey: your-api-key" \
  -H "orgId: your-org-id" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhooks/new-endpoint",
    "events": ["payment.completed"],
    "isActive": true
  }'

Delete Webhook

curl -X DELETE https://api.xentfi.com/v1/webhooks/{webhookId} \
  -H "apiKey: your-api-key" \
  -H "orgId: your-org-id"

Rotate Webhook Secret

curl -X POST https://api.xentfi.com/v1/webhooks/{webhookId}/rotate-secret \
  -H "apiKey: your-api-key" \
  -H "orgId: your-org-id"

Best Practices

  • Always verify signatures - Never trust unverified webhooks
  • Respond quickly - Return 2xx within 5 seconds
  • Idempotent processing - Handle duplicate webhooks gracefully
  • Use idempotency keys - Prevent duplicate processing
  • Log all webhooks - Keep audit trail for debugging
  • Monitor failures - Set up alerts for failed deliveries
  • Queue processing - Use message queues for async handling
  • Keep endpoints public - Must be accessible from the internet

Webhook Delivery Monitoring

Webhook Dashboard

Available Metrics

MetricDescriptionUpdate Frequency
Total deliveriesNumber of webhooks sentReal-time
Success ratePercentage of 2xx responsesReal-time
Failed deliveriesNon-2xx responsesReal-time
Average latencyTime to receive responseHourly
Retry queue sizePending retriesReal-time
Dead lettersFailed after all retriesReal-time

Testing Webhooks Locally

Using ngrok

# Install ngrok
brew install ngrok

# Expose your local server
ngrok http 3000

# Copy the HTTPS URL (e.g., https://abc123.ngrok.io)
# Use this URL when creating your webhook

Test Payloads

# Simulate a webhook for testing
curl -X POST https://yourapp.com/webhooks/xentfi \
  -H "Content-Type: application/json" \
  -H "X-Webhook-Signature: test_signature" \
  -d '{
    "id": "test_evt_123",
    "type": "payment.completed",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "data": {
      "paymentIntent": {
        "id": "test_intent_123",
        "amount": "100",
        "status": "completed"
      }
    }
  }'

Event Filtering

Subscribe to Specific Events

{
    "url": "https://yourapp.com/webhooks",
    "events": [
        "payment.completed",
        "settlement.completed",
        "aml.blocked"
    ]
}

Wildcard Subscriptions

PatternMatches
payment.*All payment events
settlement.*All settlement events
*.completedAll completion events
*All events

Troubleshooting

Possible causes:
  • Endpoint not publicly accessible
  • Firewall blocking requests
  • Invalid URL format
  • Webhook not active
Solutions:
  • Verify URL is accessible from internet
  • Check firewall rules
  • Ensure URL includes https://
  • Verify webhook is active in dashboard
Possible causes:
  • Wrong secret used
  • Paybody body modified
  • Encoding issues
Solutions:
  • Rotate and update secret
  • Use raw request body
  • Verify JSON stringification
Solutions:
  • Implement idempotency using webhook ID
  • Check for processed flag in your database
  • Use unique constraint on webhook ID
Solutions:
  • Process webhooks asynchronously
  • Use message queue (RabbitMQ, SQS)
  • Return 202 Accepted for long processing

Webhook Headers

HeaderDescriptionExample
X-Webhook-SignatureHMAC-SHA256 signaturea1b2c3d4e5f6...
X-Webhook-IDUnique webhook identifierwhk_123e4567
X-Event-TypeType of eventpayment.completed
X-Event-IDUnique event identifierevt_123e4567
X-Retry-CountRetry attempt number0
X-TimestampEvent timestamp1705319400
User-AgentIdentifies XentFiXentFi-Webhook/1.0

Pricing

FeatureStarterProfessionalBusinessEnterprise
Webhooks525100Unlimited
Events per webhook102550Unlimited
Retry attempts35810
Retention period7 days30 days90 days1 year
Custom retry schedule
Dead letter queue

Performance Metrics

MetricTargetDescription
Delivery time< 500msTime from event to delivery
Success rate> 99.9%Successful deliveries
Retry rate< 1%Percentage requiring retry
Availability99.99%Webhook system uptime

Payment Links

Payment event notifications

Auto Settlement

Settlement event notifications

AML Compliance

Compliance alert notifications

Next Steps