FX Status Change Webhook
Overview
The FX_STATUS_CHANGE webhook is triggered when a foreign exchange trade order updates its execution state (such as transitioning from Pending or Scheduled to Completed or Expired).
Webhook Delivery
- HTTP Method:
POST - Destination: Your configured server webhook endpoint
- Content-Type:
application/json
Webhook Headers
| Header | Value | Description |
|---|---|---|
Content-Type | application/json | Request body media type |
x-webhook-event | FX_STATUS_CHANGE | Identifier of the dispatched event type |
x-webhook-timestamp | ISO 8601 string | Timestamp when the event was dispatched |
Event Payload
{
"fxOrderId": "fx_983745",
"oldStatus": "Pending",
"newStatus": "Completed",
"updatedAt": "2025-03-21T11:00:00Z"
}
Payload Fields
| Field | Type | Required | Description |
|---|---|---|---|
fxOrderId | string | Yes | Unique identifier for the foreign exchange order. |
oldStatus | string | Yes | The preceding status of the FX order (e.g. Pending, Scheduled). |
newStatus | string | Yes | The updated status of the FX order (e.g. Completed, Failed, Expired). |
updatedAt | string (ISO Date) | Yes | UTC timestamp when the state transition occurred. |
Expected Server Response
Return an HTTP 200 OK status to acknowledge receipt:
{
"received": true
}
Implementation Examples
Node.js (Express)
const express = require('express');
const app = express();
app.use(express.json());
app.post('/webhook', (req, res) => {
const eventType = req.headers['x-webhook-event'];
const { fxOrderId, oldStatus, newStatus, updatedAt } = req.body;
if (eventType === 'FX_STATUS_CHANGE') {
console.log(`FX Order ${fxOrderId} changed from ${oldStatus} to ${newStatus} at ${updatedAt}`);
// Handle settlement or notify client
}
res.status(200).json({ received: true });
});
app.listen(3000, () => console.log('FX Webhook listener running on port 3000'));
Python (Flask)
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/webhook', methods=['POST'])
def handle_webhook():
event_type = request.headers.get('x-webhook-event')
data = request.json or {}
if event_type == 'FX_STATUS_CHANGE':
fx_order_id = data.get('fxOrderId')
old_status = data.get('oldStatus')
new_status = data.get('newStatus')
updated_at = data.get('updatedAt')
print(f"FX Order {fx_order_id} is now {new_status} (previously {old_status}) at {updated_at}")
return jsonify({"received": True}), 200
if __name__ == '__main__':
app.run(port=3000)