Repository navigation
Replies: 2 comments
|
I will add this. Now that there is a full app using the API, it makes sense for edit and delete to be there as well. It will work the same way as the web UI, with a few extra checks, as an app doesn't see the warnings the web UI shows:
Moving a transaction to another account and changing its status will be left out for the time being. Balances are recalculated after every change, so an edit can't leave them wrong. For retries, PATCH just sets the values you send, so sending it again is safe, and a repeated DELETE returns 404, which you can treat as already deleted. |
|
This is done and will be in the next release. It works the way I described above, the one addition is that deleting a reconciled transaction needs The spec is in openapi.json on dev if you want to start on it before the release: https://github.com/otherworld-dev/Budget/blob/dev/budget/openapi.json, the docs page will go up with the release. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Feature Request: Add transaction update and delete endpoints to the public API
Description
The public Budget API currently provides endpoints for reading transactions and creating new transactions, but there is no public API endpoint for updating or deleting an existing transaction.
This makes it difficult for external clients, mobile applications and automation tools to provide a complete transaction workflow.
I would like to propose adding official API endpoints for updating and deleting transactions, while keeping all existing Budget business rules and permission checks in place.
The goal is not to expose internal web endpoints, but to provide a stable, documented API specifically intended for external clients.
Proposed API
Update a transaction
I suggest using:
PATCHwould allow clients to update only the fields that have changed.For example:
{ "date": "2026-09-28", "amount": 42.50, "description": "Supermarket", "vendor": "Example Market", "category_id": 15, "notes": "Updated transaction" }The response should return the updated transaction in the same representation used by the existing transaction API.
Delete a transaction
I suggest:
For example:
A successful deletion could return the deleted transaction or an appropriate OCS success response.
Why PATCH instead of PUT?
PATCHseems appropriate because clients will often change only one or two properties of a transaction.For example, a user may only want to:
The client should not have to send the complete transaction object just to change one property.
Important business rules / edge cases
The API should use the same business logic and permission checks as the Budget application itself.
1. Normal transactions
A normal transaction should be editable and deletable through the API if the authenticated user has permission to modify it.
Changing fields such as:
should result in the same recalculations that would occur when making the corresponding change in the Budget web interface.
For example, changing:
to:
must update the corresponding budget/category calculations.
Likewise, changing the amount should update account balances and all relevant calculations.
2. Split transactions
Split transactions need special consideration.
For example:
The API should either:
One possible approach would be:
for the transaction itself, while:
continues to manage the split structure.
The important point is that an external client should be able to perform a complete edit of a split transaction without having to use private/internal endpoints.
3. Transfers
Transfers require additional care because one logical transfer can involve more than one transaction/account.
For example:
Deleting or modifying only one side of such a transfer could leave inconsistent data.
Therefore, the API should explicitly define what happens when the transaction belongs to a transfer.
Possible approaches include:
For example:
would be a possible future extension.
I would prefer consistency with the existing Budget data model rather than allowing an API client to accidentally modify only one side of a transfer.
4. Reconciled transactions
A transaction that has already been reconciled may need additional protection.
The API should define whether:
If Budget already has a specific rule for this in the web interface, the API should follow the same rule.
For example, an API response could indicate:
409 Conflictif the requested operation would violate the reconciliation state.
5. Permissions and shared accounts
The API must enforce the same ownership/sharing rules as the Budget application.
A user should not be able to modify or delete a transaction merely because they know its transaction ID.
The server should verify that the authenticated user has permission to modify the associated account/transaction.
6. Non-existent transactions
For an unknown transaction ID:
should return an appropriate:
404 Not FoundThe same error conventions as the existing transaction API should be used.
7. Idempotency and mobile clients
The existing transaction creation API supports idempotency, which is particularly useful for mobile clients where network connections can fail after the server has already processed a request.
The same general consideration would be useful for update/delete operations.
For example, a mobile client might send an update and then lose the connection before receiving the response.
A retry must not accidentally produce an inconsistent state.
If idempotency keys are not appropriate for
PATCH/DELETE, the API should at least document the expected retry semantics.8. Atomicity
An update should either succeed completely or fail without leaving partially modified data.
This is particularly important for:
For example, changing a transaction from €50 to €75 must not update the transaction while leaving the account balance calculated as if the transaction were still €50.
Example: mobile client workflow
A mobile client could then implement the complete transaction workflow.
Read
Edit
{ "category_id": 15 }Delete
This would allow a native mobile application to provide the same basic transaction lifecycle as the Budget web application without relying on undocumented internal endpoints.
API design considerations
I would recommend that the implementation:
Most importantly, the public API should remain the stable interface. External clients should not need to reverse-engineer or call internal frontend endpoints.
Possible future extension
Once transaction update/delete is available, the API could eventually be extended with dedicated operations for more complex transaction types.
For example:
However, I don't think transfer-specific endpoints are necessarily required for the initial implementation if normal transaction update/delete can safely handle the existing Budget data model.
Backwards compatibility
This should be a backwards-compatible addition to the existing API.
Existing endpoints:
would remain unchanged.
The new functionality would add:
without changing the behavior of existing clients.
Motivation
A complete public transaction API is particularly useful for:
Budget already provides a public API for external clients, so adding transaction update and delete would make that API significantly more complete.
I would therefore like to propose this as an official extension of the public Budget API.
Thank you for considering it!
@otherworld-dev
All reactions