Overview
The Delete Expense endpoint allows you to remove an expense from your records. The system performs a soft delete, which means the expense is marked as deleted but preserved in the database for audit and compliance purposes.
Deletion is permanent from the user perspective and cannot be undone through the API. Ensure you really want to delete the expense before calling this endpoint.
Path Parameters
The CzUid of the expense to delete
Business Rules
The system will validate that the expense can be safely deleted:
Accounting periods : Expenses in closed accounting periods may not be deletable
Integration locks : Expenses that have been synchronized with external systems may be protected
Audit requirements : Some expenses may be required to be kept for compliance reasons
If an expense cannot be deleted due to business rules, the API will return an appropriate error message.
Response
Confirmation message that the expense has been deleted
The CzUid of the deleted expense for reference
Soft Delete Behavior
When an expense is deleted:
Status Update : The expense is marked as deleted in the database
Timestamp : A deletion timestamp is recorded
List Exclusion : The expense will no longer appear in standard list endpoints
Audit Trail : The deletion is logged for audit purposes
Data Preservation : All expense data is preserved for compliance and reporting
Deleting an expense affects related data:
Statistics : The expense is excluded from future statistics calculations
Totals : List totals will be recalculated without this expense
Reports : The expense will not appear in standard reports
Attachments : Any attached files remain in the system but are marked as orphaned
curl -X DELETE "https://api.contazen.ro/v1/expenses/exp_abc123" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
200 - Success
404 - Not Found
403 - Cannot Delete
500 - Delete Failed
{
"success" : true ,
"message" : "Expense deleted successfully" ,
"id" : "exp_abc123"
}
Best Practices
Before Deleting
Verify the expense : Use the Retrieve Expense endpoint to confirm you have the correct expense
Check dependencies : Ensure the expense is not referenced by other records
Consider alternatives : Sometimes updating an expense to mark it as cancelled is preferable to deletion
After Deletion
Update local records : Remove the expense from any local caches or displays
Refresh totals : Update any calculated totals in your application
Notify users : Inform relevant users that the expense has been removed
Error Handling
Always handle potential errors gracefully:
404 errors : The expense may have already been deleted or the ID is incorrect
403 errors : Business rules prevent deletion - inform the user why
500 errors : Technical issues - retry or contact support
Alternative Actions
Consider these alternatives to deletion:
Void the expense : Mark it as cancelled while preserving the record
Reduce amount to zero : Keep the expense but remove its financial impact
Archive : Move to an archived status instead of deleting
Use your API key (sk_live_xxx or sk_test_xxx)
Expense deleted successfully