Skip to main content

Endpoint

GET /hooks/:id
Retrieves detailed information about a specific webhook.

Path Parameters

id
string
required
The unique identifier of the webhook to retrieve

Response

id
string
Unique identifier for the webhook
name
string
The friendly name of the webhook
url
string
The webhook endpoint URL
type
string
The webhook type (PRE_TRANSACTION or POST_TRANSACTION)
active
boolean
Whether the webhook is currently active
timeout
integer
Timeout in seconds
retry_count
integer
Number of retry attempts
created_at
string
Timestamp when the webhook was created (ISO 8601 format)
last_run
string
Timestamp of the last execution (ISO 8601 format)
last_success
boolean
Whether the last execution was successful

Example Request

curl -X GET "https://api.blnk.io/hooks/hook_abc123def456" \
  -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
}

Error Responses

error
string
Error message describing what went wrong

Common Errors

  • 404 Not Found: Webhook with the specified ID not found
  • 500 Internal Server Error: Failed to retrieve webhook

Monitoring Webhook Health

Use the response fields to monitor webhook health:

Active Status

Check if the webhook is currently processing events:
if (!webhook.active) {
  console.warn(`Webhook ${webhook.name} is disabled`);
}

Last Execution

Monitor when the webhook was last triggered:
const lastRun = new Date(webhook.last_run);
const hoursSinceLastRun = (Date.now() - lastRun) / 1000 / 60 / 60;

if (hoursSinceLastRun > 24) {
  console.info(`Webhook ${webhook.name} hasn't run in ${hoursSinceLastRun.toFixed(1)} hours`);
}

Success Rate

Track webhook reliability:
if (!webhook.last_success) {
  console.error(`Webhook ${webhook.name} failed on last execution`);
  // Alert or investigate
}

Use Cases

Debugging Webhook Issues

When investigating webhook problems:
  1. Get webhook details
  2. Check last_success status
  3. Verify active is true
  4. Confirm url is correct
  5. Review timeout and retry_count settings

Audit Trail

Retrieve webhook configuration for audit purposes:
const auditWebhook = async (hookId) => {
  const webhook = await getWebhook(hookId);
  
  return {
    id: webhook.id,
    name: webhook.name,
    created: webhook.created_at,
    last_activity: webhook.last_run,
    status: webhook.active ? 'active' : 'inactive'
  };
};

Health Check Dashboard

Display webhook status in admin dashboard:
const webhookHealthCheck = async (hookId) => {
  const hook = await getWebhook(hookId);
  
  return {
    name: hook.name,
    status: hook.active ? '🟢 Active' : '🔴 Inactive',
    lastRun: formatTimestamp(hook.last_run),
    lastResult: hook.last_success ? '✅ Success' : '❌ Failed',
    endpoint: hook.url
  };
};

Interpreting the Response

Last Run vs Created At

  • created_at: When the webhook was registered
  • last_run: When the webhook was last triggered
  • If last_run equals created_at, the webhook has never been triggered

Success Status

  • last_success: true: Last webhook call completed successfully
  • last_success: false: Last webhook call failed (check logs for details)

Active Status

  • active: true: Webhook is enabled and will receive events
  • active: false: Webhook is disabled and will not receive events

Build docs developers (and LLMs) love