# `PaperTiger.Plugs.Idempotency`
[🔗](https://github.com/EnaiaInc/paper_tiger/blob/v1.2.1/lib/paper_tiger/plugs/idempotency.ex#L1)

Handles Stripe-compatible idempotency key processing.

Prevents duplicate POST requests from creating duplicate resources by
caching responses keyed by the `Idempotency-Key` header.

## Usage

    # In router
    plug PaperTiger.Plugs.Idempotency

## Behavior

- **GET requests** - Idempotency keys ignored (safe methods)
- **POST with key** - Check cache, return cached response if exists
- **POST without key** - Process normally (not idempotent)

## Cache Storage

Responses cached for 24 hours via `PaperTiger.Idempotency`.

## Implementation

This plug only checks the cache. Storing responses happens in resource
handlers after successful processing.

## Example

    # First request with key
    POST /v1/customers
    Idempotency-Key: abc123
    => Creates customer, stores response

    # Duplicate request (network retry)
    POST /v1/customers
    Idempotency-Key: abc123
    => Returns cached customer (no duplicate created)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
