Skip to content

Attributes

[Idempotent]

Marks a dispatch handler as requiring an idempotency key. When applied, the generated endpoint enforces that the Idempotency-Key header is present and the request is deduplicated.

[CommandHandler]
[HttpPost("/orders")]
[Idempotent]
public static Eff<AppRuntime, OrderPlaced> Handle(CreateOrder cmd) =>
    from order in CreateAndSave(cmd)
    select new OrderPlaced(order.Id);
Property Type Default Description
(none) Marker attribute with no properties

Behavior:

  1. Client sends POST /orders with header Idempotency-Key: order-abc-123
  2. Middleware calls IIdempotencyStore.TryClaimAsync("order-abc-123")
  3. First request: claim succeeds → handler executes → response cached
  4. Duplicate request: claim fails → cached response returned (or 409)

Without [Idempotent]: The middleware still runs for configured HTTP methods (POST, PUT, PATCH by default), but [Idempotent] makes the intent explicit and enables per-handler opt-in when the global middleware is disabled.

[ConfigSection("Deepstaging:Idempotency")]

Applied to IdempotencyOptions — binds configuration from appsettings.json:

{
    "Deepstaging": {
        "Idempotency": {
            "HeaderName": "Idempotency-Key",
            "DefaultTtl": "1.00:00:00",
            "RequiredMethods": ["POST", "PUT", "PATCH"],
            "ExcludedPaths": ["/health", "/swagger"],
            "ReturnCachedResponse": true
        }
    }
}

See Overview for the full configuration reference.