API ReferenceExchange
Execute an exchange
POST /v1/exchange : convert currency using a quoted rate.
POST /v1/exchange
Headers
| Header | Required | Value |
|---|---|---|
Authorization | yes | Bearer sk_... |
Idempotency-Key | yes | unique per operation |
Content-Type | yes | application/json |
Body
| Field | Type | Required | Notes |
|---|---|---|---|
quote_id | string | yes | Quote ULID from /quotes |
Request
curl https://api.ouipay.com/v1/exchange \
-H "Authorization: Bearer sk_test_..." \
-H "Idempotency-Key: fx-001" \
-H "Content-Type: application/json" \
-d '{ "quote_id": "01M2S18..." }'What happens
- Debits the
fromwallet at the quoted rate - Credits the
towallet - Posts both legs to the ledger atomically: either both post or neither does
Response 201
The exchange transaction with both amounts recorded.
Errors
| HTTP | error.code | Cause |
|---|---|---|
| 400 | VALIDATION | Invalid or missing quote_id |
| 409 | CONFLICT | Quote expired: re-quote |
| 422 | INSUFFICIENT_FUNDS | Source wallet short |