Skip to content

Add idempotency key support for write requests #14

Open

Description

@codebestia

Description

POST requests that create resources (payments, invoices, transfers) should support an idempotency key so that retries caused by network failures don't create duplicate records. The key is forwarded as an Idempotency-Key header and the server will return the same response for duplicate requests.

Proposed Steps

  • Add idempotency_key: Optional[str] = None to all create resource methods.
  • When provided, include it as Idempotency-Key: <value> in the request headers.
  • Auto-generate a UUID idempotency_key when the HTTP client auto-retries a write (so retries are safe by default).
  • Document the idempotency window (typically 24 hours) in docstrings.

Acceptance Criteria

  • Passing idempotency_key="my-key" to a create method sends Idempotency-Key: my-key in the header.
  • Omitting idempotency_key on auto-retried write requests still sends a generated UUID key.
  • A duplicate request with the same key returns the original resource without error.
  • GET/DELETE requests ignore the idempotency_key argument.

Activity

  1. guptakumarranjeet150 commented on Oct 3, 2026

    @guptakumarranjeet150

    Hi maintainers,

    I reviewed this issue and would like to contribute the fix.

    Technical outline:

    1. Inspect repository architecture in shadeprotocol/shade-python for an idiomatic solution.
    2. Implement the feature/fix with clean modular separation and robust error handling.
    3. Add comprehensive unit and integration test coverage for all edge cases.
    4. Verify that all linters, formatting, and CI checks pass cleanly.

    Could you please assign this issue to me? Looking forward to delivering a clean PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions