DELETE
/
expenses
/
{id}
curl -X DELETE "https://api.contazen.ro/v1/expenses/exp_abc123" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"
{
  "success": true,
  "message": "Expense deleted successfully",
  "id": "exp_abc123"
}

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

id
string
required
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

message
string
Confirmation message that the expense has been deleted
id
string
The CzUid of the deleted expense for reference

Soft Delete Behavior

When an expense is deleted:
  1. Status Update: The expense is marked as deleted in the database
  2. Timestamp: A deletion timestamp is recorded
  3. List Exclusion: The expense will no longer appear in standard list endpoints
  4. Audit Trail: The deletion is logged for audit purposes
  5. 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"
{
  "success": true,
  "message": "Expense deleted successfully",
  "id": "exp_abc123"
}

Best Practices

Before Deleting

  1. Verify the expense: Use the Retrieve Expense endpoint to confirm you have the correct expense
  2. Check dependencies: Ensure the expense is not referenced by other records
  3. Consider alternatives: Sometimes updating an expense to mark it as cancelled is preferable to deletion

After Deletion

  1. Update local records: Remove the expense from any local caches or displays
  2. Refresh totals: Update any calculated totals in your application
  3. 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

Authorizations

Authorization
string
header
required

Use your API key (sk_live_xxx or sk_test_xxx)

Path Parameters

id
string
required

Expense CzUid

Response

Expense deleted successfully

success
boolean
message
string
meta
object