Funds Withdrawal
The method allows you to create a withdrawal request by sending a POST request.
Last updated
Was this helpful?
Was this helpful?
curl -X POST \
https://api.trybit.com/v2/invoice/api/out/create \
-H 'Authorization: Token YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"currency_code": "BTC",
"to_address": "YOUR_RECIPIENT_ADDRESS",
"amount": 0.00023
}'import requests
from typing import Optional
class PayoutAPIClient:
def __init__(self, api_key: str):
self.api_key = api_key
self.base_url = 'https://api.trybit.com'
self.headers = {
'Authorization': f'Token {self.api_key}',
'Content-Type': 'application/json'
}
def create_payout(self, currency_code: str, to_address: str, amount: float) -> dict:
"""
Creates a withdrawal request.
:param currency_code: Currency code (e.g. “BTC”, “ETH”, “USDT”, “LTC”).
:param to_address: Recipient's address.
:param amount: Amount to send.
:return: API response in dict format.
"""
url = f"{self.base_url}/v2/invoice/api/out/create"
payload = {
"currency_code": currency_code,
"to_address": to_address,
"amount": amount
}
response = requests.post(url, json=payload, headers=self.headers)
if response.status_code == 200:
return response.json()
else:
raise PayoutAPIError(response.status_code, response.json())
class PayoutAPIError(Exception):
def __init__(self, status_code: int, error_data: Optional[dict] = None):
self.status_code = status_code
self.error_data = error_data or {}
message = f"API Request failed with status {status_code}: {self.error_data}"
super().__init__(message)
# Example of use:
if __name__ == "__main__":
# Client Configuration
api_key = ""
client = PayoutAPIClient(api_key)
try:
result = client.create_payout(
currency_code="BTC",
to_address="",
amount=0.00023
)
print("Success:", result)
except PayoutAPIError as e:
print("Error occurred:", e)/**
* Custom error for handling payout API response failures.
*/
class PayoutAPIError extends Error {
/**
* @param {number} statusCode - HTTP status code returned by the API.
* @param {object} [errorData={}] - Error details returned by the API.
*/
constructor(statusCode, errorData = {}) {
super(`API Request failed with status ${statusCode}: ${JSON.stringify(errorData)}`);
this.name = 'PayoutAPIError';
this.statusCode = statusCode;
this.errorData = errorData;
}
}
/**
* Client for interacting with Trybit Payout API.
*/
class PayoutAPIClient {
/**
* @param {string} apiKey - API token used for authentication.
*/
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://api.trybit.com';
this.headers = {
'Authorization': `Token ${this.apiKey}`,
'Content-Type': 'application/json'
};
}
/**
* Creates a payout request.
*
* @param {string} currencyCode - Currency code (e.g., "BTC", "ETH", "USDT", "LTC").
* @param {string} toAddress - Recipient address.
* @param {number} amount - Amount to send.
* @returns {Promise<object>} - API response data.
* @throws {PayoutAPIError} - On failed request.
*/
async createPayout(currencyCode, toAddress, amount) {
const url = `${this.baseUrl}/v2/invoice/api/out/create`;
const payload = {
currency_code: currencyCode,
to_address: toAddress,
amount: amount
};
try {
const response = await axios.post(url, payload, {
headers: this.headers
});
return response.data;
} catch (error) {
const status = error.response?.status || 500;
const data = error.response?.data || {};
throw new PayoutAPIError(status, data);
}
}
}
// Example usage with Axios
(async () => {
const client = new PayoutAPIClient('<your_api_key_here>');
try {
const result = await client.createPayout("BTC", "<recipient_address>", 0.00023);
console.log("Success:", result);
} catch (error) {
console.error("Error occurred:", error);
}
})();const apiKey = '<your_api_key>';
const payload = {
currency_code: 'BTC',
to_address: '<recipient_address>',
amount: 0.00023
};
fetch('https://api.trybit.com/v2/invoice/api/out/create', {
method: 'POST',
headers: {
'Authorization': `Token ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then(response => {
if (!response.ok) throw new Error(`HTTP error ${response.status}`);
return response.json();
})
.then(data => console.log('Success:', data))
.catch(err => console.error('Error:', err));const apiKey = '<your_api_key>';
const xhr = new XMLHttpRequest();
xhr.open("POST", "https://api.trybit.com/v2/invoice/api/out/create");
xhr.setRequestHeader("Authorization", `Token ${apiKey}`);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function () {
if (xhr.status === 200) {
console.log("Success:", JSON.parse(xhr.responseText));
} else {
console.error("Error:", xhr.status, xhr.responseText);
}
};
const payload = {
currency_code: 'BTC',
to_address: '<recipient_address>',
amount: 0.00023
};
xhr.send(JSON.stringify(payload));<?php
/**
* Class PayoutAPIError
*
* Custom exception for API errors.
*/
class PayoutAPIError extends Exception
{
public int $statusCode;
public array $errorData;
/**
* PayoutAPIError constructor.
*
* @param int $statusCode
* @param array $errorData
*/
public function __construct(int $statusCode, array $errorData = [])
{
$this->statusCode = $statusCode;
$this->errorData = $errorData;
$message = "API Request failed with status $statusCode: " . json_encode($errorData);
parent::__construct($message, $statusCode);
}
}
/**
* Class PayoutAPIClient
*
* Client for creating crypto payouts via Trybit API.
*/
class PayoutAPIClient
{
private string $apiKey;
private string $baseUrl;
private array $headers;
/**
* PayoutAPIClient constructor.
*
* @param string $apiKey
*/
public function __construct(string $apiKey)
{
$this->apiKey = $apiKey;
$this->baseUrl = 'https://api.trybit.com';
$this->headers = [
'Authorization: Token ' . $this->apiKey,
'Content-Type: application/json'
];
}
/**
* Create payout request.
*
* @param string $currencyCode Currency code (e.g., BTC, ETH).
* @param string $toAddress Recipient address.
* @param float $amount Amount to send.
* @return array Response from API.
* @throws PayoutAPIError On API failure.
*/
public function createPayout(string $currencyCode, string $toAddress, float $amount): array
{
$url = $this->baseUrl . '/v2/invoice/api/out/create';
$payload = json_encode([
'currency_code' => $currencyCode,
'to_address' => $toAddress,
'amount' => $amount,
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$decoded = json_decode($response, true);
curl_close($ch);
if ($httpCode === 200) {
return $decoded;
} else {
throw new PayoutAPIError($httpCode, $decoded ?? []);
}
}
}
// Example usage
try {
$client = new PayoutAPIClient('<your_api_key_here>');
$response = $client->createPayout('BTC', '<recipient_address>', 0.00023);
echo "Success:\n";
print_r($response);
} catch (PayoutAPIError $e) {
echo "Error occurred:\n" . $e->getMessage();
}{
"status": "success",
"result": {
"uuid": "INV-2Q2SICZN",
"created": "2026-01-01 08:03:02.216905",
"address": "TT2T11KZhoDu48i2p4FWxfG79zdkEWkU9N",
"currency": {
"id": 4,
"code": "USDT",
"fullcode": "USDT_TRC20",
"network": {
"code": "TRC20",
"id": 4,
"icon": "https://cdn.trybit.com/img/network/TRC20.svg",
"fullname": "Tron"
},
"name": "Tether",
"is_email_required": false,
"stablecoin": true,
"icon_base": "https://cdn.trybit.com/img/currency/USDT.svg",
"icon_network": "https://cdn.trybit.com/img/currency_network/USDT_TRC.svg",
"icon_qr": "https://cdn.trybit.com/img/stroke/USDT_STROKE.svg",
"order": 1
},
"date_finished": null,
"expiry_date": null,
"side_commission": "client",
"side_commission_cc": "merchant",
"type_payments": "crypto",
"status": "created",
"invoice_status": "start",
"is_email_required": false,
"project": {
"id": 1,
"name": "Test",
"fail": "https://test.com/failed-payment",
"success": "https://test.com/successful-payment",
"logo": ""
},
"tx_list": [],
"step": 1,
"test_mode": false,
"type": "dw",
"user_email": "",
"pay_url": "None",
"phone": "",
"order_id": "None",
"amount_in_crypto": null,
"amount_in_fiat": 0,
"amount": 10.0,
"amount_usd": 10.0,
"amount_to_pay": 10.0,
"amount_to_pay_usd": 10.0,
"amount_paid": 0.0,
"amount_paid_usd": 0.0,
"fee": 0.0,
"fee_usd": 0.0,
"service_fee": 0.0,
"service_fee_usd": 0.0,
"received": 0,
"received_usd": 0,
"to_surcharge": 10.0,
"to_surcharge_usd": 10.0,
"total_rub": 0,
"currency_list": [
{
"code": "USDT",
"fullcode": "USDT_TRC20",
"name": "Tether",
"is_email_required": false,
"stablecoin": true,
"icon_base": "https://cdn.trybit.com/img/currency/USDT.svg",
"icon_qr": "https://cdn.trybit.com/img/stroke/USDT_STROKE.svg",
"order": 28,
"network": [
{
"code": "TRC20",
"id": 4,
"icon": "https://cdn.trybit.com/img/network/TRC20.svg",
"fullname": "Tron"
}
]
}
],
"aml_enabled": false,
"aml_side": "merchant",
"aml_cost": 0.0,
"aml_cost_usd": 0.0,
"aml_checks": [],
"links": [],
"quiz_result": false,
"quiz_detail": {
"invoice": null,
"rating": null,
"comment": null,
"created": null
},
"memo": ""
}
}