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

NextAPI webhook events come in two shapes depending on the event category.

v2-prefixed events (payment instrument, payment intent) use event + payload:

{
"event": "v2.payment_intent.succeeded",
"payload": {
"id": "...",
"account_id": "...",
"amount": 150000,
"external_id": "order-98765",
"status": "succeeded"
}
}

Payout events use type + data:

{
"type": "payout_request.processed",
"data": {
"id": "...",
"source_account_id": "...",
"amount_cents": 50000,
"status": "completed"
}
}
FieldDescription
eventEvent name for v2.* events (e.g., v2.payment_intent.succeeded)
typeEvent name for payout events (e.g., payout_request.processed)
payloadThe resource data for v2.* events
dataThe resource data for payout events

Event Types

Payment Events (v2-prefixed)

These events use event.event and event.payload.

EventDescription
v2.payment_intent.succeededPayment received and settled
v2.payment_intent.canceledPayment intent cancelled
v2.payment_instrument.usedFunding Method instrument used (single-use instruments)
v2.payment_instrument.payment_receivedIncoming payment received (Funding Method)
v2.payment_instrument.payment_settledIncoming payment cleared (Funding Method)

Payout Events

These events use event.type and event.data.

EventDescription
payout_request.creation_failedPayout request failed to create
payout_request.queuedPayout request queued for settlement
payout_request.queue_failedPayout request failed to queue
payout_request.processedPayout request fully processed
payout.succeededIndividual payout delivered
payout.failedIndividual payout failed
payout.processedIndividual payout processing complete
payout.processing_failedIndividual payout processing failed

Platform Events

These events use event.type and event.data.

EventDescription
deposit.confirmedInbound deposit confirmed on an account
direct_transfer.receivedDirect transfer received by an account
legal_entity.verification_status_changedMerchant KYC/compliance verification status updated

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

NextAPI delivers webhooks through Svix. Every delivery is signed using three headers: svix-id, svix-timestamp, and svix-signature. Always verify these using the Svix SDK before processing an event — do not re-implement the HMAC algorithm manually.

The webhook secret is returned in whsec_<base64> format when you create a webhook. Svix enforces a 5-minute timestamp tolerance automatically, so replay attacks are handled for you.

For implementation details, see Verify Webhook Signatures and Setup Webhooks.