POST
/
expenses
/
{id}
/
pay
curl -X POST "https://api.contazen.ro/v1/expenses/exp_abc123/pay" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "paid_date": "2024-01-20",
    "payment_type": 2
  }'
{
  "success": true,
  "expense": {
    "id": "exp_abc123",
    "reference": "INV-2024-001",
    "description": "Office supplies purchase",
    "amount": {
      "total": "238.00",
      "without_vat": "200.00",
      "vat": "38.00",
      "currency": "RON"
    },
    "account_amount": {
      "total": "238.00",
      "without_vat": "200.00",
      "vat": "38.00",
      "currency": "RON"
    },
    "vat_percent": 19,
    "with_vat": true,
    "date": "2024-01-15",
    "due_date": "2024-02-15",
    "paid_date": "2024-01-20",
    "is_paid": true,
    "payment_type": {
      "id": 2,
      "name": "Bank transfer"
    },
    "status": "paid",
    "supplier_id": "sup_xyz789",
    "category_id": 1,
    "user_id": 1,
    "created_at": "2024-01-15 10:30:00",
    "updated_at": "2024-01-20 14:30:00"
  },
  "message": "Expense marked as paid successfully"
}

Overview

The Mark Expense as Paid endpoint allows you to record payment for an unpaid expense. This is a specialized endpoint that specifically handles the payment workflow, updating the expense status and recording payment details.
This endpoint is designed for expenses that are currently unpaid. If an expense is already paid, the request will fail with an appropriate error message.

Path Parameters

id
string
required
The CzUid of the expense to mark as paid

Request Body

paid_date
string
required
The date when the payment was made (YYYY-MM-DD format)
payment_type
integer
required
The payment method used (1-7):
  • 1 - Cash
  • 2 - Bank transfer
  • 3 - Card
  • 4 - Check
  • 5 - Promissory note
  • 6 - Other
  • 7 - Compensation

Response

expense
object
The updated expense object reflecting the payment
message
string
Success message confirming the payment has been recorded

Business Logic

When an expense is marked as paid:
  1. Status Update: The expense status changes from unpaid/overdue to paid
  2. Payment Recording: Payment date and method are permanently recorded
  3. Audit Trail: The payment action is logged for audit purposes
  4. Notifications: Internal notifications may be triggered (if configured)

Validation Rules

  • Expense Exists: The expense must exist and be owned by your firm
  • Payment Status: The expense must currently be unpaid (not already paid)
  • Date Format: Payment date must be in YYYY-MM-DD format
  • Payment Type: Must be a valid payment type ID (1-7)
  • Date Logic: Payment date should typically not be in the future

Error Scenarios

Already Paid

If the expense is already marked as paid, you’ll receive a 400 error. Use the Update Expense endpoint if you need to change payment details for an already-paid expense.

Invalid Payment Type

Payment types must match the predefined values. Check the payment_type parameter documentation for valid options.

Date Validation

Payment dates must be valid dates in the correct format. The system may also validate that payment dates are reasonable (not too far in the past or future).
curl -X POST "https://api.contazen.ro/v1/expenses/exp_abc123/pay" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "paid_date": "2024-01-20",
    "payment_type": 2
  }'
{
  "success": true,
  "expense": {
    "id": "exp_abc123",
    "reference": "INV-2024-001",
    "description": "Office supplies purchase",
    "amount": {
      "total": "238.00",
      "without_vat": "200.00",
      "vat": "38.00",
      "currency": "RON"
    },
    "account_amount": {
      "total": "238.00",
      "without_vat": "200.00",
      "vat": "38.00",
      "currency": "RON"
    },
    "vat_percent": 19,
    "with_vat": true,
    "date": "2024-01-15",
    "due_date": "2024-02-15",
    "paid_date": "2024-01-20",
    "is_paid": true,
    "payment_type": {
      "id": 2,
      "name": "Bank transfer"
    },
    "status": "paid",
    "supplier_id": "sup_xyz789",
    "category_id": 1,
    "user_id": 1,
    "created_at": "2024-01-15 10:30:00",
    "updated_at": "2024-01-20 14:30:00"
  },
  "message": "Expense marked as paid successfully"
}

Use Cases

Bulk Payment Processing

When processing multiple payments (e.g., from bank statements), you can use this endpoint to mark individual expenses as paid:
JavaScript
const payments = [
  { expenseId: 'exp_abc123', date: '2024-01-20', type: 2 },
  { expenseId: 'exp_def456', date: '2024-01-21', type: 1 },
];

for (const payment of payments) {
  await markExpensePaid(payment.expenseId, payment.date, payment.type);
}

Integration with Banking APIs

This endpoint is ideal for integrating with banking APIs that provide transaction data:
JavaScript
// Process bank transactions and mark corresponding expenses as paid
bankTransactions.forEach(async (transaction) => {
  const expense = findMatchingExpense(transaction);
  if (expense) {
    await markExpensePaid(expense.id, transaction.date, getPaymentType(transaction.type));
  }
});

Manual Payment Entry

For manual payment entry in accounting workflows:
JavaScript
const recordPayment = async (expenseId, paymentDetails) => {
  try {
    const result = await markExpensePaid(expenseId, paymentDetails.date, paymentDetails.method);
    showSuccessMessage('Payment recorded successfully');
    refreshExpenseList();
  } catch (error) {
    showErrorMessage('Failed to record payment: ' + error.message);
  }
};

Authorizations

Authorization
string
header
required

Use your API key (sk_live_xxx or sk_test_xxx)

Path Parameters

id
string
required

Expense CzUid

Body

application/json
paid_date
string<date>
required

Payment date

payment_type
integer
required

Payment method (1-7)

Required range: 1 <= x <= 7

Response

Expense marked as paid

success
boolean
data
object
meta
object