Prompt

I'm building an API product and need webhook retry logic and delivery logs

Technology / API Platforms2 observationsLast seen Nov 25, 2026

Latest observation

Nov 25, 2026OpenAI APIWeb search: off

A solid webhook system usually needs two separate but related pieces:

  1. Retry delivery logic — so failed webhook attempts are retried safely.
  2. Delivery logs / observability — so you and your customers can inspect what happened.

Here’s a practical design you can use.


1) Webhook delivery model

Each webhook event should create a delivery record per subscriber endpoint.

Core entities

  • Webhook Subscription

    • id
    • customer_id
    • url
    • secret
    • enabled
    • event_types
    • created_at
  • Webhook Event

    • id
    • event_type
    • payload
    • created_at
    • idempotency_key / event_uuid
  • Webhook Delivery

    • id
    • event_id
    • subscription_id
    • attempt_number
    • status (pending, success, failed, retry_scheduled, dead_letter)
    • http_status
    • request_headers
    • response_body (truncated)
    • error_message
    • next_retry_at
    • created_at
    • updated_at

2) Retry logic

Recommended retry policy

Use exponential backoff with jitter.

Example:

  • Attempt 1: immediate
  • Attempt 2: 1 min
  • Attempt 3: 5 min
  • Attempt 4: 15 min
  • Attempt 5: 1 hour
  • Attempt 6: 6 hours
  • Then mark as failed/dead-letter

Add random jitter to avoid retry storms.

Retry only on transient failures

Retry for:

  • Network timeouts
  • DNS failures
  • Connection resets
  • HTTP 408
  • HTTP 429
  • HTTP 5xx

Do not retry for most 4xx responses:

  • 400, 401, 403, 404, 422 These typically indicate a permanent issue.

Success criteria

Treat as success if:

  • HTTP status is 2xx
    Optionally also allow:
  • 3xx only if you explicitly want to follow redirects, though most webhook systems avoid this.

Timeout behavior

Set a strict timeout for webhook delivery:

  • Connect timeout: 2–5s
  • Total request timeout: 5–10s

Don’t let delivery workers hang indefinitely.

Idempotency

Assume retries may duplicate events. Include:

  • event_id
  • delivery_id
  • attempt
  • signature

Customers should dedupe using event_id or your X-Webhook-Id header.


3) Delivery request format

Send headers like:

POST /webhooks HTTP/1.1
Content-Type: application/json
X-Webhook-Id: evt_123
X-Webhook-Type: invoice.paid
X-Webhook-Timestamp: 1730000000
X-Webhook-Signature: sha256=...
User-Agent: YourProduct-Webhooks/1.0

Payload example:

{
  "id": "evt_123",
  "type": "invoice.paid",
  "created_at": "2026-11-25T10:00:00Z",
  "data": {
    "invoice_id": "inv_456",
    "amount": 2500,
    "currency": "usd"
  }
}

Sign the raw body using HMAC SHA-256 with the subscription secret.


4) Delivery logs

You want logs for both:

  • internal debugging
  • customer-visible audit history

Log fields to store

For each attempt:

  • Delivery ID
  • Event ID
  • Subscription ID
  • Attempt number
  • Request timestamp
  • Response timestamp
  • Duration ms
  • HTTP status
  • Error type
  • Error message
  • Response body snippet
  • Retry scheduled time
  • Final outcome

What to expose in your UI/API

A customer should be able to see:

  • Event name
  • Endpoint URL
  • Delivery status
  • Number of attempts
  • Last attempt time
  • HTTP response status
  • Error reason
  • Full request headers
  • Full response body if safe, or truncated
  • Replay button

Suggested delivery states

  • pending
  • sending
  • success
  • retry_scheduled
  • failed
  • dead_letter
  • disabled (if subscription turned off)

5) Replay support

Very useful for customers.

Allow them to manually replay:

  • a failed delivery
  • a successful delivery
  • all deliveries for an event

Replay should:

  • create a new delivery attempt or new delivery record
  • preserve original event ID
  • maintain an audit trail

6) Queue + worker architecture

A reliable pattern:

  1. Event created in your app
  2. Persist event + delivery records
  3. Enqueue delivery job
  4. Worker sends webhook
  5. Worker records result
  6. If retryable failure, schedule next retry

Good infrastructure options

  • Queue: SQS, RabbitMQ, Redis queue, Kafka
  • Scheduler: delayed jobs / retry queue / cron poller
  • DB: Postgres for source of truth

Use the DB as the canonical record and the queue for execution.


7) Abuse and safety protections

Add:

  • Per-endpoint rate limits
  • Retry caps
  • Circuit breaker for consistently failing endpoints
  • Endpoint disablement after repeated hard failures
  • Payload size limit
  • Secret rotation support

If an endpoint fails repeatedly, consider:

  • pausing deliveries
  • notifying the customer
  • requiring re-verification

8) API endpoints you may want

Manage subscriptions

  • POST /webhook-subscriptions
  • GET /webhook-subscriptions
  • PATCH /webhook-subscriptions/{id}
  • DELETE /webhook-subscriptions/{id}

Delivery logs

  • GET /webhook-deliveries
  • GET /webhook-deliveries/{id}
  • GET /webhook-events/{id}/deliveries

Replay

  • POST /webhook-deliveries/{id}/replay

9) Minimal retry algorithm

Pseudo-logic:

attempt delivery
if 2xx:
    mark success
else if retryable and attempts < max_attempts:
    compute backoff delay
    mark retry_scheduled
    enqueue next attempt
else:
    mark failed or dead_letter

Retryable failure detection:

  • timeout / network error
  • 408 / 429 / 5xx

10) Recommended defaults

A good starting config:

  • Max attempts: 8
  • Timeout: 10s total
  • Backoff: exponential with jitter
  • Retry on: network errors, 408, 429, 5xx
  • Log retention: 30–90 days
  • Payload retention: depends on your privacy model
  • Dead-letter after max attempts

If you want, I can also give you:

  1. a database schema for this,
  2. production-grade pseudocode for the retry worker,
  3. or a Node/Python implementation with logs and replay endpoints.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.