Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/azahel79/Spartans-gym/llms.txt

Use this file to discover all available pages before exploring further.

The Plans API manages the membership tiers offered by Spartans Gym. Each plan defines a name, price, billing period, and display color used by the front-end. Because plans are referenced by name when enrolling or renewing clients, they use a soft-delete strategy — deactivated plans remain in the database and on existing client records but are hidden from the active list. All endpoints require a valid Bearer token; only admin users may create, modify, or deactivate plans.

The Plan Object

id
string
required
UUID. Unique identifier for the plan.
name
string
required
Human-readable plan name (e.g. "Mensual", "Trimestral"). Must be unique across all plans, including inactive ones.
price
number
required
Price of the plan in MXN. Returned as a JavaScript number (the underlying database type is Decimal(10,2)).
period
string
required
Billing period string. Common values: "Mes", "3 Meses", "6 Meses", "Año". The enrollment and renewal logic parses this value to determine how many months to add to the expiry date.
color
string
required
Tailwind CSS class used by the front-end to colour-code this plan’s badge (e.g. "bg-primary").
isActive
boolean
required
true for available plans; false for soft-deleted plans. The GET /api/plans list endpoint only returns plans where isActive is true.
createdAt
string
required
ISO 8601 datetime when the plan was created.
updatedAt
string
required
ISO 8601 datetime when the plan was last modified.

Endpoints

List Active Plans

Requires a valid Bearer token. Accessible to all roles (admin and recepcionista).
Returns all plans where isActive is true, sorted by price ascending. Inactive (soft-deleted) plans are never included in this response.
GET /api/plans
Success Response — 200 OK
{
  "success": true,
  "data": [
    {
      "id": "c1d2e3f4-...",
      "name": "Mensual",
      "price": 499,
      "period": "Mes",
      "color": "bg-primary",
      "isActive": true,
      "createdAt": "2025-01-01T00:00:00.000Z",
      "updatedAt": "2025-01-01T00:00:00.000Z"
    },
    {
      "id": "d2e3f4g5-...",
      "name": "Trimestral",
      "price": 1200,
      "period": "3 Meses",
      "color": "bg-secondary",
      "isActive": true,
      "createdAt": "2025-01-01T00:00:00.000Z",
      "updatedAt": "2025-01-01T00:00:00.000Z"
    }
  ]
}
Error Responses
StatusDescription
401Missing or invalid Bearer token.
500Internal server error.

Get Plan by ID

Requires a valid Bearer token. Accessible to all roles.
Retrieves a single plan by its UUID. Returns both active and inactive plans.
GET /api/plans/:id
Path Parameters
id
string
required
UUID of the plan to retrieve.
Success Response — 200 OK Returns a single Plan object wrapped in data. Error Responses
StatusDescription
401Missing or invalid Bearer token.
404No plan found with the given ID.
500Internal server error.

Create Plan

Requires role admin only.
Creates a new active membership plan. The name must be unique — if a plan with that name already exists (active or inactive), the request is rejected with 400.
POST /api/plans
Request Body
name
string
required
Unique plan name. This value is stored directly on Client records when a member enrolls, so choose something descriptive (e.g. "Semestral").
price
number
required
Plan price in MXN.
period
string
Billing period. Defaults to "Mes" if omitted. The enrollment logic understands numeric prefixes ("3 Meses", "6 Meses") and keywords ("anual", "trimestral", "semestral").
color
string
Tailwind CSS class for the plan badge. Defaults to "bg-primary" if omitted.
Success Response — 201 Created
{
  "success": true,
  "data": {
    "id": "e3f4g5h6-...",
    "name": "Semestral",
    "price": 2499,
    "period": "6 Meses",
    "color": "bg-accent",
    "isActive": true,
    "createdAt": "2025-07-16T14:00:00.000Z",
    "updatedAt": "2025-07-16T14:00:00.000Z"
  }
}
Error Responses
StatusDescription
400name or price missing, or a plan with that name already exists.
401Missing or invalid Bearer token.
403User is not an admin.
500Internal server error.
curl -X POST https://api.example.com/api/plans \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Semestral",
    "price": 2499,
    "period": "6 Meses",
    "color": "bg-accent"
  }'

Update Plan

Requires role admin only.
Partially updates an existing plan. Supply only the fields you wish to change. If name is provided and differs from the current name, the server checks for a duplicate before saving.
PUT /api/plans/:id
Path Parameters
id
string
required
UUID of the plan to update.
Request Body (all fields optional)
name
string
New unique plan name. Returns 400 if a different plan already uses this name.
price
number
Updated price in MXN.
period
string
Updated billing period string (e.g. "3 Meses", "Año").
color
string
Updated Tailwind CSS class.
isActive
boolean
Setting this to false effectively deactivates the plan (same result as DELETE /api/plans/:id). Setting it to true re-activates a previously deactivated plan.
Success Response — 200 OK Returns the full updated Plan object inside data. Error Responses
StatusDescription
400Another plan already uses the requested name.
401Missing or invalid Bearer token.
403User is not an admin.
404No plan found with the given ID.
500Internal server error.

Delete Plan

Requires role admin only.
This is a soft delete. The plan record is not physically removed from the database — its isActive flag is set to false. Existing client records that reference the plan by name are unaffected. The plan will no longer appear in GET /api/plans (which only returns isActive: true plans), and it will be rejected if passed as a plan value when enrolling or renewing a client. You can reverse a soft delete by calling PUT /api/plans/:id with { "isActive": true }.
Deactivates a membership plan by setting isActive to false.
DELETE /api/plans/:id
Path Parameters
id
string
required
UUID of the plan to deactivate.
Success Response — 200 OK
{
  "success": true,
  "message": "Plan eliminado correctamente"
}
Error Responses
StatusDescription
401Missing or invalid Bearer token.
403User is not an admin.
404No plan found with the given ID.
500Internal server error.
curl -X DELETE https://api.example.com/api/plans/e3f4g5h6-... \
  -H "Authorization: Bearer <token>"

Build docs developers (and LLMs) love