Cancel Payout API
Cancel a pending payout and receive a refund to your wallet
Cancel Payout API
Cancel a payout that has not yet been completed. Cancelled payouts are refunded to your wallet.
Endpoint
POST /api/v1/payouts/:id/cancelAuthentication: API Key + Secret required
Request Headers
X-API-Key: sk_live_abc123def456
X-API-Secret: your-secret-herePath Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Payout ID to cancel (e.g., pyt_xyz789abc) |
Cancellation Rules
A payout can only be cancelled when it's in certain states:
| Status | Can Cancel? | Notes |
|---|---|---|
created | Yes | Immediately cancellable |
queued | Yes | Can cancel before processing starts |
processing | Maybe | Depends on provider - may already be submitted |
settling | No | Funds already with beneficiary |
action_required | Yes | Can cancel while waiting for action |
completed | No | Already delivered |
failed | No | Already failed (refund automatic) |
cancelled | No | Already cancelled |
expired | No | Already expired |
Response
Success Response
Status Code: 200 OK
Returns the updated payout with cancelled status:
{
"id": "pyt_xyz789abc",
"reference_id": "PAY_2024_001",
"status": "cancelled",
"amount": 100.00,
"currency": "USD",
"fees": 1.50,
"total_amount": 101.50,
"beneficiary": {
"email": "john.doe@example.com",
"first_name": "John",
"last_name": "Doe",
"country": "US"
},
"description": "Bonus Payment",
"created_at": "2024-01-15T10:30:00Z",
"cancelled_at": "2024-01-15T10:32:00Z",
"events": [
{
"event_type": "status_change",
"from_status": null,
"to_status": "created",
"actor_type": "system",
"message": "Payout created",
"created_at": "2024-01-15T10:30:00Z"
},
{
"event_type": "status_change",
"from_status": "created",
"to_status": "cancelled",
"actor_type": "client",
"message": "Payout cancelled by client",
"created_at": "2024-01-15T10:32:00Z"
}
]
}Error Responses
400 Bad Request - Cannot Cancel
{
"error": "BadRequest",
"message": "payout cannot be cancelled in current status"
}400 Bad Request - Already Completed
{
"error": "BadRequest",
"message": "payout has already been completed"
}400 Bad Request - Missing ID
{
"error": "BadRequest",
"message": "Payout ID is required"
}404 Not Found
{
"error": "NotFound",
"message": "Payout not found"
}401 Unauthorized
{
"error": "UnauthorizedAccess",
"message": "Authentication required"
}Examples
Basic Cancellation
curl -X POST "{{host}}/api/v1/payouts/pyt_xyz789abc/cancel" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here"Safe Cancellation with Status Check
Batch Cancellation
User Confirmation Flow
Refund Process
When a payout is cancelled:
- Status Update - Payout status changes to
cancelled - Wallet Credit - The total amount (payout amount + fees) is refunded to the source wallet
- Event Logged - A cancellation event is added to the payout history
- Timestamp Set - The
cancelled_atfield is populated
Refund Timeline
- Immediate: Cancellation of
createdorqueuedpayouts - May take time: Cancellation of
processingpayouts (depends on provider)
Verify Refund
After cancellation, verify the refund in your wallet:
Error Handling
Handle Common Errors
Best Practices
- Check status first - Verify the payout is in a cancellable state before attempting
- Act quickly - Cancel as soon as possible; once processing starts, cancellation may fail
- Confirm with users - Always show a confirmation dialog for user-initiated cancellations
- Verify refunds - Check wallet balance or transaction history to confirm refund
- Log cancellations - Keep records of all cancellation attempts and outcomes
Use Cases
Duplicate Detection
Fraud Prevention
Related Endpoints
- Create Payout - Create new payouts
- Get Payout - Check payout status before cancelling
- List Payouts - Find payouts to cancel
- Wallets API - Verify refund in wallet