Skip to main content
GET
/
api
/
gastos-recurrentes
Recurring Expenses API
curl --request GET \
  --url https://api.example.com/api/gastos-recurrentes \
  --header 'Content-Type: application/json' \
  --data '
{
  "nombre": "<string>",
  "dia_cobro": 123,
  "monto": 123,
  "activo": true,
  "id": "<string>"
}
'
{
  "data": [
    {
      "id": "<string>",
      "nombre": "<string>",
      "dia_cobro": 123,
      "monto": 123,
      "activo": true,
      "categoria": "<string>",
      "metodo_pago": "<string>",
      "cuenta": "<string>",
      "ultima_ejecucion": "<string>",
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ]
}

Overview

The Recurring Expenses API manages monthly subscriptions and recurring charges. It provides full CRUD (Create, Read, Update, Delete) operations for tracking regular monthly expenses like subscriptions, rent, utilities, and other recurring payments.

Authentication

This endpoint uses Supabase authentication. Ensure your requests include valid authentication headers.

Database Schema

The API reads from the gastos_mensuales table and maps fields to a frontend-friendly format.

GET - List Recurring Expenses

Endpoint

GET /api/gastos-recurrentes

Response

data
array
Array of recurring expense objects, ordered by billing day (ascending).
id
string
Unique identifier for the recurring expense
nombre
string
Name of the subscription/recurring expense (e.g., “Netflix”, “Spotify”)
dia_cobro
number
Day of month when charge occurs (1-31)
monto
number
Monthly charge amount in MXN
activo
boolean
Whether the recurring expense is active
categoria
string
Category (defaults to “Suscripciones”)
metodo_pago
string
Payment method (defaults to “Tarjeta”)
cuenta
string
Associated account (currently null)
ultima_ejecucion
string
Last execution timestamp (currently null)
created_at
string
Creation timestamp in ISO 8601 format
updated_at
string
Last update timestamp in ISO 8601 format

Example Response

{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "nombre": "Netflix",
      "dia_cobro": 5,
      "monto": 219.00,
      "activo": true,
      "categoria": "Suscripciones",
      "metodo_pago": "Tarjeta",
      "cuenta": null,
      "ultima_ejecucion": null,
      "created_at": "2024-01-15T10:00:00Z",
      "updated_at": "2024-01-15T10:00:00Z"
    },
    {
      "id": "550e8400-e29b-41d4-a716-446655440001",
      "nombre": "Spotify",
      "dia_cobro": 12,
      "monto": 119.00,
      "activo": true,
      "categoria": "Suscripciones",
      "metodo_pago": "Tarjeta",
      "cuenta": null,
      "ultima_ejecucion": null,
      "created_at": "2024-01-20T14:30:00Z",
      "updated_at": "2024-01-20T14:30:00Z"
    }
  ]
}

POST - Create Recurring Expense

Endpoint

POST /api/gastos-recurrentes

Request Body

nombre
string
required
Name of the subscription/recurring expenseExample: "Amazon Prime"
dia_cobro
number
required
Day of month when charge occurs (1-31)Example: 15
monto
number
required
Monthly charge amount in MXNExample: 99.00
activo
boolean
default:"true"
Whether the recurring expense is active

Example Request

{
  "nombre": "Disney+",
  "dia_cobro": 10,
  "monto": 159.00,
  "activo": true
}

Example Response

{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440002",
      "nombre": "Disney+",
      "dia_cobro": 10,
      "monto": 159.00,
      "activo": true,
      "categoria": "Suscripciones",
      "metodo_pago": "Tarjeta",
      "cuenta": null,
      "ultima_ejecucion": null,
      "created_at": "2024-03-06T15:45:00Z",
      "updated_at": "2024-03-06T15:45:00Z"
    }
  ]
}

PUT - Update Recurring Expense

Endpoint

PUT /api/gastos-recurrentes

Request Body

id
string
required
ID of the recurring expense to update
nombre
string
Updated name
dia_cobro
number
Updated billing day (1-31)
monto
number
Updated amount
activo
boolean
Updated active status

Example Request

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "nombre": "Netflix Premium",
  "dia_cobro": 5,
  "monto": 299.00,
  "activo": true
}

Example Response

{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "nombre": "Netflix Premium",
      "dia_cobro": 5,
      "monto": 299.00,
      "activo": true,
      "categoria": "Suscripciones",
      "metodo_pago": "Tarjeta",
      "cuenta": null,
      "ultima_ejecucion": null,
      "created_at": "2024-01-15T10:00:00Z",
      "updated_at": "2024-03-06T16:00:00Z"
    }
  ]
}

DELETE - Remove Recurring Expense

Endpoint

DELETE /api/gastos-recurrentes?id={id}

Query Parameters

id
string
required
ID of the recurring expense to delete

Example Response

{
  "success": true
}

Code Examples

const response = await fetch('/api/gastos-recurrentes');
const { data } = await response.json();

console.log(`Found ${data.length} recurring expenses`);
data.forEach(expense => {
  console.log(`${expense.nombre}: $${expense.monto} on day ${expense.dia_cobro}`);
});

Field Mapping

The API maps database fields to frontend-friendly names:
Database FieldAPI FieldTypeNotes
nombre_appnombrestringSubscription/expense name
dia_de_cobrodia_cobronumberBilling day (1-31)
montomontonumberMonthly amount
activoactivobooleanActive status
The categoria field defaults to “Suscripciones” and metodo_pago defaults to “Tarjeta” for all recurring expenses. These values are mapped from the database schema.

Use Cases

  • Subscription Management: Track Netflix, Spotify, and other monthly subscriptions
  • Recurring Bills: Monitor rent, utilities, insurance payments
  • Budget Planning: Calculate total monthly recurring expenses
  • Automated Reminders: Use dia_cobro to set up payment reminders
  • Expense Forecasting: Project future monthly expenses based on active recurring charges

Build docs developers (and LLMs) love