Pay out

Here you can create a transaction to an other account using PIX.

POST

https://api.exchangecopter.com/Withdrawal/BRL

import axios from 'axios';

// Example function to call the createPixWithdrawal API
const callCreatePixWithdrawal = async () => {
  
  const url = 'https://api.exchangecopter.com/Withdrawal/BRL';
	const accesToken = 'your_accesToken_here';
  
  // Define the request payload
  const requestData = {
    recipientId: '123456789', // Replace with actual recipient ID
    amount: 100.00, // Replace with the amount in your currency unit
    pixKey: 'your_pix_key_here', // Replace with the actual PIX key
    opId: 'operation_id_here', // Replace with the actual operation ID
    bankAccountType: 'CHECKING', // Replace with bank account type, e.g., 'CHECKING or SAVINGS'
    type: 'INDIVIDUAL', // Replace with the type of holder, e.g., 'INDIVIDUAL or COMPANY'
    userId: "your_userID_here"
  };

  try {
    // Sending POST request to the API
    const response = await axios.post(url, requestData, {
      headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
        Authorization: `Bearer ${accessToken}`, // Include the Bearer token
      },
    });

    // Handling the response based on status code
    if (response.status === 200) {
      console.log('Withdrawal successful:', response.data);
    } else {
      console.log('Withdrawal failed with status:', response.status);
      console.log('Response data:', response.data);
    }
  } catch (error) {
    // Handling any errors that occur during the request
    console.error('Error during withdrawal:', error.response ? error.response.data : error.message);
  }
};

// Call the function to test
callCreatePixWithdrawal();



Response

👍

Response 200

{
  "id": "86cfd98a-dcc5-4b67-b8d7-841e4a9f37fd",
  "code": "45447b68-09fc-4af9-be82-d7b4df00fc3b",
  "amount": 990,
  "method": "PIX",
  "status": "PROCESSED",
  "createdAt": "2022-06-06T11:48:21Z",
  "approvedAt": "2022-06-06T11:48:21Z",
  "rejectedAt": null,
  "processedAt": "2022-06-06T11:48:21Z",
  "paidAt": null,
  "failedAt": null,
  "pixKey": null,
  "bankAccount": {
    "id": "a8a9c988-c2ba-44b9-af2d-ee6fcc00e269",
    "code": "ade39877-cb26-42bc-b151-8e6eef84284d",
    "holderName": "Bruce Wayne",
    "holderTaxId": "37515868066",
    "holderType": "INDIVIDUAL",
    "branchNumber": "0001",
    "accountNumber": "11111-1",
    "bankId": "60701190",
    "status": "ACTIVE",
    "createdAt": "2022-06-06T11:48:21Z",
    "updatedAt": null,
    "deletedAt": null,
    "metadata": null
  },
  "recipient": {
    "id": "80e579ff-e3a6-4573-84ff-30de777e7861",
    "code": "a1fc515c-ce4a-45e0-8802-2696b2c0337a",
    "name": "Bruce Wayne",
    "taxId": "37515868066",
    "type": "INDIVIDUAL",
    "status": "ACTIVE",
    "createdAt": "2022-06-08T15:02:00Z",
    "updatedAt": null,
    "deletedAt": null,
    "metadata": null
  },
  "metadata": {
    "CUSTOM_FIELD_NAME": "CUSTOM_FIELD_VALUE"
  }
}

❗️

Response 400 or 500

{
  data: {
     message: "There is a problem with the service.",
     description: error,
 }	
}