Skip to content

Add idempotency key support for write requests #14

@codebestia

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions