Skip to main content

Overview

Idempotency ensures that making the same API request multiple times produces the same result. This is crucial for reliable integrations, especially when network issues cause request failures.

How It Works

Include an Idempotency-Key header with a unique value for each logical request:
If you send the same request with the same Idempotency-Key:
  • First request: Processed normally, result stored
  • Subsequent requests: Return cached result immediately

Using Idempotency Keys

Key Guidelines

Key Format

Good examples:
  • user_123_verify_2025-01-15T10:30:00Z
  • order_456_payment_attempt_1
  • 550e8400-e29b-41d4-a716-446655440000

Key Expiration

Idempotency keys are stored for 24 hours. After expiration:
  • The same key can be reused
  • The request will be processed as new

Key Scope

Keys are scoped to:
  • Your API key
  • The endpoint being called
This means the same key can be used on different endpoints without conflict.

Safe Retry Pattern

Implement retry logic with idempotency:

Response Headers

When a cached response is returned, TXCloud includes:

Handling Conflicts

If you send the same key with different request bodies, you’ll get an error:
Always use a new idempotency key for each unique request. Reusing keys with different parameters is an error.

Endpoints Supporting Idempotency

Best Practices

Generate idempotency keys in your application, not in TXCloud. This ensures retries use the same key.
Make keys meaningful for debugging:
Log idempotency keys with your requests for troubleshooting.
Each logical operation should have its own key:

Example: Payment Processing

A common use case for idempotency is payment processing:

API Reference

Learn more about request handling in the API Reference