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

# Cancel Payout

:::danger[Deprecated — Do Not Use]
This endpoint is **deprecated** and will be removed in a future release. It is no longer maintained and may produce unexpected behavior.

**Use [Payout Intents](/docs/rest-api/endpoints/payout-intents/cancel-payout-intent) instead.**
:::

Cancel a payout that is still in `initiated` status. The blocked wallet amount is released back to the merchant.

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

## Request

### Path Parameters

<ParamTable
  rows={[
    { name: "payoutId", type: "string", required: true, desc: "Payout ID to cancel" },
  ]}
/>

### 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" },
    { name: "Content-Type", required: true, desc: "`application/json`" },
  ]}
/>

### Body Parameters

<ParamTable
  rows={[
    { name: "reason", type: "string", desc: "Reason for cancellation" },
  ]}
/>

## Response

### Success (200 OK)

```json
{
  "success": true,
  "data": {
    "payoutId": "payout_xxxxx",
    "status": "cancelled",
    "failureReason": "No longer needed",
    "amount": 10000,
    "currency": "INR"
  },
  "message": "Payout cancelled successfully"
}
```

### Error Responses

<ErrorTable
  rows={[
    { code: "PAYOUT_CANCEL_FAILED", status: "400", message: "Payout is not in `initiated` status" },
    { code: "PAYOUT_NOT_FOUND", status: "404", message: "Payout doesn't exist" },
    { code: "UNAUTHORIZED", status: "401", message: "Invalid API key" },
  ]}
/>

<CodeRail>

## Examples

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

```bash
curl -X POST "https://api.zenpays.com/payment/api/v1/payouts/payout_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" \
  -H "Content-Type: application/json" \
  -d '{"reason": "No longer needed"}'
```

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

```javascript
const cancelled = await zenpays.payouts.cancel('payout_xxxxx', 'No longer needed')
console.log(cancelled.status) // 'cancelled'
```

  </TabItem>
</Tabs>

</CodeRail>

## Related Endpoints

- [Create Payout](/docs/rest-api/endpoints/payouts/create-payout)
- [Get Payout](/docs/rest-api/endpoints/payouts/get-payout)
- [Retry Payout](/docs/rest-api/endpoints/payouts/retry-payout)
