Skip to main content

Create an FX Trade (Legacy)

Overview

This service is used to convert money between different currencies within wallets. You must include the vfx_token obtained from the Get FX Rate endpoint within its 30-second validity window. Specify side as SELL or BUY as well as the transaction amount.

Resource Access

  • HTTP Method: POST
  • Endpoint: /orders/v2.1/fx
  • Authentication: Bearer token required

Request Headers

HeaderValueRequiredDescription
Acceptapplication/jsonYesContent type for the response
AuthorizationBearer {access_token}YesBearer token for authentication
Content-Typeapplication/jsonYesRequest body content type
x-api-keystringNoAPI key for additional authentication

Request Body

{
"vfx_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjdXJyZW5jeUZyb20iOiJVU0QiLCJjdXJyZW5jeVRvIjoiTkdOIiwiY29tcGFueUlkIjoiNTI1IiwicmF0ZSI6NTcxLjQ4ODM4MTI1LCJzcHJlYWQiOjkuNjYxNjE4NzUsImlhdCI6MTcyMTAzODkwMiwiZXhwIjoxNzIxMDM4OTMyfQ.pI2LSZ8ulaWVuxqGVRe_ORv8yyXepx771glEVFcIluo",
"side": "SELL",
"amount": 100,
"clientReference": "Test 100"
}

Request Fields

FieldTypeRequiredDescription
vfx_tokenstringYesToken returned by the Get FX Rate API. Valid for 30 seconds.
sidestringYesSELL to sell source currency, or BUY to purchase fixed target currency.
amountnumberYesThe amount to BUY or SELL.
clientReferencestringNoCustom tracking reference (max 35 alphanumeric characters).

Response

Success Response (200 OK)

{
"success": true,
"order": {
"id": 3009,
"reference": "EN-15072024-002",
"amountFrom": 100,
"amountTo": 57148.84,
"rate": "571.4883812500",
"transactionState": "inward_remittance_confirmed",
"status": "deposit_recorded",
"clientReference": "Test100",
"currencyFrom": "USD",
"currencyTo": "NGN"
}
}

Response Fields

FieldTypeDescription
successbooleanIndicates whether the trade order creation was successful.
order.idnumberUnique identifier for the FX trade order.
order.referencestringInternal transaction reference number.
order.amountFromnumberSource amount debited.
order.amountTonumberTarget amount credited.
order.ratestringExecuted exchange rate.
order.transactionStatestringState of the remittance (e.g. inward_remittance_confirmed).
order.statusstringCurrent status of deposit/order (e.g. deposit_recorded).
order.clientReferencestringClient reference provided in the request.
order.currencyFromstringSource currency code.
order.currencyTostringTarget currency code.

Error Responses

  • 400 Bad Request: Invalid parameters or malformed request
  • 401 Unauthorized: Missing or invalid Bearer authentication token
  • 403 Forbidden: Insufficient account permissions
  • 404 Not Found: Resource not found
  • 500 Internal Server Error: An internal server error occurred

Code Examples

Base URL

Production: https://api.ahrvo.network
Staging: https://gateway.ahrvo.network

cURL

curl -X POST \
'https://gateway.ahrvo.network/banking/ibans/v2/orders/v2.1/fx' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"vfx_token": "YOUR_VFX_TOKEN",
"side": "SELL",
"amount": 100,
"clientReference": "Test 100"
}'

Python

import requests

url = "https://gateway.ahrvo.network/banking/ibans/v2/orders/v2.1/fx"
headers = {
"Accept": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
}
payload = {
"vfx_token": "YOUR_VFX_TOKEN",
"side": "SELL",
"amount": 100,
"clientReference": "Test 100"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())

JavaScript (Node.js)

const axios = require('axios');

const url = 'https://gateway.ahrvo.network/banking/ibans/v2/orders/v2.1/fx';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
};
const data = {
vfx_token: 'YOUR_VFX_TOKEN',
side: 'SELL',
amount: 100,
clientReference: 'Test 100'
};

axios.post(url, data, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error.response ? error.response.data : error.message));

Usage Notes

  • If side is BUY, amount specifies the fixed units of target currency to receive.
  • If side is SELL, amount specifies the fixed units of source currency to exchange.
  • Store order.id and order.reference to query status via Get FX Trade.

Interactive API Explorer