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

# Cancel a payout

Sometimes you need to stop a payout after initiation, this guide covers cancellation procedures.

If you need to cancel a payout due to an error or change in requirements, you can do so as long as the payout is in one of the following statuses: **Pending Authorization**, **Received**, **On Hold**, or **Locked**.

You can cancel payouts through the [Business Portal](https://docs.localpayment.com/docs/dashboard-review-payout.md) or programmatically via the API.

## Prerequisites

Before canceling a payout, ensure you have:

* An **active payout transaction** with status: `PendingAuth`, `Received`, `OnHold`, or `Locked`
* Valid API credentials with proper permissions
* The transaction identifier (`externalId`)

> [!WARNING]
>
> **Important**
>
> Once a payout moves to **Processing** or **Completed** status, it cannot be cancelled through API. Contact support for assistance with processed transactions.

***

## API Endpoint

To cancel a payout send a `PATCH`request to the [Cancel a Payout](https://docs.localpayment.com/reference/void-a-payout.md) endpoint.

### Cancel Payout Request

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
PATCH https://api.stage.localpayment.com/api/payout/cancel
```

### Authentication

Include your access token in the request headers:

```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
Authorization: Bearer <your_access_token>
```

### Key Request Parameters

| Parameter | Type | Description | Required |
| - | - | - | - |
| `externalId` | string | Your system's unique transaction identifier | ✅ |

### Example Request

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request PATCH \
     --url https://api.stage.localpayment.com/api/payout/cancel \
     --header 'Authorization: Bearer <your_access_token>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '{
       "externalId": "a971b7ee-fe47-4112-81fc-484f8e5c64d7"
     }'
```

***

## Response Handling

### Success Response

When cancellation is successful, you'll receive a response with the updated status:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "externalId": "a971b7ee-fe47-4112-81fc-484f8e5c64d7",
  "internalId": "3d36811d-1c02-41ea-a576-68df62c4603a",
  "status": {
    "code": "900",
    "description": "Cancelled",
    "detail": "The payout was cancelled successfully"
  }
}
```

#### Key Response Fields

| Field | Type | Description |
| - | - | - |
| `externalId` | string | Your system's transaction identifier |
| `internalId` | string | Localpayment's internal transaction ID |
| `status.code` | string | Status code (900 = Cancelled) |
| `status.description` | string | Human-readable status description |
| `status.detail` | string | Additional details about the cancellation |

### Error Responses

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "Status": 404,
  "Message": "This transaction does not exist.",
  "TraceId": "dae2d1cb-7e9e-48a5-8530-980f38b31712"
}
```

***

## Implementation Best Practices

* Always validate transaction status before attempting cancellation
* Use HTTPS for all API requests
* Store access tokens securely and rotate them regularly
* Implement proper error handling and retry logic
* Log all cancellation attempts for audit purposes

***

## Testing Your Implementation

Before deploying to production, test your cancellation logic thoroughly:

1. **Test with valid transactions** in cancellable statuses
2. **Test with invalid transactions** to handle errors gracefully
3. **Test authentication failures** and token expiration
4. **Verify webhook handling** if implemented
5. **Test rate limiting** and retry logic

***

## Resources & Next Steps

Maximize your integration success with these essential resources

> [card] [Webhook Integration](https://docs.localpayment.com/docs/webhooks.md)
>
> Set up real-time notifications for transaction status updates.

> [card] [Reporting Business Portal](https://docs.localpayment.com/docs/balance-report.md)
>
> Access detailed analytics, reporting tools, and reconciliation features.

> [card] [Transaction Monitoring](https://docs.localpayment.com/reference/transaction-status-error-codes)
>
> Learn to query transaction status and implement comprehensive tracking.

> [card] [API Reference](https://docs.localpayment.com/reference/exchange-bulk.md)
>
> Complete endpoint documentation with interactive examples.

> [!NOTE]
>
> **Pro Tip**
>
> Always test your workflow in our sandbox environment before deploying to production. This ensures your error handling, webhook processing, and status tracking work correctly across all scenarios.

***

> [!NOTE]
>
> **Need Help?**
>
> Contact our [support team](mailto:support@localpayment.com) if you experience any issues or need assistance for integration.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.