POST /api/accrued-expenses
Creates a new manual expense entry for a specific profile and period. This endpoint is used for expenses that are not imported from XML files.
Authentication
This endpoint requires authentication. Include your access token in the request cookies.
Request Body
ID of the profile (RFC emisor) to associate this expense with
ID of the accounting period for this expense
Description or concept of the expense
Subtotal amount before taxes
IVA (VAT) amount. If not provided, defaults to 0
Date of the expense in ISO 8601 format (e.g., “2024-03-15”)
Type of expense. Must be manual
Category for organizing the expense
Response
The created expense object
Unique identifier for the expense
Profile ID associated with this expense
Origin type. Will be MANUAL
Date of the expense (ISO 8601 format)
Month extracted from fecha (1-12)
Year extracted from fecha
Total amount (subtotal + iva_amount)
IVA percentage calculated from amounts
Description/concept of the expense
Creation timestamp (ISO 8601)
Last update timestamp (ISO 8601)
Example Request
curl -X POST "https://api.contafy.com/api/accrued-expenses" \
-H "Content-Type: application/json" \
-H "Cookie: access_token=your_access_token" \
-d '{
"profile_id": "profile-123",
"period_id": "period-456",
"concept": "Compra de papelería",
"subtotal": 1000,
"iva_amount": 160,
"fecha": "2024-03-15",
"type": "manual",
"categoria": "Gastos de oficina"
}'
Example Response
{
"message": "Expense created successfully",
"data": {
"id": "expense-789",
"profile_id": "profile-123",
"tipo_origen": "MANUAL",
"fecha": "2024-03-15T00:00:00Z",
"mes": 3,
"año": 2024,
"total": 1160,
"subtotal": 1000,
"iva": 16,
"iva_amount": 160,
"concepto": "Compra de papelería",
"categoria": "Gastos de oficina",
"created_at": "2024-03-15T10:30:00Z",
"updated_at": "2024-03-15T10:30:00Z"
}
}
Error Responses
Authentication required or token expired{
"error": "Unauthorized",
"message": "Authentication required"
}
Invalid request body or missing required fields{
"error": "Bad Request",
"message": "Missing required field: concept"
}
User does not have permission to create expenses for this profile{
"error": "Forbidden",
"message": "You do not have permission to access this profile"
}
500 Internal Server Error
Server error occurred{
"error": "Internal Server Error",
"message": "An unexpected error occurred"
}