Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/shadownrx/apisquare/llms.txt

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

The /api/admin/config endpoint manages the live bot configuration — the professionals and their weekly schedules, available services, and public holidays. Changes made through this endpoint take effect immediately; the Telegram bot reads the configuration fresh from Vercel KV on every incoming message without requiring a deployment or restart. Both methods require admin authentication via the admin_session cookie.

GET /api/admin/config

Returns the active configuration, merged with built-in defaults to guarantee all required fields are present.

Request

curl https://your-app.vercel.app/api/admin/config \
  -b cookies.txt

Response

HTTP 200
{
  "config": {
    "profesionales": {
      "Francisco Chibilisco": {
        "1": [{ "inicio": "11:00", "fin": "13:00" }],
        "2": [{ "inicio": "11:00", "fin": "13:00" }],
        "3": [{ "inicio": "11:00", "fin": "13:00" }],
        "4": [
          { "inicio": "11:00", "fin": "13:00" },
          { "inicio": "15:00", "fin": "20:00" }
        ],
        "5": [
          { "inicio": "11:00", "fin": "13:00" },
          { "inicio": "15:00", "fin": "20:00" }
        ],
        "6": [{ "inicio": "09:00", "fin": "13:00" }]
      },
      "Javier Martoni": {
        "1": [{ "inicio": "15:30", "fin": "20:00" }],
        "2": [{ "inicio": "15:30", "fin": "20:00" }],
        "3": [{ "inicio": "15:30", "fin": "20:00" }],
        "4": [{ "inicio": "15:30", "fin": "20:00" }],
        "5": [{ "inicio": "15:30", "fin": "20:00" }]
      }
    },
    "feriados": [],
    "servicios": [
      { "nombre": "Sesión de Quiropráctica", "duracionMinutos": 25, "precio": 30000 },
      { "nombre": "Masaje Relajante", "duracionMinutos": 45, "precio": 30000 },
      { "nombre": "Sesión Premium", "duracionMinutos": 60, "precio": 55000 }
    ]
  }
}
The response merges the stored configuration with the compiled-in DEFAULT_CONFIG. Professional entries from both the default and stored configs are combined via object spread ({...DEFAULT_CONFIG.profesionales, ...storedConfig.profesionales}), so every default professional is always present unless explicitly overridden. If the stored servicios array is empty, the default services list is used as a fallback.

Config object schema

config
object
The full bot configuration object.

Error responses

StatusBodyReason
401{ "error": "No autorizado" }Missing or invalid session cookie
500{ "error": "Error interno" }Unexpected server error

PUT /api/admin/config

Replaces the entire bot configuration stored in Vercel KV under the key app:config.
PUT replaces the entire configuration. Always GET the current config first, apply your changes to the returned object, and then PUT the modified version. Sending a partial object will erase any fields you omit.

Request

curl -X PUT https://your-app.vercel.app/api/admin/config \
  -b cookies.txt \
  -H "Content-Type: application/json" \
  -d '{
    "profesionales": {
      "Francisco Chibilisco": {
        "1": [{ "inicio": "11:00", "fin": "13:00" }],
        "4": [{ "inicio": "11:00", "fin": "13:00" }, { "inicio": "15:00", "fin": "20:00" }],
        "6": [{ "inicio": "09:00", "fin": "13:00" }]
      }
    },
    "feriados": ["2024-01-01", "2024-12-25"],
    "servicios": [
      { "nombre": "Sesión de Quiropráctica", "duracionMinutos": 25, "precio": 30000 },
      { "nombre": "Masaje Relajante", "duracionMinutos": 45, "precio": 30000 },
      { "nombre": "Sesión Premium", "duracionMinutos": 60, "precio": 55000 }
    ]
  }'

Request body

The full config object as described in the GET response schema. All three top-level fields are required.
profesionales
object
required
Map of professional name → weekly schedule. Same structure as returned by GET. Must be a non-null, non-array object.
feriados
array
required
Array of holiday date strings in YYYY-MM-DD format. Pass an empty array ([]) if there are no holidays.
servicios
array
required
Array of service objects ({ nombre, duracionMinutos, precio }). Must be a non-null array; passing an empty array will remove all bookable services from the bot.

Validation

The server checks that the request body contains all three required top-level keys before persisting:
  • profesionales must be present (truthy).
  • feriados must be present and be an array (Array.isArray).
  • servicios must be present and be an array (Array.isArray).
If any check fails, the server returns HTTP 400 with a Spanish error message.

Success response

HTTP 200
{
  "success": true,
  "config": { "...": "the exact config object you sent" }
}
success
boolean
Always true when the configuration was saved successfully.
config
object
The configuration object exactly as persisted to Vercel KV (mirrors the PUT request body).

Error responses

StatusBodyReason
400{ "error": "Estructura de configuración inválida" }Missing or wrong-typed top-level field
401{ "error": "No autorizado" }Missing or invalid session cookie
500{ "error": "Error interno" }Unexpected server error

Storage details

The configuration is persisted as a JSON string under the Vercel KV key app:config. No TTL is set — the value persists until the next PUT. In local development, when KV environment variables are absent, the config is stored in a server-side global variable (global._localAppConfig) and resets on process restart.
Because the Telegram bot reads app:config from KV on every incoming message, configuration changes applied via PUT take effect for the very next user interaction — no redeployment is required.

Build docs developers (and LLMs) love