Skip to main content

Create External Withdrawal Request

This endpoint allows the customer to withdraw cryptocurrencies to an external wallet.


Endpoint​

  • Method: POST
Endpoint URL
https://api.xgateglobal.com/withdraw

Test Integration​

Use the form below to simulate the creation of a crypto withdrawal request to an external wallet.

🔐

Withdraw to External Wallet

1. Your Credentials

2. Customer Identification
Don't have a client? Click here to create.

3. Withdrawal Data

Request​

You must send the authentication Header and the Body with the order data.

Required Headers​

HeaderValueDescription
AuthorizationBearer <your_token>The JWT token obtained from login.

Body (Request Body)​

FieldTypeRequiredDescription
amountnumberYesThe withdrawal amount in USDT (e.g., 0.1 min).
customerIdstringYesThe unique ID (_id) of the customer making the withdrawal.
cryptocurrencyobjectYesThe cryptocurrency of the transaction (e.g., USDT).
blockchainNetworkobjectYesInformation about the blockchain network.
walletstringYesThe wallet to which the values will be sent.
externalIdstringNoIdempotency.

Responses​

Success (201 Created)​

Returns the created order object, containing information about the status and the _id of the transaction.

{
"message": "Solicitação de Saque realizada com sucesso",
"status": "PENDING",
"_id": "69849e8c50****************"
}

Common Errors​

StatusMessageLikely Reason
401Unauthorized• Invalid or expired token.
• Invalid or missing Header.
• IP not allowed.
404Not FoundCustomer informed in the customerId field does not exist.
500Internal Server ErrorInternal server error. Contact support.

How to Use​

The purpose of this endpoint is to initiate the money outflow flow with Crypto to BRL conversion (Cash-out).

The Integration Flow​

  1. Identify the Customer: Make sure the user exists in XGate (POST /customer) and have their _id.
  2. Cryptocurrency Data: You will need to fetch cryptocurrency data to add to the request. You can obtain it from Cryptocurrencies.
  3. Network Data: You will need to fetch the network data, you can obtain it from Blockchain Networks.
  4. Destination: Add the public key of the wallet that will receive the withdrawal to the external wallet.
  5. Send the request: Send the request to XGate. The approval time may vary depending on the network.

Practical Example​

To create withdrawal requests to external wallets, you must follow these 4 steps:

Recommendation

It is necessary to create a customer before proceeding with the withdrawal creation.

You can be clicking here to go to the customer creation documentation page.

Step 1: Enter the amount in USDT in amount and the customer's _id as customerId, just like in the highlighted fields:

{
"amount": 2,
"customerId": "672f40**************",
"cryptocurrency": {
"_id": "6733a2a900**************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether"
},
"blockchainNetwork": {
"_id": "69ea849098**************",
"chain": "Solana",
"name": "Solana",
"symbol": "SOL"
},
"wallet": "0x7A00e4a***************",
"externalId": "6dd37763a2***************"
}

Step 2: You must obtain the cryptocurrency with the data for the withdrawal.

You can obtain the list of them by clicking here.

{
"amount": 2,
"customerId": "672f40**************",
"cryptocurrency": {
"_id": "6733a2a900**************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether"
},
"blockchainNetwork": {
"_id": "69ea849098**************",
"chain": "Solana",
"name": "Solana",
"symbol": "SOL"
},
"wallet": "0x7A00e4a***************",
"externalId": "6dd37763a2***************"
}
Cryptocurrency

The cryptocurrency data can also be retrieved from the response coming from the blockchain network listing. The integration example in Node.Js shows how it works.

Object Details​

See the details of each information in the cryptocurrency object to build your request.

FieldTypeRequiredDescription
_idstringYesUnique identifier of the cryptocurrency.
namestringYesName of the cryptocurrency.
symbolstringYesSymbol of the cryptocurrency.
coinGeckostringNoCryptocurrency identifier on CoinGecko.
updatedDatestringNoDate of last update of cryptocurrency information.
createdDatestringNoDate when the cryptocurrency was created in the system.
__vnumberNoVersion of the cryptocurrency record in the database.

Step 3: You must obtain the blockchain network data.

You can obtain the list of them by clicking here.

{
"amount": 2,
"customerId": "672f40**************",
"cryptocurrency": {
"_id": "6733a2a900**************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether"
},
"blockchainNetwork": {
"_id": "69ea849098**************",
"chain": "Solana",
"name": "Solana",
"symbol": "SOL"
},
"wallet": "0x7A00e4a***************",
"externalId": "6dd37763a2***************"
}
Recommendation

If your integration uses a fixed network for all withdrawal operations, we recommend sending the required values via hard-code. This optimizes your application's performance, avoiding repetitive calls to the network listing endpoint, which has a high data volume.

Object Details​

See the details of each information in the blockchainNetwork object to build your request.

FieldTypeRequiredDescription
_idstringYesUnique identifier of the blockchain network in the system.
namestringYesTechnical name of the network standard (e.g., TRC-20, ERC-20).
chainIdstringYesNumeric ID of the network (e.g., 56 for BSC, 1 for Ethereum).
cryptocurrenciesarrayNoList of IDs of cryptocurrencies supported on this network.
updatedDatestringNoDate of last update of network parameters.
createdDatestringNoDate of creation of the network record in the system.
__vnumberNoInternal version of the record in the database.
chainstringYesSimplified name of the blockchain (e.g., BSC, ETH).
symbolstringYesSymbol of the native currency of the network (e.g., BNB, ETH).

Step 4: You must obtain the public key of the wallet where the withdrawal values will be sent.

{
"amount": 2,
"customerId": "672f40**************",
"cryptocurrency": {
"_id": "6733a2a900**************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether"
},
"blockchainNetwork": {
"_id": "69ea849098**************",
"chain": "Solana",
"name": "Solana",
"symbol": "SOL"
},
"wallet": "0x7A00e4a***************",
"externalId": "6dd37763a2***************"
}

Step 5 (Optional): Add the externalId at the end of the code. It will prevent the client from sending the withdrawal request more than once, avoiding duplication.

{
"amount": 2,
"customerId": "672f40**************",
"cryptocurrency": {
"_id": "6733a2a900**************",
"name": "USDT",
"symbol": "USDT",
"coinGecko": "tether"
},
"blockchainNetwork": {
"_id": "69ea849098**************",
"chain": "Solana",
"name": "Solana",
"symbol": "SOL"
},
"wallet": "0x7A00e4a***************",
"externalId": "6dd37763a2***************"
}

Integration​

This integration example uses the Axios library in Node.js.

Installing Axios:

npm install axios

JavaScript Example:

const axios = require("axios");

(async () => {
const email = "your_email@domain.com";
const password = "**********";
const amount = 10.90;
const wallet = "0x*****************";
const customerId = "**************";

try {
const url_api = "https://api.xgateglobal.com"
const login = await axios.post(`${url_api}/auth/token`, { email, password });
const blockchains = await axios.get(`${url_api}//withdraw/company/blockchain-networks`, {
headers: {
"Authorization": `Bearer ${login.data.token}`
}
});
const { data } = await axios.post(`${url_api}/withdraw`, {
amount,
wallet,
customerId,
cryptocurrency: blockchains.data[0].cryptocurrencies[1].cryptocurrency, // USDT
blockchainNetwork: blockchains.data[0],
}, {
headers: {
"Authorization": `Bearer ${login.data.token}`
}
});
console.log(data); // Response
} catch (error) {
console.log(error.response.data.message) // Error
}
})()