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

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article