Make a Cash Out
Cash out Endpoint
Create a cash out operation. The value entered in the 'value' field must be entered in cents. Example: If it is 10 reais, enter 1000 in the 'value' field
https://sandbox.tickpay.com/api/v1/wallets/out
Request
To access this endpoint, you need to provide a valid access token in the Authorization header.
- cURL
- C#
- JavaScript
- Python
- Java
- PHP
Use the following cURL command to create a cash out operation:
curl -X 'POST' \
'https://sandbox.tickpay.com/api/v1/wallets/out' \
-H 'accept: application/json' \
-H 'Authorization: Bearer your_access_token' \
-H 'Content-Type: application/json' \
-d '{
"value": 5000,
"callbackUrl": "https://example.com/callback",
"pixDestinyType": "EMAIL",
"pixDestinyKey": "[email protected]",
"metadata": {
"key": "value",
"anotherKey": "anotherValue"
},
"externalReference": "ABC123"
}'
Use the following csharp command to create a cash out operation:
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string apiUrl = "https://sandbox.tickpay.com/api/v1/wallets/out";
string token = "your_access_token";
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("accept", "application/json");
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}");
var requestData = new
{
value = 5000,
callbackUrl = "https://example.com/callback",
pixDestinyType = "EMAIL",
pixDestinyKey = "[email protected]",
metadata = new
{
key = "value",
anotherKey = "anotherValue"
},
externalReference = "ABC123"
};
string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(requestData);
HttpContent content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(apiUrl, content);
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
else
{
Console.WriteLine($"Error: {response.StatusCode} - {response.ReasonPhrase}");
}
}
}
}
Use the following javascript command to create a cash out operation:
const url = 'https://sandbox.tickpay.com/api/v1/wallets/out';
const headers = {
'accept': 'application/json',
'Authorization': 'Bearer your_access_token',
'Content-Type': 'application/json'
};
const requestBody = {
value: 5000,
callbackUrl: 'https://example.com/callback',
pixDestinyType: "EMAIL",
pixDestinyKey: "[email protected]",
metadata: {
key: 'value',
anotherKey: 'anotherValue'
},
externalReference: 'ABC123'
};
post(url, {
method: 'POST',
headers: headers,
body: JSON.stringify(requestBody)
})
.then(response => response.json())
.then(data => {
console.log('Server Response:', data);
})
.catch(error => {
console.error('Request Error:', error);
});
Use the following python command to create a cash out operation:
import requests
url = 'https://sandbox.tickpay.com/api/v1/wallets/out'
headers = {
'accept': 'application/json',
'Authorization': 'Bearer your_access_token',
'Content-Type': 'application/json'
}
data = {
"value": 5000,
"callbackUrl": "https://example.com/callback",
"pixDestinyType": "EMAIL",
"pixDestinyKey": "[email protected]",
"metadata": {
"key": "value",
"anotherKey": "anotherValue"
},
"externalReference": "ABC123"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
Use the following java command to create a cash out operation:
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Map;
public class Example {
public static void main(String[] args) {
HttpClient httpClient = HttpClient.newHttpClient();
String url = "https://sandbox.tickpay.com/api/v1/wallets/out";
Map<String, String> headers = Map.of(
"accept", "application/json",
"Authorization", "Bearer your_access_token",
"Content-Type", "application/json"
);
String requestBody = "{\n" +
" \"value\": 5000,\n" +
" \"callbackUrl\": \"https://example.com/callback\",\n" +
" \"pixDestinyType\": \"EMAIL\",\n" +
" \"pixDestinyKey\": \"[email protected]\",\n" +
" \"metadata\": {\n" +
" \"key\": \"value\",\n" +
" \"anotherKey\": \"anotherValue\"\n" +
" },\n" +
" \"externalReference\": \"ABC123\"\n" +
"}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.headers(headers.entrySet().stream()
.flatMap(e -> Map.entry(e.getKey(), e.getValue()).stream())
.toArray(String[]::new))
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
try {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
Use the following php command to create a cash out operation:
<?php
$apiUrl = "https://sandbox.tickpay.com/api/v1/wallets/out";
$accessToken = "your_access_token";
$data = array(
'value' => 5000,
'callbackUrl' => 'https://example.com/callback',
'pixDestinyType' => 'EMAIL',
'pixDestinyKey' => '[email protected]',
'metadata' => array(
'key' => 'value',
'anotherKey' => 'anotherValue'
),
'externalReference' => 'ABC123'
);
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'accept: application/json',
'Authorization: Bearer ' . $accessToken,
'Content-Type: application/json'
));
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
}
curl_close($ch);
echo $result;
?>
Request body
| Parameter | Description | Required |
|---|---|---|
value | The monetary value of the transaction,, representing cents. | true |
callbackUrl | The URL to which the transaction status will be sent asynchronously. | true |
pixDestinyType | Specifies the type of PIX destination. Accepted values: EMAIL, PHONE, DOCUMENT or RANDOM. | true |
pixDestinyKey | The PIX destination identifier, such as an email address or phone number. | true |
metadata | Additional key-value pairs providing metadata associated with the transaction. | false |
externalReference | An external reference or identifier for the transaction. | false |
Response
The response will contain a data object, along with additional information:
{
"data": {
"id": "9a6abcb2-f3bc-4d28-9c52-b69a01c8f1a9",
"callbackUrl": "https://example.com/callback",
"value": 5000,
"tax": 100,
"description": "Cash-out created successfully.",
"operation": "CASH_OUT",
"status": "PENDING",
"metadata": {
"key": "value",
"anotherKey": "anotherValue"
},
"externalReference": "ABC123",
"createdAt": "2024-01-12T03:49:14.985Z"
},
"messageError": null,
"success": true
}
Response Properties
| Parameter | Description | Default Value |
|---|---|---|
messageError | Error message. | null |
success | Indicates whether the request was successful. | false |
data Properties | ||
id | Unique identifier for the transaction. | |
callbackUrl | URL for callback. | |
value | Specific value in the response, representing cents. | |
tax | Tax value. | |
description | Description of the operation. | |
operation | Type of operation. | |
status | Current status of the transaction. Possible properties | |
metadata | Additional metadata. | |
externalReference | External reference identifier. | |
createdAt | Date and time of creation. |
Possible Properties
| Parameter | Description |
|---|---|
status | PENDING, CANCELED, SUCCEED, FAILED |