Skip to content

Commit b5b7078

Browse files
committed
fix:adding idempotency to readme
1 parent e7b9bf6 commit b5b7078

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

openapi/README.md

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

568568
---
569569

570+
## Idempotency
571+
572+
Any API endpoint that triggers money movement **must** support idempotency to prevent duplicate transactions caused by retries, network failures, or client timeouts.
573+
574+
We follow the [IETF Idempotency-Key HTTP Header Field](https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/) specification.
575+
576+
### Endpoints Requiring Idempotency
577+
578+
| Endpoint | Description |
579+
|----------|-------------|
580+
| `POST /quotes` (with `immediatelyExecute: true`) | Creates and executes a quote in one step |
581+
| `POST /quotes/{quoteId}/execute` | Executes a previously created quote |
582+
| `POST /transfer-in` | Initiates an inbound transfer |
583+
| `POST /transfer-out` | Initiates an outbound transfer |
584+
585+
### How It Works
586+
587+
Clients include an `Idempotency-Key` header with a unique value (typically a UUID) on the request. The server uses this key to deduplicate requests:
588+
589+
- **First request**: Processes normally and stores the response keyed by the idempotency key.
590+
- **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.
591+
- **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.
592+
- **Different key**: Treated as a new request.
593+
594+
```
595+
POST /quotes/{quoteId}/execute
596+
Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000
597+
```
598+
599+
### SDK Support
600+
601+
Our SDKs support idempotency keys via request options:
602+
603+
```typescript
604+
// TypeScript
605+
await client.quotes.execute('Quote:123', {
606+
idempotencyKey: '550e8400-e29b-41d4-a716-446655440000',
607+
});
608+
```
609+
610+
```kotlin
611+
// Kotlin
612+
client.quotes().execute("Quote:123", RequestOptions.builder()
613+
.idempotencyKey("550e8400-e29b-41d4-a716-446655440000")
614+
.build())
615+
```
616+
617+
### Design Guidelines
618+
619+
When adding a new endpoint that triggers money movement:
620+
621+
1. Document that the endpoint supports idempotency in the operation description
622+
2. Include the `Idempotency-Key` header in the OpenAPI spec parameters
623+
624+
---
625+
570626
## Stainless SDK Patterns
571627

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

0 commit comments

Comments
 (0)