Skip to main content

Endpoint

GET /hooks
Retrieves a list of all registered webhooks. Optionally filter by webhook type.

Query Parameters

type
string
Filter webhooks by type. Supported values:
  • PRE_TRANSACTION: Only pre-transaction webhooks
  • POST_TRANSACTION: Only post-transaction webhooks
If not specified, returns all webhooks

Response

Returns an array of webhook objects.
webhooks
array
Array of webhook objects

Example Requests

Get All Webhooks

curl -X GET "https://api.blnk.io/hooks" \
  -H "Authorization: Bearer YOUR_API_KEY"

Get Pre-Transaction Webhooks Only

curl -X GET "https://api.blnk.io/hooks?type=PRE_TRANSACTION" \
  -H "Authorization: Bearer YOUR_API_KEY"

Get Post-Transaction Webhooks Only

curl -X GET "https://api.blnk.io/hooks?type=POST_TRANSACTION" \
  -H "Authorization: Bearer YOUR_API_KEY"

Example Response

[
  {
    "id": "hook_abc123def456",
    "name": "Fraud Detection",
    "url": "https://api.example.com/webhooks/fraud-check",
    "type": "PRE_TRANSACTION",
    "active": true,
    "timeout": 10,
    "retry_count": 1,
    "created_at": "2024-03-04T12:00:00Z",
    "last_run": "2024-03-04T14:30:15Z",
    "last_success": true
  },
  {
    "id": "hook_xyz789abc012",
    "name": "Transaction Notification",
    "url": "https://api.example.com/webhooks/transaction-complete",
    "type": "POST_TRANSACTION",
    "active": true,
    "timeout": 30,
    "retry_count": 3,
    "created_at": "2024-03-04T12:15:00Z",
    "last_run": "2024-03-04T14:45:20Z",
    "last_success": true
  },
  {
    "id": "hook_def456ghi789",
    "name": "Compliance Check",
    "url": "https://api.example.com/webhooks/compliance",
    "type": "PRE_TRANSACTION",
    "active": false,
    "timeout": 15,
    "retry_count": 2,
    "created_at": "2024-03-01T09:00:00Z",
    "last_run": "2024-03-03T16:20:00Z",
    "last_success": false
  }
]

Empty Response

When no webhooks are registered:
[]

Error Responses

error
string
Error message describing what went wrong

Common Errors

  • 400 Bad Request: Invalid webhook type specified
  • 500 Internal Server Error: Failed to list webhooks

Use Cases

Webhook Dashboard

Display all webhooks with their status:
const loadWebhookDashboard = async () => {
  const webhooks = await fetch('https://api.blnk.io/hooks', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  }).then(r => r.json());
  
  return webhooks.map(hook => ({
    name: hook.name,
    type: hook.type,
    status: hook.active ? 'Active' : 'Inactive',
    health: hook.last_success ? 'Healthy' : 'Failing',
    lastRun: formatTime(hook.last_run)
  }));
};

Health Monitoring

Monitor all webhook endpoints:
const checkWebhookHealth = async () => {
  const webhooks = await fetch('https://api.blnk.io/hooks', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  }).then(r => r.json());
  
  const failing = webhooks.filter(h => !h.last_success && h.active);
  const inactive = webhooks.filter(h => !h.active);
  
  if (failing.length > 0) {
    console.error(`${failing.length} webhooks are failing:`, failing.map(h => h.name));
  }
  
  if (inactive.length > 0) {
    console.warn(`${inactive.length} webhooks are inactive:`, inactive.map(h => h.name));
  }
  
  return {
    total: webhooks.length,
    active: webhooks.filter(h => h.active).length,
    healthy: webhooks.filter(h => h.last_success).length,
    failing: failing.length
  };
};

Filter by Type

Get webhooks of a specific type:
const getPreTransactionHooks = async () => {
  return await fetch('https://api.blnk.io/hooks?type=PRE_TRANSACTION', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  }).then(r => r.json());
};

const getPostTransactionHooks = async () => {
  return await fetch('https://api.blnk.io/hooks?type=POST_TRANSACTION', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  }).then(r => r.json());
};

Audit Report

Generate a webhook audit report:
const generateWebhookAudit = async () => {
  const webhooks = await fetch('https://api.blnk.io/hooks', {
    headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
  }).then(r => r.json());
  
  return {
    generated_at: new Date().toISOString(),
    total_webhooks: webhooks.length,
    by_type: {
      pre_transaction: webhooks.filter(h => h.type === 'PRE_TRANSACTION').length,
      post_transaction: webhooks.filter(h => h.type === 'POST_TRANSACTION').length
    },
    by_status: {
      active: webhooks.filter(h => h.active).length,
      inactive: webhooks.filter(h => !h.active).length
    },
    webhooks: webhooks.map(h => ({
      id: h.id,
      name: h.name,
      type: h.type,
      active: h.active,
      endpoint: h.url,
      created: h.created_at,
      last_run: h.last_run,
      last_success: h.last_success
    }))
  };
};

Filtering and Sorting

Client-side filtering examples:
// Filter active webhooks
const activeWebhooks = webhooks.filter(h => h.active);

// Sort by last run time (most recent first)
const sortedByLastRun = webhooks.sort((a, b) => 
  new Date(b.last_run) - new Date(a.last_run)
);

// Filter webhooks created in the last 30 days
const recentWebhooks = webhooks.filter(h => {
  const created = new Date(h.created_at);
  const thirtyDaysAgo = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000);
  return created > thirtyDaysAgo;
});

Best Practices

  1. Regular monitoring: Check webhook list regularly for health status
  2. Clean up unused webhooks: Delete webhooks that are no longer needed
  3. Document webhook purposes: Use descriptive names to identify webhook functions
  4. Review failed webhooks: Investigate webhooks with last_success: false
  5. Audit active webhooks: Periodically review all active webhooks for security

Build docs developers (and LLMs) love