Post a cross-commodity exchange group atomically
Posts a cross-commodity exchange as one atomic group.
/v1/ledgers/{ledgerId}/exchangesPosts a cross-commodity exchange as one atomic group. Per-commodity zero-sum stays the invariant - the ledger never balances USD against IQD - so an exchange is two or more postings, each balanced in its own commodity, created together and linked by an exchange record that stores the rate as the exact fraction rate_num / rate_den it was struck at. Requires an Idempotency-Key. Because the stored rate describes a trade, the members are not individually reversible; a half-reversed exchange would leave the record describing something that no longer happened.
Authorization
bearerAuth In: header
Path Parameters
uuidHeader Parameters
Replays return the original response byte-identically within the retention window.
1 <= length <= 255Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/problem+json
curl -X POST "https://example.com/v1/ledgers/497f6eca-6276-4993-bfeb-53cbbbba6f08/exchanges" \ -H "Idempotency-Key: string" \ -H "Content-Type: application/json" \ -d '{ "type": "string", "from_commodity": "string", "to_commodity": "string", "rate_num": 1, "rate_den": 1, "postings": [ { "legs": [ { "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65", "direction": "credit", "amount": 1, "commodity": "string" }, { "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65", "direction": "credit", "amount": 1, "commodity": "string" } ] }, { "legs": [ { "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65", "direction": "credit", "amount": 1, "commodity": "string" }, { "account_id": "449e7a5c-69d3-4b8a-aaaf-5c9b713ebc65", "direction": "credit", "amount": 1, "commodity": "string" } ] } ] }'{ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", "from_commodity": "string", "to_commodity": "string", "rate_num": 0, "rate_den": 0, "txn_ids": [ "f6c4a82f-6b80-4863-aa86-516323128055" ], "created_at": "2019-08-24T14:15:22Z"}Cancel a reservation without postings
Cancels an active reservation and releases the funds, writing no entries at all: a voided pending leaves no trace in the books beyond its own record, because nothing ever moved.
Read one exchange with its transaction ids
Reads one exchange group: the commodities, the stored rate, and the ids of every transaction created with it.