Events Service API
Subscribe to real-time events via webhooks and WebSocket streams for transaction updates, system events, and notifications.
Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /api/events/webhook | Create webhook subscription |
GET | /api/events/webhook/list | List webhooks |
DELETE | /api/events/webhook/:id | Delete webhook |
GET | /api/events/stream | WebSocket 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
| Event | Description |
|---|---|
transaction.pending | Transaction submitted |
transaction.confirmed | Transaction confirmed |
transaction.failed | Transaction failed |
wallet.created | New wallet created |
bridge.initiated | Bridge transfer started |
bridge.completed | Bridge transfer completed |
custody.approval_required | Transaction 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);
};