Idempotency

POST/v2/transfers requires an Idempotency-Key header. Send one key per transfer you intend to create, and send that same key on every retry of that request. Confirm, capture, refund, void, update, and read do not use the header.

V1 has no equivalent. POST/v1/transfers still needs a query-before-retry shape. Billing metric events dedupe on reference. Webhook handlers dedupe on event ID.

Transfers V2 — Idempotency-Key

Every POST/v2/transfers request needs an Idempotency-Key header, on the first attempt and not only on a retry. Frame saves the outcome under that key. Retrying with the same key and the same body returns the saved outcome, or finishes the original request, instead of creating a second transfer. The rules are the same for payments, payouts, and account transfers.

curl --request POST \
  --url https://api.framepayments.com/v2/transfers \
  --header "Authorization: Bearer $FRAME_SECRET_KEY" \
  --header "Idempotency-Key: 7f3c1a2e-9b04-4d11-8c6a-2e5b0f91d4aa" \
  --header "Content-Type: application/json" \
  --data '{
    "amount": { "value": 1000, "currency": "usd" },
    "source": { "payment_method_id": "pm_..." }
  }'

A replayed response carries the original status and body, plus one extra header:

HTTP/1.1 201 Created
Idempotent-Replay: true

How keys work

  • Format. Any string of 1 to 255 characters. Use a random v4 UUID. Don't build keys from customer data such as an email address or card details.
  • One key per transfer. Generate the key before the first attempt, store it with the order or payout it belongs to, and send it verbatim on every retry of that request. Never use it for a different transfer.
  • Scope. Keys are scoped to your merchant account and to live or sandbox mode, not to an API key. A key sent with one of your API keys matches requests sent with any of your other API keys in the same mode.
  • Checked first. The header is validated before the request body.
  • Retention. A saved response is kept for 24 hours. After that, the key can be reused, and reusing it creates a new transfer. A request that never finished does not expire: a retry still attaches to the original transfer, even after 24 hours.
  • Same request means the same method, path, and body. Key order doesn't matter. Card fields (card_number, cvc, cvv, number, account_number, cryptogram, and strings starting with ev:) are left out of the comparison because they are re-encrypted on every retry. Changing the amount, currency, payment method id, expiry, metadata, or any other field returns idempotency_key_reused.

What a retry returns

First responseSaved?A retry with the same keyWhat to do
201, including a payment that failed or was declinedYesReturns the same 201 with Idempotent-Replay: true. Nothing is charged again.Use the body. To try a declined payment again, send it with a new key.
422 validation_errors: an invalid field, an unknown currency, or a referenced id that does not existYesReturns the same 422.Fix the request and send it with a new key. A corrected body under the old key returns idempotency_key_reused.
422 validation_errors for a malformed amountNo. It is rejected before the key is recorded.Is treated as a first attempt.Fix the amount and retry. The key is still unused.
422 blocked: a restricted account, or merchant processing pausedYesReturns the same 422.Resolve the block, then send a new key.
422 payment_method_single_useYesReturns the same 422.Use a different payment method with a new key.
422 external_api_error or persistence_errorNoContinues the original transfer without repeating steps that already finished.Retry with the same key and the same body.
500, a timeout, or no responseNoContinues the original transfer without repeating steps that already finished.Retry with the same key and the same body.
A 422 can mean the money already moved

external_api_error and persistence_error can arrive after the processor has charged the card or sent the payout. Retry with the same key: Frame picks up the original transfer where it stopped and does not charge again. Once it finishes, the retry returns the normal 201. Never retry these with a new key, and never treat the transfer as failed. A new key starts a new transfer and can charge the card a second time.

Key errors

SituationStatuscode
Header missing or blank400idempotency_key_required
Longer than 255 characters400idempotency_key_invalid
Same key, different request, within 24 hours of a saved response400idempotency_key_reused
Same key, another request still running409idempotency_in_progress (Retry-After: 1)
The original request lost its lock409idempotency_lease_lost (Retry-After: 1)
{ "status": 400, "error": "An idempotency key is required.", "code": "idempotency_key_required" }

Retrying safely

  1. Generate a v4 UUID for each transfer you intend to create, and store it before the first attempt.
  2. On a network error, a timeout, a 500, or a 422 external_api_error or persistence_error, retry with the same key and the same body. Back off exponentially between attempts.
  3. On a 409, wait for Retry-After seconds, then retry with the same key.
  4. On Idempotent-Replay: true, treat the body as the original outcome.
  5. On idempotency_key_reused, stop. The key belongs to a different request, which is a bug in how your client assigns keys.
  6. Use a new key only for a new transfer: after a decline, or after fixing a request that returned a saved 422.

Other V2 endpoints

PATCH /v2/wallets/{id} also requires Idempotency-Key, with the same format, scope, 24-hour replay, and 400/409 codes. Confirm, capture, refund, void, update, and read on transfers do not use the header. For the request body of each transfer type, see Use Transfers V2.

Billing events — reference is the dedup key

Billing metric events are the one V1 place Frame enforces idempotency. The reference field on POST /v1/billing/metering_events is a globally-unique key that Frame stores with a uniqueness constraint:

curl --request POST \
  --url https://api.framepayments.com/v1/billing/metering_events \
  --header "Authorization: Bearer $FRAME_SECRET_KEY" \
  --data '{
    "customer": "<customer_id>",
    "event_name": "api_call",
    "reference": "req_8f3a2c1e_2026-06-05T14:23:00Z",
    "value": 1
  }'

Same reference value on a retry returns a duplicate_reference signal rather than logging the event twice. This is the only API surface in Frame V1 with safe-replay built in.

