Method

transaction.delete

Delete a transaction that is not read-only.

Deletes a transaction and all its splits; the splits leave their lots. A read-only transaction (voided, or protected by the auto read-only threshold) is refused with conflict. Deleting erases the record; to cancel a posted entry and keep the history, use transaction.void or transaction.reverse.

Examples

Example: with a copy of the reports/test-data example book open as book.gnucash.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"transaction.delete","params":{"guid":"c0000000000000000000000000000006"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {}
}

Request:

{"jsonrpc":"2.0","id":2,"method":"transaction.get","params":{"guid":"c0000000000000000000000000000006"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 2,
  "error": {
    "code": 2000,
    "message": "…",
    "data": {
      "kind": "transaction",
      "id": "c0000000000000000000000000000006",
      "help": "error/not-found"
    }
  }
}

Command line

red-ale exec --book book.gnucash --script - <<'EOF'
transaction.delete {"guid":"c0000000000000000000000000000006"}
transaction.get {"guid":"c0000000000000000000000000000006"}
EOF

It fails with exit status 2, printing on standard error:

{
  "error": {
    "code": 2000,
    "message": "…",
    "data": {
      "kind": "transaction",
      "id": "c0000000000000000000000000000006",
      "help": "error/not-found"
    }
  }
}

MCP tool call

Tool call:

{"name":"transaction.delete","arguments":{"guid":"c0000000000000000000000000000006"}}

Result:

{
  "structuredContent": {}
}

Tool call:

{"name":"transaction.get","arguments":{"guid":"c0000000000000000000000000000006"}}

Result:

{
  "isError": true,
  "structuredContent": {
    "error": {
      "code": 2000,
      "name": "not-found",
      "message": "…",
      "data": {
        "kind": "transaction",
        "id": "c0000000000000000000000000000006",
        "help": "error/not-found"
      }
    }
  }
}

Effect: destructive, on the Book.

Params

Params naming one transaction.

  • guid (Guid, required): The transaction's GUID.

Result

A result with nothing to report.

Type: Done.