API ReferenceapiaccountingPOST /v1/transactions/{id}/reverse

POST /v1/transactions/\{id\}/reverse

Service: accounting · operationId: (none)

Reverse a previously posted transaction by creating a compensating transaction with inverted entries

Required scopes

(no scope declared — review service config)

Path parameters

  • id (string) required

Required headers

  • idempotency-key

Request body

{
  "type": "object",
  "properties": {
    "reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "Reason for the reversal"
    },
    "external_ref": {
      "type": [
        "string",
        "null"
      ],
      "description": "External reference (e.g. refund ID)"
    }
  }
}

Responses

201 Reversal transaction created successfully

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "type": {
      "type": "string"
    },
    "external_ref": {
      "type": [
        "string",
        "null"
      ]
    },
    "memo": {
      "type": [
        "string",
        "null"
      ]
    },
    "posted_at": {
      "type": "string",
      "format": "date-time"
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "amount_cents": {
            "type": "integer"
          },
          "memo": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "account_id",
          "amount_cents",
          "memo"
        ]
      }
    },
    "reversal_of": {
      "type": "string",
      "description": "ID of the original reversed transaction"
    }
  },
  "required": [
    "id",
    "type",
    "external_ref",
    "memo",
    "posted_at",
    "entries",
    "reversal_of"
  ]
}

404 Original transaction not found

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}

409 Transaction already reversed or idempotency key conflict

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}

500 Internal server error

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}

Example

curl -X POST https://accounting.platform.loop.health/v1/transactions/{id}/reverse \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'