curl -X DELETE "https://api.contazen.ro/v1/expenses/exp_abc123" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
const expenseId = 'exp_abc123';
const response = await fetch(`https://api.contazen.ro/v1/expenses/${expenseId}`, {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
const data = await response.json();
if (data.success) {
console.log('Expense deleted successfully:', data.id);
} else {
console.error('Failed to delete expense:', data.error.message);
}
$expenseId = 'exp_abc123';
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.contazen.ro/v1/expenses/{$expenseId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]
]);
$response = curl_exec($curl);
$data = json_decode($response, true);
curl_close($curl);
if ($data['success']) {
echo 'Expense deleted successfully: ' . $data['id'];
} else {
echo 'Error: ' . $data['error']['message'];
}
{
"success": true,
"message": "Expense deleted successfully",
"id": "exp_abc123"
}
{
"success": false,
"error": {
"message": "Expense not found",
"type": "invalid_request_error",
"code": "resource_missing",
"param": "id"
}
}
{
"success": false,
"error": {
"message": "Expense cannot be deleted due to business rules",
"type": "invalid_request_error",
"code": "delete_restricted",
"details": "This expense is in a closed accounting period and cannot be modified or deleted"
}
}
{
"success": false,
"error": {
"message": "Failed to delete expense",
"type": "api_error",
"code": "delete_failed",
"details": "An internal error occurred while processing the deletion"
}
}
Expenses
Delete Expense
Delete an expense record with proper validation and soft delete functionality
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"
const expenseId = 'exp_abc123';
const response = await fetch(`https://api.contazen.ro/v1/expenses/${expenseId}`, {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
const data = await response.json();
if (data.success) {
console.log('Expense deleted successfully:', data.id);
} else {
console.error('Failed to delete expense:', data.error.message);
}
$expenseId = 'exp_abc123';
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.contazen.ro/v1/expenses/{$expenseId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]
]);
$response = curl_exec($curl);
$data = json_decode($response, true);
curl_close($curl);
if ($data['success']) {
echo 'Expense deleted successfully: ' . $data['id'];
} else {
echo 'Error: ' . $data['error']['message'];
}
{
"success": true,
"message": "Expense deleted successfully",
"id": "exp_abc123"
}
{
"success": false,
"error": {
"message": "Expense not found",
"type": "invalid_request_error",
"code": "resource_missing",
"param": "id"
}
}
{
"success": false,
"error": {
"message": "Expense cannot be deleted due to business rules",
"type": "invalid_request_error",
"code": "delete_restricted",
"details": "This expense is in a closed accounting period and cannot be modified or deleted"
}
}
{
"success": false,
"error": {
"message": "Failed to delete expense",
"type": "api_error",
"code": "delete_failed",
"details": "An internal error occurred while processing the deletion"
}
}
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
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
Response
string
Confirmation message that the expense has been deleted
string
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
Impact on Related Data
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"
const expenseId = 'exp_abc123';
const response = await fetch(`https://api.contazen.ro/v1/expenses/${expenseId}`, {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
});
const data = await response.json();
if (data.success) {
console.log('Expense deleted successfully:', data.id);
} else {
console.error('Failed to delete expense:', data.error.message);
}
$expenseId = 'exp_abc123';
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.contazen.ro/v1/expenses/{$expenseId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json'
]
]);
$response = curl_exec($curl);
$data = json_decode($response, true);
curl_close($curl);
if ($data['success']) {
echo 'Expense deleted successfully: ' . $data['id'];
} else {
echo 'Error: ' . $data['error']['message'];
}
{
"success": true,
"message": "Expense deleted successfully",
"id": "exp_abc123"
}
{
"success": false,
"error": {
"message": "Expense not found",
"type": "invalid_request_error",
"code": "resource_missing",
"param": "id"
}
}
{
"success": false,
"error": {
"message": "Expense cannot be deleted due to business rules",
"type": "invalid_request_error",
"code": "delete_restricted",
"details": "This expense is in a closed accounting period and cannot be modified or deleted"
}
}
{
"success": false,
"error": {
"message": "Failed to delete expense",
"type": "api_error",
"code": "delete_failed",
"details": "An internal error occurred while processing the deletion"
}
}
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
Was this page helpful?