Set Custom Conversion Rate
Important Notes:
The Custom Conversion Rate feature is restricted and must be explicitly enabled by an administrator. Only merchants with prior approval will be able to set custom crypto-to-fiat conversion rates.
If you wish to use this feature, please contact customer support or your account administrator to request access.
This endpoint allows a merchant to configure a custom exchange rate between a cryptocurrency (e.g., USDT) and a fiat currency (e.g., Brazilian Real).
For example, if your products or services are priced in Brazilian Real (BRL), but you want your customers to pay in USDT, you can define the conversion rate manually. By doing so, you control how many USDT the customer must pay for a given BRL-denominated price, instead of relying on live market rates.
This is particularly useful in the following scenarios:
You want to apply a fixed or preferential rate for your customers.
You operate in markets with volatile exchange rates.
You wish to include your own markup or discount within the rate.
Once set, this custom rate will be used during the checkout or payment process for conversions from BRL to USDT.
Endpoint
POSThttps://api.tylt.money/transactions/merchant/setRate
Request Headers
X-TLP-APIKEY
string
93ee3c5e133697251b5362bcf9cc8532476785t8768075616f58d88
Your Tylt API Key, used to identify your account in API requests.
X-TLP-SIGNATURE
string
d0afef3853dfc8489c8b9affa5825171fdd7y7685675e4966a05f66ed2b3eaf9462b3c9c0
HMAC SHA-256 signature generated using the API Secret Key to secure the request.
Request Body
Field Name
Type
Description
transactionType
string
Represents the type of transaction for which the custom rate should be applied (e.g., "payin" or "payout"). Note: If not specified, the default value is "payin".
fromCurrencySymbol
string
Represents the symbol/code of the fiat currency (e.g., "BRL", "INR", "USD"). Note: fromCurrencySymbol must belong to a fiat currency
toCurrencySymbol
number
Represents the symbol/code of the crypto currency (e.g., "USDT", "USDC", "DAI"). Note: toCurrencySymbol must belong to a crypto currency
rate
number
The custom conversion rate.
isReciprocal
number
Determines the direction of the exchange rate you are providing.
Set
isReciprocal = 0if your rate means: 1 unit offromCurrencySymbol= N units oftoCurrencySymbol(e.g., 1 BRL = 0.20 USDT)Set
isReciprocal = 1if your rate means: 1 unit oftoCurrencySymbol= N units offromCurrencySymbol(e.g., 1 USDT = 5 BRL)
This flag ensures clarity on whether the rate is expressed in a direct or inverse form.
Code Snippet
import axios from "axios";
import crypto from "crypto";
const apiKey = "your-api-key";
const apiSecret = "your-api-secret";
const data = {
transactionType: "payin",
fromCurrencySymbol: "INR", // compulsory
toCurrencySymbol: "USDT", // compulsory
rate: 90.50, // compulsory
isReceiprocal: 1
};
/*
fromCurrencySymbol and toCurrencySymbol are compulsory
rate is compulsory
fromCurrencySymbol can only be of currenctType 'fiat'
toCurrencySymbol can only be of currenctType 'crypto'
currencyType of a currency can be checked here -
https://docs.tylt.money/tylt-cpg-crypto-payment-gateway/api-reference/supporting-apis/supported-base-currency-list
For your reference -
fromCurrencySymbol can be 'INR' and other fiat currencies
toCurrencySymbol can be 'USDT' and other crypto currencies
*/
const signaturePayload = JSON.stringify(data);
const signature = crypto
.createHmac("sha256", apiSecret)
.update(signaturePayload)
.digest("hex");
const url = `https://api.tylt.money/transactions/merchant/setRate`;
const config = {
method: "post",
url: url,
headers: {
"X-TLP-APIKEY": apiKey,
"X-TLP-SIGNATURE": signature,
},
data: data,
};
axios
.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.error(error);
});import requestsimport requests
import hmac
import hashlib
import json
# Replace with your API Key and Secret
api_key = 'your-api-key'
api_secret = 'your-api-secret'
# Request body (all fields are compulsory)
body = {
"transactionType": "payin",
"fromCurrencySymbol": "INR", # fiat
"toCurrencySymbol": "USDT", # crypto
"rate": 90.50,
"isReceiprocal": 1
}
# Prepare body for signature
body_string = json.dumps(body, separators=(',', ':'), ensure_ascii=False)
# Create the HMAC SHA-256 signature
signature = hmac.new(api_secret.encode(), body_string.encode(), hashlib.sha256).hexdigest()
# Define headers
headers = {
"X-TLP-APIKEY": api_key,
"X-TLP-SIGNATURE": signature,
"Content-Type": "application/json"
}
# Send the POST request
response = requests.post("https://api.tylt.money/transactions/merchant/setRate", headers=headers, data=body_string)
# Print the response
if response.status_code == 200:
print("Response:", response.json())
else:
print(f"Failed with status code {response.status_code}: {response.text}")
const fetch = require('node-fetch');
const crypto = require('crypto');
// Replace with your API Key and Secret
const apiKey = 'your-api-key';
const apiSecret = 'your-api-secret';
// Request body for setting the rate
const requestBody = {
transactionType: "payin",
fromCurrencySymbol: 'INR', // fiat
toCurrencySymbol: 'USDT', // crypto
rate: 90.50,
isReceiprocal: 1
};
// Convert request body to JSON
const raw = JSON.stringify(requestBody);
// Function to create HMAC SHA-256 signature
const createSignature = (secret, data) => {
return crypto.createHmac('sha256', secret)
.update(data)
.digest('hex');
};
// Generate signature
const signature = createSignature(apiSecret, raw);
// Define headers
const headers = {
"Content-Type": "application/json",
"X-TLP-APIKEY": apiKey,
"X-TLP-SIGNATURE": signature
};
// Function to send the request
const sendRequest = async (url, headers, body) => {
const response = await fetch(url, {
method: 'POST',
headers: headers,
body: body,
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP ${response.status}: ${errorText}`);
}
return response.json();
};
// Send the request
sendRequest('https://api.tylt.money/transactions/merchant/setRate', headers, raw)
.then(result => console.log("Success:", result))
.catch(error => console.error("Error:", error));
Response
{
"data": {},
"errorCode": 0,
"msg": "Rate inserted successfully"
}Last updated