Helpers for working with Treasury Prime's idempotency support.
Every create/* function in this library accepts an idempotency_key:
option, sent as the X-Idempotency-Key header. When set, Treasury Prime
guarantees the operation is processed at most once no matter how many
times the request is retried (network blips, automatic retries from this
library's own backoff logic, etc.) — this is essential for any
money-movement endpoint (ACH, wire, book transfer, FedNow, ...).
key = TreasuryPrime.Idempotency.generate_key()
TreasuryPrime.Ach.create(client, params, idempotency_key: key)If you don't supply one, no X-Idempotency-Key header is sent at all —
this library never invents one for you, since a key should usually be
generated once per business operation (e.g. once per "pay this invoice"
action in your application, persisted alongside that operation) rather
than once per HTTP call.
Summary
Functions
Generates a random, URL-safe idempotency key suitable for use as an
X-Idempotency-Key header value. Backed by a UUIDv4-shaped random string;
it doesn't need to be a real UUID (Treasury Prime accepts any arbitrary
string), but this format is convenient and collision-resistant.
Functions
@spec generate_key() :: String.t()
Generates a random, URL-safe idempotency key suitable for use as an
X-Idempotency-Key header value. Backed by a UUIDv4-shaped random string;
it doesn't need to be a real UUID (Treasury Prime accepts any arbitrary
string), but this format is convenient and collision-resistant.