Laravel Packages

Safely Retry API calls in Laravel

Published
Safely Retry API calls in Laravel image

Idempotency for Laravel is a production-ready package for implementing idempotency in API requests. Clients can safely retry API calls using this package without worrying about duplicate processing.

Using the Idempotency-Key header with a unique UUID, you can send the same key over and over, and the original response is returned without running an operation multiple times:

POST /api/payments HTTP/1.1
Content-Type: application/json
Idempotency-Key: 123e4567-e89b-12d3-a456-426614174000
 
{
"amount": 1000,
"currency": "USD",
"description": "Order #1234"
}

When using this package, API responses include an Idempotency-Key that API users safely use in the future to re-run the operation.

Main Features

  • Robust Cache Mechanism: Reliably stores and serves cached responses
  • Lock-Based Concurrency Control: Prevents race conditions with distributed locks
  • Comprehensive Telemetry: Track and monitor idempotency operations
  • Alert System: Get notified about suspicious activity
  • Payload Validation: Detect when the same key is used with different payloads
  • Detailed Logging: Easily debug idempotency issues

You can learn more about this package, get full installation instructions, and view the source code on GitHub. You can install this package via Composer:

composer require infinitypaul/idempotency-laravel
php artisan vendor:publish --provider="Infinitypaul\Idempotency\IdempotencyServiceProvider"
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
Laravel Auditor Audits Your App With Your Own AI Agent image

Laravel Auditor Audits Your App With Your Own AI Agent

Read article
A simple form builder that stays out of your way image

A simple form builder that stays out of your way

Read article
Laravel AI: Trace Agent Runs With Lifecycle Events image

Laravel AI: Trace Agent Runs With Lifecycle Events

Read article
Laravel AI: Get Raw HTTP Responses and Rate Limits image

Laravel AI: Get Raw HTTP Responses and Rate Limits

Read article
Agent Run Observability in Laravel AI SDK 0.11 image

Agent Run Observability in Laravel AI SDK 0.11

Read article
Debounced Queued Event Listeners in Laravel image

Debounced Queued Event Listeners in Laravel

Read article