Skip to main content

Understanding Webhooks

Webhooks are automated HTTP callbacks that NextAPI sends to your server when events occur. Instead of polling the API for status updates, you receive instant notifications.

How Webhooks Work

Event occurs → NextAPI creates webhook payload → HTTP POST to your endpoint → You acknowledge

NextAPI signs each delivery so you can verify it came from us, not a malicious third party.

Webhook Payload Structure

Every webhook delivery includes:

{
"id": "evt_abc123",
"created": 1705312200,
"type": "payout_request.completed",
"data": {
"id": "pr_xyz789",
"amount": 10000,
"currency": "PHP",
"status": "completed",
"account_id": "acc_456",
"processed_at": "2024-01-15T10:30:00Z"
}
}
FieldDescription
idUnique event ID. Use for deduplication.
createdUnix timestamp of when the event occurred
typeEvent type (e.g., payout_request.completed)
dataThe resource that changed, with its current state

Event Types

Payout Events

EventDescription
payout_request.initiatedPayout request created
payout_request.pendingPayout queued for processing
payout_request.processingPayout being processed by provider
payout_request.completedPayout successfully delivered
payout_request.failedPayout failed
payout_request.cancelledPayout cancelled
payout_request.reversedCompleted payout reversed

Payment Events

EventDescription
payment_intent.createdPayment intent created
payment_intent.paidPayment successfully received
payment_intent.expiredPayment intent expired
payment_intent.cancelledPayment intent cancelled

Delivery and Retries

NextAPI retries failed deliveries with exponential backoff:

AttemptDelayCumulative Wait
1Immediate
21 minute1 minute
35 minutes6 minutes
430 minutes36 minutes
52 hours~2.5 hours

Response expectations:

  • 2xx — Success. Webhook processed, no retry.
  • 4xx — Client error. No retry (fix your endpoint).
  • 5xx — Server error. Retry scheduled.

Your endpoint must respond within 30 seconds or the delivery is considered failed.

Idempotency

Webhook events may be delivered more than once. Always use the id field to deduplicate:

  1. Store processed event IDs
  2. Before processing, check if the event ID was already handled
  3. Skip duplicates

This prevents double-processing (e.g., crediting an account twice for the same payment).

Security

Webhook payloads are signed with your webhook secret. Always verify the signature before processing. The signature is included in the x-nextpay-signature header as an HMAC-SHA256 digest.

For implementation details, see Setup Webhooks.