web-chat-public

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

Base path: /web-chat/:token·6 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
  • otpstring
  • 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>","otp": "<otp>","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"
}
GET/web-chat/:token/history
bearer

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

Path params

  • tokenstringrequerido

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/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"
}