idempotency-key

Implement Redis-backed idempotency for NestJS mutating API endpoints.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/mthang1801/go-domain-driven-design --skill idempotency-key
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: idempotency-key
Source: https://github.com/mthang1801/go-domain-driven-design/tree/main/.claude/skills/idempotency-key
Command: npx skills add https://github.com/mthang1801/go-domain-driven-design --skill idempotency-key

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The Idempotency Key pattern ensures that multiple identical requests from a client (e.g., due to network retries, double-clicks) result in only a single execution of the operation on the server. This prevents duplicate mutations and preserves data integrity.

Core Features & Use Cases

  • Header-driven deduplication: Clients must provide an Idempotency-Key header for mutating requests (POST, PUT, PATCH, DELETE).
  • Middleware/Interceptor support: Implement an IdempotencyInterceptor or equivalent to capture keys and payloads.
  • State management with Redis: Use a lightweight state machine (PENDING, COMPLETED, FAILED) and a TTL (e.g., 24 hours) to guard against repeated processing.
  • Use cases: Guard for order creation, payments, and other operations where retries should not produce duplicates.

Quick Start

Add an IdempotencyInterceptor to your NestJS app and apply it to endpoints that mutate data using the Idempotency-Key header.

Frequently Asked Questions about idempotency-key

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent duplicate requests in NestJS from network retries or double-clicks?

To prevent duplicate requests in NestJS, implement an idempotency mechanism using an interceptor and the Idempotency-Key header to ensure identical client requests result in only a single execution.

How does Redis manage idempotency state for mutating API endpoints?

Redis manages idempotency state by using a lightweight state machine with PENDING, COMPLETED, and FAILED statuses, alongside a 24-hour TTL to guard against repeated processing of identical request payloads.

When do I need to use an Idempotency-Key header for my API?

You need an Idempotency-Key header for mutating API endpoints (POST, PUT, PATCH, DELETE) that require repeat-safe execution, such as order creation or payment processing operations.

How do I add an idempotency interceptor to a NestJS backend?

To add idempotency to a NestJS backend, implement an IdempotencyInterceptor to capture the Idempotency-Key header and payload, applying it to endpoints that mutate data.

Does this request deduplication approach require a specific database or cache?

Yes, this request deduplication approach requires Redis to manage the state lifecycle and handle the 24-hour TTL for tracking PENDING, COMPLETED, and FAILED request states.

What is the difference between using an idempotency key and standard API rate limiting?

An idempotency key ensures identical repeated mutating requests execute only once to preserve data integrity, whereas standard API rate limiting simply restricts the volume of requests without deduplicating payloads.