Q
quub
WEBHOOKS

Real-Time Events
Via Webhooks

Receive instant notifications when events happen in your Quub account. Build reactive applications with our reliable webhook system.

99.9%
Delivery Rate
<2s
Avg Latency
24
Event Types
3x
Auto Retry

How Webhooks Work

Simple 3-step process to start receiving real-time notifications

1
๐Ÿ”—

Register Endpoint

Add your webhook URL in the dashboard and select which events you want to receive.

2
โšก

Events Trigger

When an event occurs, we immediately send a POST request to your endpoint with the event data.

3
โœ…

Process & Respond

Handle the event in your application and return a 200 status to acknowledge receipt.

Available Event Types

Subscribe to the events that matter to your application

๐Ÿ’ผ

Wallet Events

wallet.created
New wallet created
wallet.updated
Wallet information modified
wallet.balance_changed
Balance updated for wallet
wallet.deleted
Wallet permanently deleted
๐Ÿ’ธ

Transaction Events

transaction.created
Transaction initiated
transaction.pending
Transaction pending confirmation
transaction.confirmed
Transaction confirmed on-chain
transaction.failed
Transaction failed or rejected
๐ŸŒพ

DeFi Events

defi.stake_started
Staking position opened
defi.stake_completed
Staking position closed
defi.yield_earned
Yield rewards distributed
defi.swap_executed
Token swap completed
๐Ÿ”

Security Events

security.api_key_created
New API key generated
security.api_key_revoked
API key revoked or deleted
security.suspicious_activity
Unusual activity detected
security.withdrawal_approved
Large withdrawal confirmed
๐Ÿ“Š

Portfolio Events

portfolio.value_updated
Total portfolio value changed
portfolio.threshold_reached
Custom threshold triggered
portfolio.rebalanced
Auto-rebalance executed
portfolio.report_ready
Periodic report generated
โš™๏ธ

System Events

system.webhook_test
Test webhook endpoint
system.rate_limit_warning
Approaching rate limit
system.maintenance_scheduled
Planned maintenance notice
system.service_restored
Service back online

Webhook Payload

Example webhook payload structure

{
  "id": "evt_1234567890",
  "type": "transaction.confirmed",
  "created": 1697041234,
  "data": {
    "object": {
      "id": "tx_9876543210",
      "status": "confirmed",
      "from": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
      "to": "0x8f0E2A2B3C4D5E6F7A8B9C0D1E2F3A4B5C6D7E8F",
      "amount": "100.00",
      "currency": "USDC",
      "chain": "ethereum",
      "hash": "0xabc123def456...",
      "confirmations": 12,
      "gas_used": "21000",
      "gas_price": "25",
      "timestamp": 1697041200,
      "metadata": {
        "user_id": "user_123",
        "order_id": "order_456"
      }
    }
  },
  "livemode": true,
  "pending_webhooks": 1,
  "request": {
    "id": "req_abc123",
    "idempotency_key": "key_xyz789"
  }
}

Implementation Guide

Code examples for handling webhooks in your application

Node.js / Express

โšก
const express = require('express');
const crypto = require('crypto');

app.post('/webhooks/quub',
  express.raw({type: 'application/json'}),
  (req, res) => {
    const signature = req.headers['x-quub-signature'];
    const payload = req.body;

    // Verify signature
    const hash = crypto
      .createHmac('sha256', webhookSecret)
      .update(payload)
      .digest('hex');

    if (hash !== signature) {
      return res.status(401).send('Invalid signature');
    }

    const event = JSON.parse(payload);

    // Handle event
    switch (event.type) {
      case 'transaction.confirmed':
        handleTransaction(event.data.object);
        break;
      case 'wallet.balance_changed':
        updateBalance(event.data.object);
        break;
    }

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

Python / Flask

๐Ÿ
from flask import Flask, request
import hmac
import hashlib

@app.route('/webhooks/quub', methods=['POST'])
def webhook():
    signature = request.headers.get('X-Quub-Signature')
    payload = request.data

    # Verify signature
    expected = hmac.new(
        webhook_secret.encode(),
        payload,
        hashlib.sha256
    ).hexdigest()

    if signature != expected:
        return 'Invalid signature', 401

    event = request.json

    # Handle event
    if event['type'] == 'transaction.confirmed':
        handle_transaction(event['data']['object'])
    elif event['type'] == 'wallet.balance_changed':
        update_balance(event['data']['object'])

    return 'Success', 200

Best Practices

Follow these guidelines for reliable webhook handling

๐Ÿ”

Verify Signatures

Always verify the webhook signature using the secret key to ensure the request is from Quub.

โšก

Respond Quickly

Return a 200 status immediately. Process heavy tasks asynchronously in a queue.

๐Ÿ”„

Handle Retries

Make your endpoint idempotent. We retry failed webhooks up to 3 times with exponential backoff.

๐Ÿ“

Log Everything

Keep logs of all received webhooks for debugging and audit purposes.

๐Ÿงช

Test Thoroughly

Use our test mode to simulate events before deploying to production.

๐Ÿ””

Monitor Health

Set up alerts for failed webhook deliveries in the dashboard.

Webhook Security

How we ensure webhook authenticity and security

Signature Verification

Every webhook includes an X-Quub-Signature header containing an HMAC-SHA256 signature of the payload.

signature = HMAC_SHA256(webhook_secret, payload)

HTTPS Only

All webhooks are sent over HTTPS to ensure data is encrypted in transit. HTTP endpoints are not supported.

โœ“
https://api.yourdomain.com/webhooks
โœ—
http://api.yourdomain.com/webhooks

IP Allowlisting

For additional security, you can allowlist our webhook IPs:

54.187.205.235
54.187.216.72
54.187.174.169

Timestamp Validation

Each webhook includes a created timestamp. Reject events older than 5 minutes to prevent replay attacks.

if (now - event.created > 300) reject()

Ready to Integrate Webhooks?

Start receiving real-time notifications for events in your Quub account. Set up your first webhook endpoint in minutes.