Skip to content

Commit 8a4e47a

Browse files
authored
fix:adding idempotency to readme (#267)
### TL;DR Added comprehensive idempotency documentation to the OpenAPI README, covering requirements for money movement endpoints, implementation details, and SDK usage examples. ### What changed? Added a new "Idempotency" section to the OpenAPI README that includes: - Requirements for endpoints that trigger money movement to support idempotency - Reference to the IETF Idempotency-Key HTTP Header Field specification - Table listing specific endpoints requiring idempotency (`POST /quotes` with `immediatelyExecute: true`, `POST /quotes/{quoteId}/execute`, `POST /transfer-in`, `POST /transfer-out`) - Detailed explanation of how idempotency works with different response scenarios (2xx/4xx stored, 5xx retried) - Code examples for TypeScript and Kotlin SDKs showing idempotency key usage - Design guidelines for adding new money movement endpoints ### How to test? Review the documentation for accuracy and completeness. Verify that the listed endpoints and SDK examples align with the actual API implementation and SDK interfaces. ### Why make this change? This documentation ensures developers understand how to properly implement idempotency for financial operations, preventing duplicate transactions that could occur due to retries, network failures, or client timeouts. Clear guidelines also help maintain consistency when adding new money movement endpoints.
1 parent 1651992 commit 8a4e47a

5 files changed

Lines changed: 109 additions & 0 deletions

File tree

mintlify/openapi.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,62 @@ All errors follow a consistent structure:
616616

617617
---
618618

619+
## Idempotency
620+
621+
Any API endpoint that triggers money movement **must** support idempotency to prevent duplicate transactions caused by retries, network failures, or client timeouts.
622+
623+
We follow the [IETF Idempotency-Key HTTP Header Field](https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/) specification.
624+
625+
### Endpoints Requiring Idempotency
626+
627+
| Endpoint | Description |
628+
|----------|-------------|
629+
| `POST /quotes` (with `immediatelyExecute: true`) | Creates and executes a quote in one step |
630+
| `POST /quotes/{quoteId}/execute` | Executes a previously created quote |
631+
| `POST /transfer-in` | Initiates an inbound transfer |
632+
| `POST /transfer-out` | Initiates an outbound transfer |
633+
634+
### How It Works
635+
636+
Clients include an `Idempotency-Key` header with a unique value (typically a UUID) on the request. The server uses this key to deduplicate requests:
637+
638+
- **First request**: Processes normally and stores the response keyed by the idempotency key.
639+
- **Subsequent requests with the same key (2xx or 4xx)**: Returns the stored response without reprocessing. The response status code and body will match the original response.
640+
- **Subsequent requests with the same key (5xx)**: Server errors are not stored — the request will be retried and processed again, allowing recovery from transient failures.
641+
- **Different key**: Treated as a new request.
642+
643+
```
644+
POST /quotes/{quoteId}/execute
645+
Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000
646+
```
647+
648+
### SDK Support
649+
650+
Our SDKs support idempotency keys via request options:
651+
652+
```typescript
653+
// TypeScript
654+
await client.quotes.execute('Quote:123', {
655+
idempotencyKey: '550e8400-e29b-41d4-a716-446655440000',
656+
});
657+
```
658+
659+
```kotlin
660+
// Kotlin
661+
client.quotes().execute("Quote:123", RequestOptions.builder()
662+
.idempotencyKey("550e8400-e29b-41d4-a716-446655440000")
663+
.build())
664+
```
665+
666+
### Design Guidelines
667+
668+
When adding a new endpoint that triggers money movement:
669+
670+
1. Document that the endpoint supports idempotency in the operation description
671+
2. Include the `Idempotency-Key` header in the OpenAPI spec parameters
672+
673+
---
674+
619675
## Stainless SDK Patterns
620676

621677
Our SDKs are generated by [Stainless](https://www.stainless.com/) from the OpenAPI spec.

openapi/paths/quotes/quotes.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ post:
2222
- Cross-Currency Transfers
2323
security:
2424
- BasicAuth: []
25+
parameters:
26+
- name: Idempotency-Key
27+
in: header
28+
required: false
29+
description: >
30+
A unique identifier for the request. If the same key is sent multiple times,
31+
the server will return the same response as the first request.
32+
schema:
33+
type: string
34+
example: <uuid>
2535
requestBody:
2636
required: true
2737
content:

openapi/paths/quotes/quotes_{quoteId}_execute.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ post:
2121
schema:
2222
type: string
2323
example: Quote:019542f5-b3e7-1d02-0000-000000000001
24+
- name: Idempotency-Key
25+
in: header
26+
required: false
27+
description: >
28+
A unique identifier for the request. If the same key is sent multiple times,
29+
the server will return the same response as the first request.
30+
schema:
31+
type: string
32+
example: <uuid>
2433
responses:
2534
'200':
2635
description: >

0 commit comments

Comments
 (0)