Cancel a trade
http
POST /api/trades/:id/cancelUser · buyer only
Refunds the escrow to the seller.
Preconditions
- Trade is
ESCROW_LOCKED(not yet marked paid)
Sequence
- Claim
→ REFUNDING. - Submit the refund transaction (remove signer, merge to seller).
→ CANCELLEDwithrefundTxHash,cancelReason: "BUYER_CANCELLED"; writeESCROW_REFUNDledger entry and system message.- Reactivate the order if it hasn't expired (broadcasts
order:created).
Response 200
Updated trade details with links.refund.
Errors
| Status | Code | Cause |
|---|---|---|
| 403 | FORBIDDEN | Not the buyer |
| 409 | CONFLICT | Already paid, finished, or concurrent change |
| 502 | STELLAR_TX_FAILED | Rejected; status restored |
| 503 | HORIZON_UNAVAILABLE | Outcome unknown; reconciled automatically |