> ## Documentation Index
> Fetch the complete documentation index at: https://www.cashfree.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Batch Transfer

> Integrate the Cashfree Batch Transfer API to send multiple payouts in a single request and track each batch's status until every transfer completes.

A batch transfer is a way to make multiple payouts transfer requests at one time. Cashfree offers separate APIs for batch transfers. This section provides details on how to integrate a batch transfer from scratch. It includes making a batch transfer and fetching the batch transfer status.

<img src="https://mintcdn.com/cashfreepayments-d00050e9/_iQwC827ZHOkrGFs/static/payouts/payouts/integrations/payouts_batch_txfr.png?fit=max&auto=format&n=_iQwC827ZHOkrGFs&q=85&s=56da54a479e4970a46228b31b4fdeca9" alt="" width="644" height="150" data-path="static/payouts/payouts/integrations/payouts_batch_txfr.png" />

Steps

1. [Setup](#step-1-setup)
2. [Initialisation and authorisation](#step-2-initialisation-and-authorisation)
3. [Request a batch transfer](#step-3-request-batch-transfer)
4. [Get batch transfer status](#step-4-get-batch-transfer-status)

Check out our libraries and samples section for the integration code hosted on GitHub.

## Step 1: Setup

Get your corresponding clientId and clientSecret from your payout dashboard and ensure that your IP is whitelisted as well. Check our development quickstart here.

Host URL: Use the following URL for PROD and TEST, respectively:

* For the **production** environment: [https://payout-api.cashfree.com](https://payout-api.cashfree.com)
* For the **test** environment: [https://payout-gamma.cashfree.com](https://payout-gamma.cashfree.com)

## Step 2: Initialisation and authorisation

Call the authenticate API to Cashfree system or server to obtain an Authorisation Bearer token. All other API calls must have this token as authorisation header in the format 'Bearer \<token>' (without quotes) for them to be processed.

<CodeGroup>
  ```curl theme={"dark"}
  curl -X POST \
    'http://{{Host%20Url}}/payout/v1/authorize' \

  -H 'X-Client-Id: {{client id}}' \
   -H 'X-Client-Secret: {{client secret}}' \
   -H 'cache-control: no-cache'

  ```

  ```javascript Node theme={"dark"}
  //require CashfreeSDK
  const cfSdk = require("cashfree-sdk");

  //access the PayoutsSdk from CashfreeSDK
  const { Payouts } = cfSdk;

  // Instantiate Cashfree Payouts
  const payoutsInstance = new Payouts({
    env: "TEST",
    clientId: "<CLIENT_ID>",
    clientSecret: "<CLIENT_SECRET>",
  });
  ```

  ```python theme={"dark"}
  from cashfree_sdk.payouts import Payouts
  from cashfree_sdk.payouts.transfers import Transfers

  clientId = "your_client_id"
  clientSecret = "your_secret_key"
  env = "TEST"

  Payouts.init(clientId, clientSecret, env)
  ```

  ```java theme={"dark"}
  import com.cashfree.lib.clients.Payouts;
  import com.cashfree.lib.constants.Constants.Environment;

  public static void main() {
  Payouts payouts = Payouts.getInstance(
      Environment.PRODUCTION, "<client_id>", "<client_secret>");
  payouts.init();
  }
  ```
</CodeGroup>

**Sample Response**

```json theme={"dark"}
{
	"status": "SUCCESS",
	"message": "Token generated",
	"subCode": "200",
	"data": { "token": "eyJ0eXA...fWStg", "expiry": 1564130052 }
}
```

## Step 3: Request batch transfer

A batch transfer allows you to request multiple payout transfers at a given time. Batch transfers can be created by passing the beneficiary ID or by passing the beneficiary details.

<CodeGroup>
  ```curl theme={"dark"}
  curl -X POST \
    'http://{{Host%20Url}}/payout/v1/requestBatchTransfer' \
    -H 'Authorization: Bearer {{Token}}' \
    -d '{
  	"batchTransferId": "test_batch_format",
  	"batchFormat": "BENEFICIARY_ID",
  	"batch": [{
  		"transferId": "PTM_00121241112",
  		"amount": "12",
  		"beneId": "b01",
  		"remarks": "working"
  	}]
  }'
  ```

  ```javascript Node theme={"dark"}
  const response = await payoutsInstance.transfers.requestBatchTransfer({
  	batchTransferId: "Test_Bank_Account_Format_45",
  	batchFormat: "BANK_ACCOUNT",
  	deleteBene: 1,
  	batch: [
  		{
  			transferId: "PTM_00121241112",
  			amount: "12",
  			phone: "9999999999",
  			bankAccount: "9999999999",
  			ifsc: "PYTM0_000001",
  			email: "bahrat@gocashfree.com",
  			name: "bharat",
  		},
  	],
  });
  ```

  ```python theme={"dark"}
  entries = [ {"transferId" : "PTM_00121241112",
      "amount" : "12",
      "phone" : "9999999999",
      "bankAccount" : "9999999999" ,
      "ifsc" : "PYTM0_000001",
      "email" : "bahrat@gocashfree.com",
      "name": "bharat"},
      {"transferId" : "PTM_00052312126",
      "amount" : "12",
      "phone" : "9999999999",
      "bankAccount" : "9999999999" ,
      "ifsc" : "PYTM0000001",
      "email" : "bharat@gocashfree.com",
      "name": "bharat" },
      {"transferId" : "PTM_0001321215",
      "amount" : "12","phone" : "9999999999",
      "bankAccount" : "9999999999" ,
      "ifsc" : "PYTM0000001",
      "email" : "bahrat@gocashfree.com", "name": "bharat"} ]

  batch_tnx_create = Transfers.create_batch_transfer(batchTransferId="Test_Bank_Account_Format_45", batchFormat="BANK_ACCOUNT", batch=entries, deleteBene=1)
  ```

  ```java theme={"dark"}
  import com.cashfree.lib.clients.Payouts;
  import com.cashfree.lib.clients.Transfers;
  import com.cashfree.lib.domains.request.BatchTransferRequest;
  import com.cashfree.lib.domains.request.RequestTransferRequest;

  public static void main(){

  Payouts payouts = Payouts.getInstance(
      Environment.PRODUCTION, "<client_id>", "<client_secret>");
  payouts.init();
  Transfers transfer = new Transfers(payouts);

  BatchTransferRequest batchTransferRequest = new BatchTransferRequest()
          .setBatchTransferId("javasdkbatch12")
          .setBatchFormat("BANK_ACCOUNT")
          .setDeleteBene(1)
          .setBatch(List.of(
              new BatchTransferRequest.Payload()
                  .setTransferId("PTM_00121241112")
                  .setAmount(new BigDecimal("1.00"))
                  .setPhone("9999999999")
                  .setBankAccount("9999999999")
                  .setIfsc("PYTM0_000001")
                  .setEmail("bahrat@gocashfree.com")
                  .setName("bharat"),
              new BatchTransferRequest.Payload()
                  .setTransferId("PTM_00052312126")
                  .setAmount(new BigDecimal("1.00"))
                  .setPhone("9999999999")
                  .setBankAccount("9999999999")
                  .setIfsc("PYTM0000001")
                  .setEmail("bharat@gocashfree.com")
                  .setName("bharat"),
              new BatchTransferRequest.Payload()
                  .setTransferId("PTM_0001321215")
                  .setAmount(new BigDecimal("1.00"))
                  .setPhone("9999999999")
                  .setBankAccount("9999999999")
                  .setIfsc("PYTM0000001")
                  .setEmail("bahrat@gocashfree.com")
                  .setName("bharat")));

  transfers.requestBatchTransfer(batchTransferRequest);

  }
  ```
</CodeGroup>

**Sample Response**

```json theme={"dark"}
{
  "status": SUCCESS,
  "subCode": "200",
  "message": "Request accepted",
  "data": { "referenceId": 1594 }}
```

## Step 4: Get batch transfer status

Get the status of all transfers within a batch transfer.

<CodeGroup>
  ```curl theme={"dark"}
  curl -X GET \
    'http://{{Host%20Url}}/payout/v1/getBatchTransferStatus?batchTransferId=test_batch_format_01' \
    -H 'Authorization: Bearer {{Token}}' \
  ```

  ```javascript Node theme={"dark"}
  const response = await payoutsInstance.tranfers.getBatchTransferStatus({
  batchTransferId:Test_Bank_Account_Format_45"
  });
  ```

  ```python theme={"dark"}
  status = Transfers.get_batch_transfer_status(batchTransferId="Test_Bank_Account_Format_45")
  ```

  ```java theme={"dark"}
  import com.cashfree.lib.clients.Payouts;
  import com.cashfree.lib.clients.Transfers;
  import com.cashfree.lib.domains.request.BatchTransferRequest;
  import com.cashfree.lib.domains.request.RequestTransferRequest;

  public static void main(){

  Payouts payouts = Payouts.getInstance(
      Environment.PRODUCTION, "<client_id>", "<client_secret>");
  payouts.init();
  Transfers transfer = new Transfers(payouts);

  transfers.getBatchTransferStatus("javasdkbatch12");
  }
  ```
</CodeGroup>

**Sample Response**

```json theme={"dark"}
{
	"status": "SUCCESS",
	"subCode": "200",
	"message": "Details of transfer with transferId 159381033b123",
	"data": {
		"transfer": {
			"referenceId": 17073,
			"bankAccount": "026291800001191",
			"beneId": "ABCD_123",
			"amount": "20.00",
			"status": "SUCCESS",
			"utr": "1387420170430008800069857",
			"addedOn": "2017­-01­-07 20:09:59",
			"processedOn": "2017­-01­-07 20:10:05",
			"acknowledged": 1
		}
	}
}
```

Check out our [Samples](/docs/payouts/payouts/integrations/samples) section for the integration code hosted on GitHub.

You now have a complete standard transfer integration for payouts. Cashfree will send webhooks in the case of certain events. Webhooks are server to server notifications. Learn more in the [payouts webhooks documentation](/docs/payouts/payouts/make-payouts/webhooks).

When testing your integration with your test API key, you can use [test numbers](/docs/payouts/payouts/integrations/data-to-test) to ensure that it works correctly.

<div class="hidden" data-table-of-contents="bottom">
  <p class="mt-4 font-medium flex items-center gap-2 related-docs-heading">
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="w-4 h-4">
      <path d="M3 4h7a2 2 0 0 1 2 2v13a2 2 0 0 0-2-2H3z" />

      <path d="M21 4h-7a2 2 0 0 0-2 2v13a2 2 0 0 1 2-2h7z" />
    </svg>

    <span>Related topics</span>
  </p>

  <ul>
    <li><a href="/docs/api-reference/payouts/v2/transfers-v2/batch-transfer-v2">Batch Transfer API v2</a></li>
    <li><a href="/docs/api-reference/payouts/v2/transfers-v2/get-batch-transfer-status-v2">Get Batch Transfer Status API v2</a></li>
    <li><a href="/docs/api-reference/payouts/v1/authorize">Authorize API</a></li>
    <li><a href="/docs/payouts/payouts/integrations/samples">Sample Integration Kits</a></li>
  </ul>
</div>
