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 anIdempotency-Key header with a unique value for each logical request:
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:00Zorder_456_payment_attempt_1550e8400-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
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:Endpoints Supporting Idempotency
Best Practices
Generate Keys Client-Side
Generate Keys Client-Side
Generate idempotency keys in your application, not in TXCloud. This ensures retries use the same key.
Include Context in Keys
Include Context in Keys
Make keys meaningful for debugging:
Store Keys for Debugging
Store Keys for Debugging
Log idempotency keys with your requests for troubleshooting.
Don't Reuse Keys Across Operations
Don't Reuse Keys Across Operations
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