<!-- ZenPays documentation · https://docs.zenpays.com/docs/rest-api/endpoints/payouts/cancel-batch-payout -->

# Cancel Batch Payout

Cancel a batch payout. Payouts still in `initiated` status within the batch are cancelled. Payouts that are already `processing` or `completed` are not affected.

<EndpointHeader verb="POST" path="/payment/api/v1/batch-payouts/{batchId}/cancel" />

## Request

### Path Parameters

<ParamTable
  rows={[
    { name: "batchId", type: "string", required: true, desc: "Batch payout ID" },
  ]}
/>

### Headers

<ParamTable
  label="Header"
  rows={[
    { name: "Authorization", required: true, desc: "`Bearer {api_key}`" },
    { name: "X-Signature", required: true, desc: "HMAC-SHA256 signature" },
    { name: "X-Timestamp", required: true, desc: "ISO 8601 timestamp" },
    { name: "X-Secret-Salt", required: true, desc: "Secret salt for HMAC validation" },
  ]}
/>

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": {
    "success": true,
    "message": "Batch batch_xxxxx cancelled. 12 pending jobs removed."
  }
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "BATCH_CANCEL_FAILED", status: "400", message: "Batch already completed or cancelled" },
    { code: "BATCH_NOT_FOUND", status: "404", message: "Batch payout doesn't exist" },
  ]}
/>

<CodeRail>

## Examples

<Tabs groupId="language">
  <TabItem value="curl" label="cURL" default>

```bash
curl -X POST "https://api.zenpays.com/payment/api/v1/batch-payouts/batch_xxxxx/cancel" \
  -H "Authorization: Bearer zp_test_xxxxx" \
  -H "X-Timestamp: 2024-01-15T10:30:00.000Z" \
  -H "X-Signature: a1b2c3d4e5f6..." \
  -H "X-Secret-Salt: your_secret_salt"
```

  </TabItem>
  <TabItem value="sdk" label="SDK">

```javascript
const result = await zenpays.payouts.cancelBatch('batch_xxxxx')
console.log(result.message)
```

  </TabItem>
</Tabs>

</CodeRail>

## Related Endpoints

- [Create Batch Payout](/docs/rest-api/endpoints/payouts/create-batch-payout)
- [Get Batch Payout](/docs/rest-api/endpoints/payouts/get-batch-payout)
- [Confirm Batch Payout](/docs/rest-api/endpoints/payouts/confirm-batch-payout)
