Ledga
POST /transactions/{transactionId}/reverse

Reverse a posted transaction

Reverse a transaction

Parameters

NameInTypeDescription
transactionIdrequired path string
uuid
Transaction UUID to reverse

Request bodyrequired

FieldTypeDescription
reasonrequired string Reason for reversal
daterequired string
date
Effective date of the reversal, read as effective_date is on a posting. At most 30 days ahead unless every entry of the original is in the encumbrance layer; refused inside a closed period or one whose close is in progress
reference string
nullable
Defaults to REV- and the original's reference (REV-INV-1), with -2, -3 and so on when that is taken, as when an original is reversed again after its contra was voided; none when the original has none. Not in the shape a period close writes, CLOSE-<monthly|quarterly|yearly>-<period end> with -2, -3 and so on, which is reserved for it.
metadata object
nullable
idempotency_key string
nullable
Not in the shape a period close writes, period_close_<ledger id>_<period end> with _2, _3 and so on, which is reserved for it.

Responses

201Reversal transaction created
{
  "success": true,
  "data": {
    "ledger_id": "01997b90-1c2d-7e3f-8a4b-5c6d7e8f9a0b",
    "journal_id": null,
    "total_amount": "500.00",
    "entry_count": 2,
    "voided_by": null,
    "voided_at": null,
    "void_reason": null,
    "id": "019bdfff-2900-7b20-9c3d-4e5f6a7b8c9d",
    "reference": "REV-INV-001",
    "description": "Reversal of: Invoice INV-001 paid",
    "effective_date": "2026-01-21T00:00:00.000000Z",
    "date": "2026-01-21T00:00:00.000000Z",
    "layer": "settled",
    "status": "posted",
    "hash": null,
    "previous_hash": null,
    "correlation_id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
    "correlation_source_id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
    "correlation_type": "reversal",
    "metadata": {
      "original_transaction_id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
      "reversal_reason": "Customer refund"
    },
    "attributes": {},
    "original_transaction_id": "01997c1e-4d2a-7c3e-9a1b-2f0e8c6d4b5a",
    "reversal_reason": "Customer refund",
    "entries": [
      {
        "id": "019bdfff-2900-7b21-9c3d-4e5f6a7b8c9d",
        "account_id": "01997b91-2a3b-7c4d-9e5f-6a7b8c9d0e1f",
        "account_code": "1000",
        "account_name": "Cash",
        "amount": "500.00",
        "type": "credit",
        "description": "Reversal: ",
        "layer": "settled",
        "metadata": null
      },
      {
        "id": "019bdfff-2900-7b22-9c3d-4e5f6a7b8c9d",
        "account_id": "01997b91-2a3b-7c4d-9e5f-6a7b8c9d0e20",
        "account_code": "4000",
        "account_name": "Sales",
        "amount": "500.00",
        "type": "debit",
        "description": "Reversal: ",
        "layer": "settled",
        "metadata": null
      }
    ],
    "created_at": "2026-01-21T10:00:00+00:00",
    "updated_at": "2026-01-21T10:00:00+00:00"
  }
}
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) — or the date falls in a closed period or one whose close is in progress (code PERIOD_LOCKED)
{
  "success": false,
  "message": "Validation failed",
  "code": "VALIDATION_ERROR"
}
422Validation error (including a date more than 30 days ahead for a transaction that is not pure encumbrance), the transaction cannot be reversed, a balance limit would be breached (code BALANCE_LIMIT_EXCEEDED), or an account was deleted while posting (code ACCOUNT_DELETED); either names the account in errors.account_code
{
  "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"
}'

← All endpoints