Derive the reference deterministically from your business logic — request ID, idempotency key, a composite of customer + timestamp + action. Whatever you pick, ensure the same logical event always produces the same reference, even across retries / app restarts / queue redelivery.

See metering for the deeper model.

V1 transfers and charges — query-before-retry

For POST /v1/transfers (and other V1 money-movement endpoints), there's no client-supplied idempotency key. The safe pattern when you need to retry after a timeout:

  1. Don't retry blindly. A blind retry on an ambiguous outcome can double-charge.
  2. Query first. GET /v1/charges?account_id=<id> (or scoped equivalent) — look for a recent charge matching the amount + payment method + account that you were about to create.
  3. Retry only if no recent match. If a charge from the past few minutes matches your intended request, treat the original as successful and use that record. Otherwise, retry.
async function safeCreateTransfer({ accountId, paymentMethodId, amountCents }) {
  try {
    return await frame.transfers.create({ ... });
  } catch (err) {
    // Network timeout — outcome ambiguous.
    if (isTimeoutError(err)) {
      const recent = await frame.charges.list({
        account_id: accountId,
        // ...filter by recency + match criteria
      });
      const match = recent.find(c =>
        c.amount_cents === amountCents &&
        c.payment_method_id === paymentMethodId &&
        Date.now() - new Date(c.created).getTime() < 5 * 60 * 1000
      );
      if (match) return match;  // Original landed; use it.
      // No match — safe to retry.
      return await frame.transfers.create({ ... });
    }
    throw err;
  }
}

This pattern doesn't generalize perfectly — if the customer made another charge of the same amount in the past 5 minutes, you'll false-positive. Tighten the match criteria (include a metadata field with your idempotency UUID, then look for it on returned charges) for production-quality recovery.

Do not use this pattern for V2. Send Idempotency-Key instead.

Webhook handlers — dedupe on event ID

Inbound webhook deliveries can repeat. Frame retries failed deliveries up to 3 times (see events and webhooks), so your handler will sometimes see the same event twice — once from the original delivery your endpoint timed out on, again from the retry.

Dedupe handler-side by tracking processed event IDs:

async function handleWebhook(event) {
  const alreadyProcessed = await db.events.exists({ frame_event_id: event.id });
  if (alreadyProcessed) {
    return { status: 'ok', deduped: true };
  }

  await db.transaction(async tx => {
    await tx.events.insert({ frame_event_id: event.id, ... });
    await applyBusinessLogic(event);
  });
}

This is the standard webhook-handling pattern; nothing Frame-specific. The Frame event payload includes a unique id that's stable across retries.

Subscription renewals and invoice charges

Subscription renewals charge automatically each cycle; if a charge fails, Frame doesn't auto-retry subscription-renewal invoices. Your application orchestrates recovery (notify the customer, update payment method, re-issue the invoice).

Billing-pipeline invoices (those generated via POST /v1/billing/billing_invoice) do auto-retry — Billings::RetryFailedChargesJob runs daily at 2 AM and retries failed billing charges up to 3 attempts within 72 hours. See build postpaid billing for the recovery semantics.

Metadata as a client-side tracker on V1

A pragmatic workaround for V1 endpoints without dedup: pass your own UUID in the request's metadata field, then query by that metadata on retry:

# First attempt
curl --request POST \
  --url https://api.framepayments.com/v1/transfers \
  --data '{
    "amount": 5000,
    "currency": "USD",
    "account_id": "<account_id>",
    "payment_method_id": "<payment_method_id>",
    "metadata": { "idem_key": "<your_uuid>" }
  }'

# On timeout, before retrying: query for the UUID
curl --request GET \
  --url "https://api.framepayments.com/v1/charges?account_id=<account_id>" \
  --header "Authorization: Bearer $FRAME_SECRET_KEY"
# ...iterate, check metadata for { idem_key: "<your_uuid>" }

If you find a record with the UUID, the original landed — use it. If not, retry safely.

The downside: metadata is limited (20 entries per object, 40-char keys, 100-char values), so reserve one key for the idempotency UUID and never reuse it for anything else.

On V2, Idempotency-Key is the primitive. Do not use metadata as a substitute for it.

Gotchas

Symptom: you retried a V1 transfer create after a timeout and ended up with two charges. Why: there's no built-in dedup on /v1/transfers, and blind retry duplicated the request. Fix: implement the query-before-retry pattern above, or move the charge to Transfers V2 and send Idempotency-Key. Refund the duplicate.

Symptom: a V2 create returned idempotency_key_reused. Why: the body changed under a key that already completed (amount, currency, payment method id, expiry, metadata, or any compared field). Card ciphertext is ignored; everything else is not. Fix: use a new key when the request is intentionally different. Do not retry the old key.

Symptom: your billing events keep getting duplicate_reference responses even though you meant to log distinct events. Why: your reference derivation isn't producing unique values per event — probably collapsing to the same value when you intended otherwise (e.g., using just customer_id without a timestamp). Fix: include enough variability in the reference to uniquely identify each logical event (request ID, timestamp at millisecond precision, action+entity composite).

Symptom: your webhook handler processed the same event twice and applied a side effect twice. Why: Frame retries failed deliveries; your handler isn't deduping. Fix: implement the event-ID dedup pattern above. The event's id is stable across retries.

Reference

For V2 create keys, see POST/v2/transfers and Use Transfers V2. For the V1 billing primitive, see POST/v1/billing/metering_events. For V1 charge recovery, see transfers + handle declines.

Frame Assistant

Ask anything about Frame's APIs and products