Independent developer reference: code samples describe implementation patterns and are not live hosted endpoints.
Operations guide

Idempotency and Retry Safety for Token Minting APIs

A detailed design for idempotency keys, canonical request hashes, durable state machines, ambiguous submissions, and response replay.

Idempotency for Minting APIs featured graphic with MintAPI.com branding

A mint request can be processed even when the client never receives the response. The connection may close after the server writes an operation, after a signer approves, after a node accepts the transaction, or after the chain confirms. From the client's perspective these cases can look identical: a timeout. Retrying without a shared identity can create another transaction and duplicate the token issuance.

Idempotency gives repeated requests one logical result. It does not mean the server ignores retries or that every blockchain instruction is naturally idempotent. It means the API records a durable relationship among a client-provided key, authenticated scope, canonical request, operation resource, and eventual chain evidence, then returns that same operation whenever the request is repeated.

Require a key on every state-changing mint request

Use an explicit header such as Idempotency-Key and require a high-entropy value generated for one business action. A UUID or similarly random identifier is practical. Do not derive the key only from a timestamp, recipient, or amount; legitimate separate mints can share those values, and predictable keys can collide across callers.

Scope the key to the authenticated tenant or principal and the endpoint family. The same text used by two customers should not collide. Define a maximum length and allowed character set, log a fingerprint rather than the full value when logs are broadly accessible, and return the key or its reference in the operation resource for support correlation.

Bind the key to a canonical request hash

Store a cryptographic hash of the normalized request beside the key. Normalization should resolve insignificant differences such as JSON field order while preserving meaningful distinctions such as recipient, network, asset, amount, metadata version, and external business reference. Include the authenticated scope and API version so a key cannot be replayed under another identity or contract.

When a repeated key has the same hash, return the existing operation and a response that makes replay clear. When the hash differs, reject with a stable conflict code such as idempotency_key_reused. Never mutate the existing operation to match the new payload; doing so destroys the audit trail and can make a previously signed transaction appear to represent different intent.

Create the operation before external side effects

The database transaction that reserves the idempotency key should also create the mint operation or link to an existing one. This write must complete before the signer or RPC provider is called. Otherwise a process crash can leave a submitted transaction with no durable key mapping, allowing the retry to create another operation.

Use a uniqueness constraint on the scoped key rather than relying only on application checks. Two concurrent requests can both observe no record and race. The database should allow only one winner, and the loser should load and return the winning operation after verifying the request hash.

Make the state machine resumable

Store enough information to resume each stage: normalized request, configuration version, policy result, transaction construction data, signer request identifier, signed transaction hash or signature, submission attempts, confirmation observations, and reconciliation result. Workers should claim operations through leases or compare-and-set transitions so two processes do not submit the same logical request independently.

A retry from the client should not execute the state machine inline. It should read the durable resource. Background workers can continue or recover processing based on state. This separation keeps HTTP retries cheap and prevents a caller from creating parallel sign-and-submit paths by opening several connections.

Distinguish transaction rebroadcast from reminting

Rebroadcasting the exact same signed transaction is generally an attempt to deliver the same chain action. Constructing and signing a new transaction may represent a second action even when the high-level fields are identical. The service must know which operation it is performing. Store the signed transaction identifier before or atomically with the first broadcast attempt whenever the chain model allows it.

On EVM networks, the sender and nonce help identify replacements for one logical transaction. On Solana, a renewed recent blockhash produces a different signed transaction and requires confirmation that the prior one did not land. Chain adapters should implement evidence-based retry rules rather than exposing a generic 'try again' switch to application code.

Handle the ambiguous submission window

The most dangerous state occurs when submission returns no reliable answer. Query the network using the known transaction hash or signature and inspect account nonce, receipt, signature status, or relevant program state. Repeat those reads across a bounded period and, for important operations, across more than one provider. Do not translate a timeout directly into failed.

If the service cannot prove success or prove that the transaction can no longer execute, set needs_review or a similarly explicit status. Alert an operator and block automatic reconstruction. Operational pressure to 'unstick' a request is exactly when accidental duplicate supply is most likely.

Replay the resource response consistently

A repeated POST can return the current representation of the existing operation rather than a byte-for-byte copy of the first response. Document that behavior. The status may have advanced from accepted to confirmed, and returning the current resource is often more useful. Keep immutable fields stable and expose timestamps so the client can understand the progression.

Use the same operation ID and canonical location header on original and replayed responses. Include a replay indicator if it helps debugging, but do not make clients depend on it for correctness. Clients should treat the operation ID as the durable identity and poll or consume webhooks for status.

Choose retention based on business duplication risk

A short idempotency window may be enough for low-impact API writes, but token issuance can be retried days later by job systems, support staff, or batch replays. Retain the mapping at least as long as the operation and business process can be resubmitted. For unique assets, the external asset key may need a permanent uniqueness record even after the idempotency key expires.

Archival can move old records to cheaper storage while preserving a lookup index. Do not reuse keys automatically after expiration without a clear contract; a client cannot safely know whether an old request disappeared from the server. Return explicit expiration metadata when the policy is finite.

Test races, crashes, and timeouts deliberately

Send the same key concurrently from many connections and prove that only one operation and one external side effect exist. Crash the worker after operation creation, after signing, before submission, after submission, and before confirmation storage. Restart and verify that processing resumes from evidence rather than from assumptions. Inject slow database commits and provider timeouts to expose ordering flaws.

Also test the mismatch path: same key with a different amount, recipient, metadata version, or tenant. Verify that the API rejects it without changing the original resource. Inspect logs and metrics to ensure support teams can correlate replays without seeing secrets or full authentication data.

Combine idempotency with business uniqueness

An idempotency key answers whether two HTTP requests represent the same client-declared action. It does not know whether two different keys refer to the same invoice, reward, ticket, or physical item. Add a stable external reference and a uniqueness policy where the product requires one issuance per business object.

The external reference can map to the confirmed token or operation and reject a second mint even from another client process. This defense is essential for NFT serial numbers and useful for fungible distributions tied to a one-time entitlement. Together, idempotency and business uniqueness address both network retries and application-level duplication.

Primary standard or official reference

RFC 9110: HTTP Semantics. HTTP distinguishes safe and idempotent method semantics, but a blockchain mint is an application-specific state change; a POST endpoint therefore needs an explicit idempotency contract and durable duplicate detection.

Conclusion

Retry safety comes from durable identity and evidence. Reserve the scoped idempotency key before side effects, bind it to a canonical request, create one operation resource, coordinate workers, store signed transaction identity, distinguish rebroadcast from reconstruction, and preserve ambiguous outcomes for reconciliation. A timeout is a missing answer, not proof that nothing happened.

Apply a second uniqueness layer to business assets that must be issued once. With both controls, clients can retry confidently and operators can recover from failures without using a second mint as a troubleshooting technique.

Continue building

Related guides

Continue the implementation path.