Events Service API

Subscribe to real-time events via webhooks and WebSocket streams for transaction updates, system events, and notifications.

Endpoints

MethodEndpointDescription
POST/api/events/webhookCreate webhook subscription
GET/api/events/webhook/listList webhooks
DELETE/api/events/webhook/:idDelete webhook
GET/api/events/streamWebSocket event stream

Create Webhook

POST /api/events/webhook
Content-Type: application/json

{
  "url": "https://api.yourapp.com/webhooks/tenzro",
  "events": ["transaction.confirmed", "wallet.created", "bridge.completed"],
  "secret": "your-webhook-secret"
}

Response

{
  "data": {
    "id": "wh_abc123",
    "url": "https://api.yourapp.com/webhooks/tenzro",
    "events": ["transaction.confirmed", "wallet.created", "bridge.completed"],
    "status": "active",
    "createdAt": "2024-01-15T10:30:00Z"
  }
}

Webhook Payload

{
  "id": "evt_abc123",
  "type": "transaction.confirmed",
  "timestamp": "2024-01-15T10:30:00Z",
  "data": {
    "transactionId": "tx_xyz",
    "txHash": "0x...",
    "status": "confirmed",
    "blockNumber": 12345678
  }
}

Webhook Signature

Verify webhook authenticity using the X-Tenzro-Signature header:

const crypto = require('crypto');

function verifyWebhook(payload, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(payload)
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

Event Types

EventDescription
transaction.pendingTransaction submitted
transaction.confirmedTransaction confirmed
transaction.failedTransaction failed
wallet.createdNew wallet created
bridge.initiatedBridge transfer started
bridge.completedBridge transfer completed
custody.approval_requiredTransaction needs approval

WebSocket Stream

const ws = new WebSocket('wss://api.platform.tenzro.com/events/stream');

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: 'subscribe',
    events: ['transaction.*'],
    apiKey: 'your-api-key'
  }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Event received:', data);
};