Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/gcsconsultores/centros-estrategicos-gcs/llms.txt

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

The /api/leads route captures prospect data submitted through the virtual office — whether via SallyChat’s conversational flow or the LeadFormModal component — and persists it to a SharePoint List through the Microsoft Graph API. Authentication against Graph uses an OAuth 2.0 client credentials grant scoped to the registered Azure AD application. In development environments where Microsoft 365 credentials are absent, the route logs the lead payload to stdout and still returns a 200 OK so the UI flow is never interrupted.

POST /api/leads

Request

PropertyValue
MethodPOST
Path/api/leads
Content-Typeapplication/json

Body Parameters

nombre
string
required
Full name of the contact submitting the lead.
email
string
required
Email address of the contact. Validated server-side with the regex /^[^\s@]+@[^\s@]+\.[^\s@]+$/ before any storage attempt.
empresa
string
required
Company or organisation name associated with the lead.
servicio
string
required
Service or room ID representing the area of interest — e.g. compliance, ejecutiva, sarlaft. Maps to the Servicio Choice column in SharePoint.
telefono
string
Optional contact phone number. Stored as an empty string in SharePoint when not provided.
mensaje
string
Optional free-text message or notes from the contact. Stored as an empty string in SharePoint when not provided.
origen
string
required
Source identifier describing where the lead was captured — e.g. "Oficina Virtual - Sala Ejecutiva". Used for attribution reporting in SharePoint.

Response

{
  "success": true,
  "message": "Lead registrado exitosamente",
  "id": "<sharepoint-item-id>",
  "storage": "sharepoint"
}

GET /api/leads

The GET handler is an admin info endpoint — it returns documentation metadata and does not expose stored lead data. Accessing real lead records requires authentication and direct SharePoint / Graph API access.
{
  "message": "Endpoint de administración de leads",
  "note": "Requiere autenticación. Los leads se almacenan en SharePoint.",
  "documentation": "/docs/api/leads"
}

SharePoint Integration

The route follows a two-step Microsoft Graph flow on every authenticated POST:
1

Obtain OAuth2 token

A client_credentials grant is posted to the Azure AD token endpoint:
POST https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/token

Content-Type: application/x-www-form-urlencoded

client_id=<AZURE_AD_CLIENT_ID>
&client_secret=<AZURE_AD_CLIENT_SECRET>
&scope=https://graph.microsoft.com/.default
&grant_type=client_credentials
If any credential is missing or the request fails, the route falls back to development mode immediately.
2

Create SharePoint list item

With a valid bearer token, the route posts to the target SharePoint list:
POST https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{listId}/items

Authorization: Bearer <token>
Content-Type: application/json
{
  "fields": {
    "Title": "<nombre>",
    "Email": "<email>",
    "Empresa": "<empresa>",
    "Telefono": "<telefono>",
    "Servicio": "<servicio>",
    "Mensaje": "<mensaje>",
    "Origen": "<origen>",
    "FechaCreacion": "<ISO 8601 timestamp>"
  }
}
The SharePoint item id returned in the response is surfaced back to the caller as "id".

Required SharePoint List Columns

Create these columns in your SharePoint List before enabling production storage. Column names are case-sensitive and must match exactly.
Column NameTypeMaps To
TitleTextnombre
EmailTextemail
EmpresaTextempresa
TelefonoTexttelefono
ServicioChoiceservicio
MensajeMultiline Textmensaje
OrigenTextorigen
FechaCreacionDateAuto-set to ISO 8601 timestamp at write time

Validation

The route validates the request body before attempting any external call:
  • Required fields: nombre, email, empresa, servicio — returns 400 with a descriptive message if any are absent.
  • Email format: validated with /^[^\s@]+@[^\s@]+\.[^\s@]+$/ — returns 400 if the format is invalid.
  • All other optional fields (telefono, mensaje) are stored as empty strings in SharePoint when not provided.

Error Responses

StatusDescription
400Missing one or more required fields (nombre, email, empresa, servicio)
400Invalid email format
500SharePoint API error or unexpected server error
Persistent storage requires all five environment variables: AZURE_AD_CLIENT_ID, AZURE_AD_CLIENT_SECRET, AZURE_AD_TENANT_ID, SHAREPOINT_SITE_ID, and SHAREPOINT_LIST_ID. Without them, leads are only logged to stdout and are lost on the next deployment or server restart.

Build docs developers (and LLMs) love