Execute trade
const url = 'https://api.openfx.com/v1/brokerage/{orgId}/trade';
const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({quoteId: 'd8bc9618-2830-1822-9ae2-414aaf2b2de3'})
};
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"
payload = { "quoteId": "d8bc9618-2830-1822-9ae2-414aaf2b2de3" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"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")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"quoteId\": \"d8bc9618-2830-1822-9ae2-414aaf2b2de3\"\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");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Idempotency-Key: <idempotency-key>");
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 \"quoteId\": \"d8bc9618-2830-1822-9ae2-414aaf2b2de3\"\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"
payload := strings.NewReader("{\n \"quoteId\": \"d8bc9618-2830-1822-9ae2-414aaf2b2de3\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"quoteId": "d8bc9618-2830-1822-9ae2-414aaf2b2de3"
}
'{
"status": "success",
"data": {
"balances": {
"USD": -596064.969940321,
"USDC": -9893214.59296976,
"USDT": 8654884.42360652
},
"trade": {
"id": "2c011d8b-1822-4d1c-9b16-414aaf2b2de4",
"buy": "USD",
"sell": "USDC",
"referencedUnit": "USD",
"referencedAmount": 100,
"amount": 101,
"status": "EXECUTED",
"transactedAt": "2025-02-10T07:40:21.300Z",
"quoteId": "d8bc9618-2830-1822-9ae2-414aaf2b2de3"
},
"userCreditLimit": 10000000,
"userCreditUsed": 8844000.51844473
}
}{
"status": "error",
"message": "Query validation failed"
}{
"status": "error",
"message": "The authorization key provided is either invalid or expired, please try again"
}{
"status": "error",
"message": "Request with this idempotency key is currently processing",
"error": {
"code": "IDEMPOTENCY_IN_FLIGHT",
"details": "Please wait for the original request to complete"
}
}{
"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"
}Execute trade
Executes a currency exchange against a valid quote ID. Must be called within 3 seconds of quote generation.
POST
/
v1
/
brokerage
/
{orgId}
/
trade
Execute trade
const url = 'https://api.openfx.com/v1/brokerage/{orgId}/trade';
const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({quoteId: 'd8bc9618-2830-1822-9ae2-414aaf2b2de3'})
};
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"
payload = { "quoteId": "d8bc9618-2830-1822-9ae2-414aaf2b2de3" }
headers = {
"Idempotency-Key": "<idempotency-key>",
"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")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"quoteId\": \"d8bc9618-2830-1822-9ae2-414aaf2b2de3\"\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");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Idempotency-Key: <idempotency-key>");
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 \"quoteId\": \"d8bc9618-2830-1822-9ae2-414aaf2b2de3\"\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"
payload := strings.NewReader("{\n \"quoteId\": \"d8bc9618-2830-1822-9ae2-414aaf2b2de3\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
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 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"quoteId": "d8bc9618-2830-1822-9ae2-414aaf2b2de3"
}
'{
"status": "success",
"data": {
"balances": {
"USD": -596064.969940321,
"USDC": -9893214.59296976,
"USDT": 8654884.42360652
},
"trade": {
"id": "2c011d8b-1822-4d1c-9b16-414aaf2b2de4",
"buy": "USD",
"sell": "USDC",
"referencedUnit": "USD",
"referencedAmount": 100,
"amount": 101,
"status": "EXECUTED",
"transactedAt": "2025-02-10T07:40:21.300Z",
"quoteId": "d8bc9618-2830-1822-9ae2-414aaf2b2de3"
},
"userCreditLimit": 10000000,
"userCreditUsed": 8844000.51844473
}
}{
"status": "error",
"message": "Query validation failed"
}{
"status": "error",
"message": "The authorization key provided is either invalid or expired, please try again"
}{
"status": "error",
"message": "Request with this idempotency key is currently processing",
"error": {
"code": "IDEMPOTENCY_IN_FLIGHT",
"details": "Please wait for the original request to complete"
}
}{
"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.
- Execute currency exchanges
- Lock in quoted rates
- Convert between currencies
- Initiate settlement process
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 quote ID, missing fields, etc.) |
| 401 | The authorization key provided is either invalid or expired, please try again | Mint a fresh JWT — see Authentication |
| 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
Unique key to ensure idempotent requests. UUID v4 recommended. Valid for 24 hours.
Example:
"123e4567-e89b-12d3-a456-426614174000"
Path Parameters
Body
application/json
Example:
"d8bc9618-2830-1822-9ae2-414aaf2b2de3"
⌘I