Skip to main content

What is Idempotency?

Idempotency means you can safely retry the same request multiple times without creating duplicates. This is critical for:
  • Network failures and timeouts
  • Uncertain transaction states
  • Retry logic in distributed systems
  • Preventing accidental duplicates

Two Idempotency Mechanisms

1. External ID Pattern

Use external_id field to ensure resources are created only once:
Behavior:
  • First request: Creates resource, returns 201 Created
  • Retry with same external_id: Returns existing resource, returns 200 OK
The external_id should be unique within your system and stable (don’t change it).

2. Idempotency-Key Header

For operations that don’t support external_id, use the Idempotency-Key header:
Behavior:
  • First request: Processes payment, returns 201 Created
  • Retry with same key: Returns cached response, returns 200 OK

Resources Supporting external_id

Businesses

Invoices

Bills

Customers & Vendors

Operations Supporting Idempotency-Key Header

Invoice Payments

Bill Payments

Idempotency Key Format

Use a format that combines relevant identifiers:
  • Entity type + ID: invoice-123
  • Entity + date: payment-20240115-001
  • UUID: 550e8400-e29b-41d4-a716-446655440000
Good Examples:
Bad Examples:

Idempotency Window

Idempotency keys are stored for 24 hours. After that, the same key can be reused for a new transaction.

Response Status Codes

The response body is identical in both cases.

Best Practices

Generate Stable IDs

Check Response Status

Use for All Creates

Always provide external_id or Idempotency-Key when creating resources:

Handling Conflicts

If you retry with different data but same external_id:
Idempotent retries with the same external_id always return the original resource, even if request data differs.To update a resource, use the update endpoint instead.

Example: Safe Invoice Creation

Next Steps

Error Handling

Handle errors during retries

Authentication

Token refresh during retries