Reverse a trade
const url = 'https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tradeId: '123e4567-e89b-42d3-a456-426614174000',
quoteId: '223e4567-e89b-42d3-a456-426614174000',
clientReferenceId: 'customer-reversal-20260713-001'
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));import requests
url = "https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse"
payload = {
"tradeId": "123e4567-e89b-42d3-a456-426614174000",
"quoteId": "223e4567-e89b-42d3-a456-426614174000",
"clientReferenceId": "customer-reversal-20260713-001"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"tradeId\": \"123e4567-e89b-42d3-a456-426614174000\",\n \"quoteId\": \"223e4567-e89b-42d3-a456-426614174000\",\n \"clientReferenceId\": \"customer-reversal-20260713-001\"\n}")
.asString();CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"tradeId\": \"123e4567-e89b-42d3-a456-426614174000\",\n \"quoteId\": \"223e4567-e89b-42d3-a456-426614174000\",\n \"clientReferenceId\": \"customer-reversal-20260713-001\"\n}");
CURLcode ret = curl_easy_perform(hnd);package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse"
payload := strings.NewReader("{\n \"tradeId\": \"123e4567-e89b-42d3-a456-426614174000\",\n \"quoteId\": \"223e4567-e89b-42d3-a456-426614174000\",\n \"clientReferenceId\": \"customer-reversal-20260713-001\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}curl --request POST \
--url https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tradeId": "123e4567-e89b-42d3-a456-426614174000",
"quoteId": "223e4567-e89b-42d3-a456-426614174000",
"clientReferenceId": "customer-reversal-20260713-001"
}
'{
"status": "success",
"message": "Trade reversed successfully",
"data": {
"trade": {
"id": "423e4567-e89b-42d3-a456-426614174000",
"buy": "USD",
"sell": "USDC",
"referencedUnit": "USD",
"referencedAmount": 1000,
"amount": 999.25,
"status": "REVERSED",
"transactedAt": "2026-07-13T10:00:00.000Z",
"quoteId": "223e4567-e89b-42d3-a456-426614174000",
"clientReferenceId": "customer-reversal-20260713-001",
"originalTradeId": "123e4567-e89b-42d3-a456-426614174000"
},
"reversalDetails": {
"direction": "CREDIT",
"differentialAmount": 0.75,
"currency": "USD"
}
}
}{
"status": "error",
"message": "Query validation failed"
}{
"status": "error",
"message": "The authorization key provided is either invalid or expired, please try again"
}{
"status": "error",
"message": "Trade not found",
"error": {
"code": "TRADE_NOT_FOUND"
}
}{
"status": "error",
"message": "The trade cannot be reversed",
"error": {
"code": "TRADE_NOT_REVERSIBLE"
}
}{
"status": "error",
"message": "Idempotency key reused with different parameters",
"error": {
"code": "IDEMPOTENCY_MISMATCH",
"details": "This idempotency key was already used with different request parameters"
}
}{
"status": "error",
"message": "An internal error has occurred"
}Reverse a trade
Reverses an existing trade using an approved reverse quote.
POST
/
v1
/
brokerage
/
{orgId}
/
trade
/
reverse
Reverse a trade
const url = 'https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse';
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tradeId: '123e4567-e89b-42d3-a456-426614174000',
quoteId: '223e4567-e89b-42d3-a456-426614174000',
clientReferenceId: 'customer-reversal-20260713-001'
})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));import requests
url = "https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse"
payload = {
"tradeId": "123e4567-e89b-42d3-a456-426614174000",
"quoteId": "223e4567-e89b-42d3-a456-426614174000",
"clientReferenceId": "customer-reversal-20260713-001"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"tradeId\": \"123e4567-e89b-42d3-a456-426614174000\",\n \"quoteId\": \"223e4567-e89b-42d3-a456-426614174000\",\n \"clientReferenceId\": \"customer-reversal-20260713-001\"\n}")
.asString();CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer <token>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"tradeId\": \"123e4567-e89b-42d3-a456-426614174000\",\n \"quoteId\": \"223e4567-e89b-42d3-a456-426614174000\",\n \"clientReferenceId\": \"customer-reversal-20260713-001\"\n}");
CURLcode ret = curl_easy_perform(hnd);package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse"
payload := strings.NewReader("{\n \"tradeId\": \"123e4567-e89b-42d3-a456-426614174000\",\n \"quoteId\": \"223e4567-e89b-42d3-a456-426614174000\",\n \"clientReferenceId\": \"customer-reversal-20260713-001\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}curl --request POST \
--url https://api.openfx.com/v1/brokerage/{orgId}/trade/reverse \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"tradeId": "123e4567-e89b-42d3-a456-426614174000",
"quoteId": "223e4567-e89b-42d3-a456-426614174000",
"clientReferenceId": "customer-reversal-20260713-001"
}
'{
"status": "success",
"message": "Trade reversed successfully",
"data": {
"trade": {
"id": "423e4567-e89b-42d3-a456-426614174000",
"buy": "USD",
"sell": "USDC",
"referencedUnit": "USD",
"referencedAmount": 1000,
"amount": 999.25,
"status": "REVERSED",
"transactedAt": "2026-07-13T10:00:00.000Z",
"quoteId": "223e4567-e89b-42d3-a456-426614174000",
"clientReferenceId": "customer-reversal-20260713-001",
"originalTradeId": "123e4567-e89b-42d3-a456-426614174000"
},
"reversalDetails": {
"direction": "CREDIT",
"differentialAmount": 0.75,
"currency": "USD"
}
}
}{
"status": "error",
"message": "Query validation failed"
}{
"status": "error",
"message": "The authorization key provided is either invalid or expired, please try again"
}{
"status": "error",
"message": "Trade not found",
"error": {
"code": "TRADE_NOT_FOUND"
}
}{
"status": "error",
"message": "The trade cannot be reversed",
"error": {
"code": "TRADE_NOT_REVERSIBLE"
}
}{
"status": "error",
"message": "Idempotency key reused with different parameters",
"error": {
"code": "IDEMPOTENCY_MISMATCH",
"details": "This idempotency key was already used with different request parameters"
}
}{
"status": "error",
"message": "An internal error has occurred"
}v1 sunsets December 31, 2026. Migrate to v2 — see the migration guide.
- Unwind a trade executed in error
- Refund a customer at the quoted reversal rate
- Correct a duplicate or mis-keyed execution
Idempotency is supported on v2 and v3 for this endpoint. v1 does not support idempotency keys — see Migration guide.
Errors
| Status | Message | Notes |
|---|---|---|
| 400 | Query validation failed | Request didn’t match schema (bad trade ID, bad quote ID, missing fields, etc.) |
| 401 | The authorization key provided is either invalid or expired, please try again | Mint a fresh JWT — see Authentication |
| 404 | Trade not found | tradeId or quoteId doesn’t resolve to a record on this org |
| 409 | The trade cannot be reversed | The trade is outside its reversal window or already reversed/settled |
| 500 | An internal error has occurred | Server fault. Writes are non-idempotent in v1 — fetch the trade by ID before retrying to avoid double-execution |
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
V2 only. Unique key for an idempotent reverse trade request. Valid for 24 hours.
Example:
"523e4567-e89b-42d3-a456-426614174000"
Path Parameters
Body
application/json
Unique identifier of the trade being reversed
Example:
"123e4567-e89b-42d3-a456-426614174000"
Unique identifier of the approved reverse quote
Example:
"223e4567-e89b-42d3-a456-426614174000"
Optional client-supplied reference for the reversed trade
Example:
"customer-reversal-20260713-001"
⌘I