POST
/transactions/{transactionId}/reverseReverse a posted transaction
Reverse a transaction
Parameters
| Name | In | Type | Description |
|---|---|---|---|
transactionIdrequired | path | string uuid | Transaction UUID to reverse |
Request bodyrequired
| Field | Type | Description |
|---|---|---|
reasonrequired | string | Reason for reversal |
daterequired | string date | Effective date of reversal |
reference | string nullable | |
metadata | object nullable | |
idempotency_key | string nullable |
Responses
201Reversal transaction created
{
"success": true,
"data": {
"id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
"ledger_id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
"reference": "INV-001",
"description": "Payment received",
"effective_date": "2026-01-15T10:30:00Z",
"date": "2026-01-15T10:30:00Z",
"layer": "settled",
"status": "posted",
"total_amount": "100.00",
"entry_count": 2,
"entries": [
{
"id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
"account_id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
"account_code": "1000",
"account_name": "Cash",
"amount": "100.00",
"type": "debit",
"layer": "settled"
}
],
"created_at": "2026-01-15T10:30:00Z",
"updated_at": "2026-01-15T10:30:00Z"
}
} 400Validation error
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 401Unauthenticated
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 403Forbidden
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 404Transaction not found
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 409Idempotency conflict — request with this key in progress (idempotency_key_in_use) or key already used for a different operation (idempotency_key_reused)
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 422Transaction cannot be reversed
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} 503Idempotency service unavailable (code SERVICE_UNAVAILABLE) — fail-closed with a Retry-After header; nothing is written
{
"success": false,
"message": "Validation failed",
"code": "VALIDATION_ERROR"
} Examples
curl -X POST https://ledga.io/api/v1/transactions/{transactionId}/reverse \
-H "Authorization: Bearer sk_xxxxxxxx_your_secret" \
-H "Content-Type: application/json" \
-d '{
"reason": "Customer refund",
"date": "2025-01-15",
"reference": "REF-001"
}' use Ledga\Api\LedgaClient;
$ledga = new LedgaClient('sk_xxxxxxxx_your_secret');
$reversal = $ledga->transactions->reverse('01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a', [
'reason' => 'Customer refund',
'date' => '2026-01-20',
]);