Skip to main content

PUT /api/accrued-expenses/:id

Updates an existing manual expense. Only expenses with tipo_origen: MANUAL can be updated. XML-imported expenses cannot be modified.

Authentication

This endpoint requires authentication. Include your access token in the request cookies.

Path Parameters

id
string
required
Unique identifier of the expense to update

Request Body

All fields are optional. Only include fields you want to update.
concept
string
Updated description or concept of the expense
subtotal
number
Updated subtotal amount before taxes
iva_amount
number
Updated IVA (VAT) amount
is_paid
boolean
Payment status of the expense
payment_date
string
Payment date in ISO 8601 format. Set to null to clear the payment date
categoria
string
Updated category. Set to null to clear the category

Response

message
string
required
Success message
data
Expense
required
The updated expense object

Example Request

curl -X PUT "https://api.contafy.com/api/accrued-expenses/expense-789" \
  -H "Content-Type: application/json" \
  -H "Cookie: access_token=your_access_token" \
  -d '{
    "concept": "Compra de papelería y suministros",
    "subtotal": 1200,
    "iva_amount": 192,
    "is_paid": true,
    "payment_date": "2024-03-20",
    "categoria": "Gastos de oficina"
  }'

Example Response

{
  "message": "Expense updated successfully",
  "data": {
    "id": "expense-789",
    "profile_id": "profile-123",
    "tipo_origen": "MANUAL",
    "fecha": "2024-03-15T00:00:00Z",
    "mes": 3,
    "año": 2024,
    "total": 1392,
    "subtotal": 1200,
    "iva": 16,
    "iva_amount": 192,
    "is_paid": true,
    "payment_date": "2024-03-20T00:00:00Z",
    "concepto": "Compra de papelería y suministros",
    "categoria": "Gastos de oficina",
    "created_at": "2024-03-15T10:30:00Z",
    "updated_at": "2024-03-20T14:25:00Z"
  }
}

Error Responses

401 Unauthorized
error
Authentication required or token expired
{
  "error": "Unauthorized",
  "message": "Authentication required"
}
400 Bad Request
error
Invalid request body or attempting to update an XML expense
{
  "error": "Bad Request",
  "message": "Cannot update XML-imported expenses"
}
403 Forbidden
error
User does not have permission to update this expense
{
  "error": "Forbidden",
  "message": "You do not have permission to update this expense"
}
404 Not Found
error
Expense not found
{
  "error": "Not Found",
  "message": "Expense not found"
}
500 Internal Server Error
error
Server error occurred
{
  "error": "Internal Server Error",
  "message": "An unexpected error occurred"
}