Set Custom Conversion Rate

Important Notes:

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

Name
Type
Example
Description

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.

When using the API, ensure to include your API Key and generate the signature for the request payload using your API Secret. The tables provided above contain example values for illustration purposes only. Please refer to the code snippets for detailed instructions on how to sign the request and generate the signature properly.

Request Body

Field Name

Type

Description

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 = 0 if your rate means: 1 unit of fromCurrencySymbol = N units of toCurrencySymbol (e.g., 1 BRL = 0.20 USDT)

  • Set isReciprocal = 1 if your rate means: 1 unit of toCurrencySymbol = N units of fromCurrencySymbol (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 = {
    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 requests

Response

{
    "data": {},
    "errorCode": 0,
    "msg": "Rate inserted successfully"
}

Last updated