Skip to main content

GET /api/expenses

Retrieves a paginated list of expenses for the authenticated user with support for filtering by profile, date, category, and more.

Authentication

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

Query Parameters

profileId
string
Filter expenses by specific profile ID (RFC emisor)
mes
number
Filter by month (1-12)
año
number
Filter by year (e.g., 2024)
regimen_fiscal
string
Filter by fiscal regime
tipo
string
Filter by payment type. Options: PUE, PPD, COMPLEMENTO_PAGO
categoria
string
Filter by expense category
page
number
default:"1"
Page number for pagination
limit
number
default:"20"
Number of items per page
Search term to filter expenses by concept, RFC, or name

Response

data
Expense[]
Array of expense objects
pagination
object
required
Pagination information

Example Request

curl -X GET "https://api.contafy.com/api/expenses?page=1&limit=20&mes=3&año=2024" \
  -H "Cookie: access_token=your_access_token"

Example Response

{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "profile_id": "profile-123",
      "tipo_origen": "XML",
      "fecha": "2024-03-15T10:30:00Z",
      "mes": 3,
      "año": 2024,
      "total": 11600,
      "subtotal": 10000,
      "iva": 16,
      "iva_amount": 1600,
      "is_paid": true,
      "payment_date": "2024-03-15T10:30:00Z",
      "concepto": "Servicios de consultoría",
      "categoria": "Servicios profesionales",
      "uuid": "12345678-1234-1234-1234-123456789012",
      "tipo": "PUE",
      "rfc_emisor": "XAXX010101000",
      "nombre_emisor": "Proveedor Ejemplo SA de CV",
      "rfc_receptor": "CACX7605101P8",
      "nombre_receptor": "Mi Empresa",
      "created_at": "2024-03-15T10:35:00Z",
      "updated_at": "2024-03-15T10:35:00Z"
    }
  ],
  "pagination": {
    "total": 150,
    "page": 1,
    "limit": 20,
    "totalPages": 8
  }
}

Error Responses

401 Unauthorized
error
Authentication required or token expired
{
  "error": "Unauthorized",
  "message": "Authentication required"
}
400 Bad Request
error
Invalid query parameters
{
  "error": "Bad Request",
  "message": "Invalid month value. Must be between 1 and 12"
}
500 Internal Server Error
error
Server error occurred
{
  "error": "Internal Server Error",
  "message": "An unexpected error occurred"
}