web-chat-public
Endpoints públicos consumidos por el widget JS desde el navegador del visitante.
/web-chat/:token·11 endpoints·Source: mosend-wb-backend/src/modules/web-chat/web-chat-public.controller.ts/web-chat/:token/sessionsPúblico (widget): crea sesión del visitante (anónima, identificada o verify-OTP).
Path params
tokenstringrequerido
Body (JSON)
visitorIdstringrequeridomodestringrequeridoanonymousidentifiedverify-otphost-identifiednamestringemailstring · emailphonestringavatarUrlstring · uriFoto 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.
otpstringacceptOfflinebooleanEl visitante confirmó "dejar mensaje de todos modos" fuera de horario. Solo surte efecto si el canal usa offlineAction = MESSAGE_ALLOW.
userIdstringhashstringHMAC-SHA256 hex de `userId || email`, firmado con `WebChatChannel.identitySecret`.
attributesobjectAtributos custom del host (plan, role, etc.) — van a visitor.metadata.host.
departmentIdstringprechatobjectRespuestas del prechat dinámico: { fieldId: value }.
urlstringDatos del navegador / contexto.
refererstringtitlestringlangstringutmobject
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": {}}'{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "string",
"description": "string"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/sessions/resend-otpPú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"}'{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "string",
"description": "string"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/presencePú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>'
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"createdAt": "2026-05-01T03:42:18.123Z"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/push/vapidPú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>'
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"createdAt": "2026-05-01T03:42:18.123Z"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/push/subscribePú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>'
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"createdAt": "2026-05-01T03:42:18.123Z"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/push/unsubscribePú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>'
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"createdAt": "2026-05-01T03:42:18.123Z"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/historyPúblico (widget): historial reciente del visitante (requiere visitor JWT).
Path params
tokenstringrequerido
Query params
beforestringlimitstring
Respuestas
- 200
curl -X GET 'https://api.mosend.dev/web-chat/<token>/history' \ -H 'X-Api-Key: mk_live_<prefix>.<secret>'
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"createdAt": "2026-05-01T03:42:18.123Z"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/sessions/link-emailPúblico (widget): vincula un email al visitante (requiere visitor JWT).
Path params
tokenstringrequerido
Body (JSON)
emailstring · emailrequeridonamestring
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>"}'{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"name": "string",
"description": "string"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/client-errorPú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>'
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"createdAt": "2026-05-01T03:42:18.123Z"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/uploadPú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>'
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"createdAt": "2026-05-01T03:42:18.123Z"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}/web-chat/:token/messagesPú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>'
{
"data": {
"id": "00000000-0000-0000-0000-000000000000",
"createdAt": "2026-05-01T03:42:18.123Z"
},
"timestamp": "2026-05-01T03:42:18.123Z"
}