web-chat-public

Endpoints públicos consumidos por el widget JS desde el navegador del visitante.

Base path: /web-chat/:token·11 endpoints·Source: mosend-wb-backend/src/modules/web-chat/web-chat-public.controller.ts
POST/web-chat/:token/sessions
bearer

Público (widget): crea sesión del visitante (anónima, identificada o verify-OTP).

Path params

  • tokenstringrequerido

Body (JSON)

  • visitorIdstringrequerido
  • modestringrequerido
    anonymousidentifiedverify-otphost-identified
  • namestring
  • emailstring · email
  • phonestring
  • avatarUrlstring · uri

    Foto del visitante que el sitio host puede pasar por identify (p.ej. data-user-avatar). Se cachea en S3 y se expone en el inbox.

  • otpstring
  • acceptOfflineboolean

    El visitante confirmó "dejar mensaje de todos modos" fuera de horario. Solo surte efecto si el canal usa offlineAction = MESSAGE_ALLOW.

  • userIdstring
  • hashstring

    HMAC-SHA256 hex de `userId || email`, firmado con `WebChatChannel.identitySecret`.

  • attributesobject

    Atributos custom del host (plan, role, etc.) — van a visitor.metadata.host.

  • departmentIdstring
  • prechatobject

    Respuestas del prechat dinámico: { fieldId: value }.

  • urlstring

    Datos del navegador / contexto.

  • refererstring
  • titlestring
  • langstring
  • utmobject

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/sessions' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>' \
  -H 'Content-Type: application/json' \
  -d '{"visitorId": "00000000-0000-0000-0000-000000000000","mode": "anonymous","name": "<name>","email": "persona@empresa.com","phone": "<phone>","avatarUrl": "https://tu-app.com/endpoint","otp": "<otp>","acceptOffline": true,"userId": "00000000-0000-0000-0000-000000000000","hash": "<hash>","attributes": {},"departmentId": "00000000-0000-0000-0000-000000000000","prechat": {},"url": "https://tu-app.com/endpoint","referer": "<referer>","title": "<title>","lang": "<lang>","utm": {}}'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "name": "string",
    "description": "string"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
POST/web-chat/:token/sessions/resend-otp
bearer

Público (widget): reenvía el código OTP de verificación por email.

Path params

  • tokenstringrequerido

Body (JSON)

  • emailstring · emailrequerido

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/sessions/resend-otp' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>' \
  -H 'Content-Type: application/json' \
  -d '{"email": "persona@empresa.com"}'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "name": "string",
    "description": "string"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
POST/web-chat/:token/presence
bearer

Público (widget): presencia del visitante (sendBeacon).

Path params

  • tokenstringrequerido

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/presence' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "createdAt": "2026-05-01T03:42:18.123Z"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
GET/web-chat/:token/push/vapid
bearer

Público: clave VAPID pública para Web Push.

Path params

  • tokenstringrequerido

Respuestas

  • 200
curl -X GET 'https://api.mosend.dev/web-chat/<token>/push/vapid' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "createdAt": "2026-05-01T03:42:18.123Z"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
POST/web-chat/:token/push/subscribe
bearer

Público (widget): registra la suscripción Web Push del visitante.

Path params

  • tokenstringrequerido

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/push/subscribe' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "createdAt": "2026-05-01T03:42:18.123Z"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
POST/web-chat/:token/push/unsubscribe
bearer

Público (widget): elimina la suscripción Web Push.

Path params

  • tokenstringrequerido

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/push/unsubscribe' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "createdAt": "2026-05-01T03:42:18.123Z"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
GET/web-chat/:token/history
bearer

Público (widget): historial reciente del visitante (requiere visitor JWT).

Path params

  • tokenstringrequerido

Query params

  • beforestring
  • limitstring

Respuestas

  • 200
curl -X GET 'https://api.mosend.dev/web-chat/<token>/history' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "createdAt": "2026-05-01T03:42:18.123Z"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
POST/web-chat/:token/sessions/link-email
bearer

Público (widget): vincula un email al visitante (requiere visitor JWT).

Path params

  • tokenstringrequerido

Body (JSON)

  • emailstring · emailrequerido
  • namestring

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/sessions/link-email' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>' \
  -H 'Content-Type: application/json' \
  -d '{"email": "persona@empresa.com","name": "<name>"}'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "name": "string",
    "description": "string"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
POST/web-chat/:token/client-error
bearer

Público (widget): reporta un error de runtime del widget.

Path params

  • tokenstringrequerido

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/client-error' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "createdAt": "2026-05-01T03:42:18.123Z"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
POST/web-chat/:token/upload
bearer

Público (widget): sube un adjunto y devuelve su mediaAssetId (requiere visitor JWT).

Path params

  • tokenstringrequerido

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/upload' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "createdAt": "2026-05-01T03:42:18.123Z"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}
POST/web-chat/:token/messages
bearer

Público (widget): envía un mensaje con adjunto del visitante (requiere visitor JWT).

Path params

  • tokenstringrequerido

Respuestas

  • 201
curl -X POST 'https://api.mosend.dev/web-chat/<token>/messages' \
  -H 'X-Api-Key: mk_live_<prefix>.<secret>'
Response · 200
{
  "data": {
    "id": "00000000-0000-0000-0000-000000000000",
    "createdAt": "2026-05-01T03:42:18.123Z"
  },
  "timestamp": "2026-05-01T03:42:18.123Z"
}