Skip to main content
The List Hooks endpoint can function as a Dead Letter Queue (DLQ). You can fetch all failed hooks within a specific time range, process them, and then delete them.

Workflow

  1. List Failed Hooks: Use status=failed and filters like postAtAfter (e.g., “yesterday”).
    for await (const hook of posthook.hooks.listAll({
      status: 'failed',
      postAtAfter: '2025-01-01T00:00:00Z'
    })) {
      console.log(hook.id, hook.path);
    }
    
  2. Process: Iterate through the list and handle the failures (e.g., log them, alert a team, or manually fix the data).
  3. Delete: Once processed, delete the hook to remove it from the queue.
    DELETE /hooks/{id}
    
Automate this with Sequences: You can set up a recurring Sequence Pattern to trigger your DLQ processing endpoint every day.

Bulk Retry

If you had a temporary outage (e.g., your database was down), you can batch retry failures instead of deleting them.
  1. List Failed Hooks (as above).
  2. Extract IDs: Collect the id from each hook (or use the SDK’s bulk retry directly).
  3. Bulk Retry:
    const result = await posthook.hooks.bulk.retry({
      hookIDs: ['e5405623-2c1c-460e-9737-c884f7f59035', 'a1b2c3d4-5678-90ab-cdef-1234567890ab', 'f9e8d7c6-5432-10fe-dcba-0987654321fe']
    });
    console.log(`Retried ${result.affected} hooks`);