Skip to main content
This guide maps the five M2M chat endpoints to real integration patterns. Use it to understand which endpoint to call when.

Quick reference

EndpointMethodPurposeResponse TimeUse When
Chat (Sync)POST /m2m/sites/{id}/chatSend message and get answer immediately5-60sCaller needs immediate answer
Chat (Async)POST /m2m/sites/{id}/chat/asyncSubmit message for background processing100msCaller should not block
Chat StatusGET /m2m/sites/{id}/chat/requests/{requestId}Check status of async request10msPolling async completion
Chat FeedbackPOST /m2m/sites/{id}/chat/feedbackRate the response quality100msImproving answer quality
Session ListGET /m2m/sites/{id}/sessionsList user conversations100msTracking sessions
Session ClosePOST /m2m/sites/{id}/chat/session/closeMark session as closed100msEnding conversation

Pattern 1: Synchronous chat (blocking)

Use when the user is waiting for the answer.
Typical latency: 5-30 seconds. Simple answers faster, complex queries slower. Example: Customer support chatbot in a web form.

Pattern 2: Asynchronous chat (non-blocking)

Use when you have a job queue or background processing system.
Typical latency: 100ms submit + 5-30 seconds processing + polling. Example: Background job processor, message queue consumer, webhook receiver.

Pattern 3: Collect feedback (quality monitoring)

Use after each completed response to track answer quality.
Example: Chat widget with thumbs up/down buttons.

Pattern 4: Retrieve conversation history

Use to look up past sessions for a user.
Example: Multi-session support ticket system.

Pattern 5: Close sessions explicitly

Use when a conversation ends (user resolution, timeout, etc.).
Example: Support ticket closure, conversation timeout.

Session strategy

Before using any chat endpoint, define your session_id strategy:

Option A: Per-user sessions

Best for chat applications where one user = one long conversation.
Characteristics:
  • One session per user account
  • Conversation history grows over time
  • Follow-up questions maintain context
  • Close explicitly when user logs out

Option B: Per-thread sessions

Best for ticket or thread-based systems.
Characteristics:
  • One session per support ticket
  • Clear conversation boundaries
  • Easy to archive
  • Close when ticket resolved

Option C: Per-channel sessions

Best for multi-channel integrations (email, slack, etc.).
Characteristics:
  • One session per channel + user combo
  • Separate context per channel
  • Can close after inactivity
  • Useful for omnichannel setups

Request/response flow

Sync chat flow

Async chat flow

Feedback flow

Common patterns

Pattern: “Sync with fallback”

Try sync chat first, fall back to a template answer if it times out.

Pattern: “Async with webhook”

Submit async chat and notify via webhook when complete.

Error handling checklist

✓ Treat 400 as a payload error (fix request)
✓ Treat 401 as auth failure (check key, rotation)
✓ Treat 403 as access denied (check plan/permissions)
✓ Treat 404 as resource not found (check IDs)
✓ Retry 429 and 5xx with exponential backoff
✓ Don’t retry 4xx (except 429) without fixing the request
✓ Async polling has an overall timeout
✓ User-facing errors are safe and don’t expose API details
See Error Handling Catalog for complete guidance.

Production readiness

Before deploying chat integrations: ✓ All HTTP calls have timeouts
✓ Retries are bounded and selective
✓ Session IDs are stable across requests
✓ Feedback collection is wired correctly
✓ Async polling respects timeouts
✓ Monitoring and alerting are configured
✓ Logs do not contain API keys
✓ User-facing errors are safe
✓ Staging smoke test passed