Skip to main content
Authentication: Bearer JWT required
Required role: admin or cajero

POST /api/caja/gastos

Records an expense against the currently open register. Cash expenses (efectivo) reduce the physical cash on hand; QR expenses do not affect the cash drawer balance.

Request

Body

descripcion
string
required
Description of the expense, e.g. "Compra de gas para cocina". Maximum 200 characters.
metodo_pago
string
required
Payment method. Allowed values: efectivo, qr
monto
number
required
Expense amount in BOB (min: 0.01)

Response

Success (201)

id
number
Auto-incremented expense ID
caja_id
number
ID of the register this expense is linked to
usuario_id
string | null
ID of the user who recorded the expense
descripcion
string
Expense description
metodo_pago
string
Payment method: efectivo or qr
monto
number
Expense amount (BOB)
creado_en
string
Timestamp when the expense was created (ISO 8601)
actualizado_en
string | null
Timestamp of last update
borrado_en
string | null
Soft-delete timestamp — null for active records

Error responses

StatusDescription
400No register is currently open
401Unauthorized — missing or invalid JWT
403Forbidden — role is not admin or cajero

Example

curl -X POST http://localhost:3000/api/caja/gastos \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "descripcion": "Compra de gas para cocina",
    "metodo_pago": "efectivo",
    "monto": 50.00
  }'
{
  "id": 1,
  "caja_id": 1,
  "usuario_id": "usr_abc123",
  "descripcion": "Compra de gas para cocina",
  "metodo_pago": "efectivo",
  "monto": 50.00,
  "creado_en": "2026-02-04T10:30:00.000Z",
  "actualizado_en": "2026-02-04T10:30:00.000Z",
  "borrado_en": null
}

GET /api/caja/gastos/historial

Returns a list of the most recent expenses across all registers, ordered by creation date descending.

Request

Query parameters

limit
number
Maximum number of records to return (default: 50)

Response

Success (200)

Returns an array of expense objects. Each item has the same shape as the POST /api/caja/gastos success response.
[].id
number
Expense record ID
[].caja_id
number
Register ID this expense belongs to
[].usuario_id
string | null
ID of the user who recorded the expense
[].descripcion
string
Expense description
[].metodo_pago
string
Payment method: efectivo or qr
[].monto
number
Expense amount (BOB)
[].creado_en
string
Timestamp when the expense was created

Error responses

StatusDescription
401Unauthorized — missing or invalid JWT
403Forbidden — role is not admin or cajero

Example

curl "http://localhost:3000/api/caja/gastos/historial?limit=10" \
  -H "Authorization: Bearer <token>"
[
  {
    "id": 10,
    "caja_id": 3,
    "usuario_id": "usr_abc123",
    "descripcion": "Compra de insumos",
    "metodo_pago": "efectivo",
    "monto": 150.50,
    "creado_en": "2026-02-04T15:30:00.000Z",
    "actualizado_en": "2026-02-04T15:30:00.000Z",
    "borrado_en": null
  }
]

Build docs developers (and LLMs) love