Developers

Messenger API (your own chat screen)

Build a native support chat in your app — your own design, the customer writes, your team answers in the inbox.

The Messenger API is what the Shopxare Messenger itself uses. With it you can draw the chat in your own app's design — a native screen in Swift, Kotlin, React Native or Flutter — while your team works in the Shopxare inbox as usual. The customer writes as themselves, sees your team's replies live and gets push notifications.

Prefer the ready-made screen? The mobile SDKs open the full Messenger in a few lines. Writing from your server instead of the phone? Use the REST API.

  • Base URL: https://app.shopxare.com/widget/api/v1
  • Format: JSON in, JSON out. Times are ISO 8601 in UTC.
  • Your app id: in Settings → Messenger → Install.

Sign the customer in

Start every session with POST /boot. Send the customer's id and the user hash from identity verification — compute it on your server, never in the app — and platform (ios or android):

curl -X POST https://app.shopxare.com/widget/api/v1/boot \
  -H "Content-Type: application/json" \
  -d '{"app_id": "YOUR_APP_ID", "platform": "ios",
       "user": {"user_id": "42", "user_hash": "…", "email": "[email protected]", "name": "Ada"}}'

The answer holds a session token (sxv_…), the customer (contact), their recent conversations, the Messenger texts and settings, and the realtime connection details. Keep the token (e.g. in the Keychain) and send it back as token on the next boot to continue the same session. A boot without user starts an anonymous visitor. The same person signing in on another phone, or on your website, sees the same conversations.

Every other call carries the token:

Authorization: Bearer sxv_…

Endpoints

Method Path What it does
GET /conversations the customer's conversations, newest first
POST /conversations start a conversation: client_id (a UUID you create), body, optional attachment_ids
GET /conversations/{id}/messages after_seq=N for everything after message N, or the latest 50 (before_seq for older)
POST /conversations/{id}/messages send a message: client_id, body, optional attachment_ids
POST /attachments upload a file (multipart, field file) — when attachments are on in Settings → Messenger
POST /conversations/{id}/receipts seq and read: true — the customer has seen the team's messages up to seq
POST /conversations/{id}/rating rating 1–5 and an optional comment, for a closed conversation
POST /contact update the customer's name, email or phone
POST /events track an event: name, optional meta
POST /push/devices register the phone for push: platform (ios, android) and token
DELETE /push/devices unregister: token
POST /shutdown on logout: ends the session and unregisters the phone

Start a conversation

curl -X POST https://app.shopxare.com/widget/api/v1/conversations \
  -H "Authorization: Bearer sxv_…" -H "Content-Type: application/json" \
  -d '{"client_id": "8b0d4c1e-…", "body": "My parcel has not arrived"}'

The conversation reaches the inbox like one from the Messenger: assignment rules, office hours, the AI agent and workflows apply. Sending again with the same client_id never creates a second conversation or message — so retry freely after a network error.

Messages

Each message has seq (its position: 1, 2, 3 …), client_id, body, attachments, created_at and author — {"type": "contact"} for the customer, user for a teammate and bot for the AI agent (both with a name). Internal notes never reach this API.

Live updates

Replies arrive over a WebSocket that speaks the Pusher protocol, so any Pusher client library works (pusher-js, PusherSwift, pusher-websocket-java, pusher_channels_flutter):

  • Server: realtime.scheme, realtime.host and realtime.path from the boot answer, key realtime.key.
  • Channel: private-contact.{contact.id}.
  • Authorization: POST /broadcasting/auth with socket_id and channel_name, carrying the session token.
Event Data
message.created conversation_id, message, conversation
message.updated conversation_id, message (e.g. a reaction)
message.deleted conversation_id, seq
conversation.updated conversation (status, assignee, rating …)
conversation.read the team has read the customer's messages

No WebSockets? GET /sync?after_id=…&version=… waits up to 20 seconds and returns as soon as something changes, with every new message. Start with the cursor and version from the boot answer and pass back what each answer returns. After the app returns from the background, catch up with GET /conversations/{id}/messages?after_seq=….

Push notifications

Add your APNs key and/or Firebase service account in Settings → Messenger → Install → Push notifications for your app, then register the phone with POST /push/devices. When your team or the AI agent answers, the phone gets a notification with the data shopxare: "1", conversation_id and seq — open that conversation when it is tapped. See mobile SDK for the provider setup.

Errors and limits

Errors are JSON with a code:

Status Code Meaning
401 visitor_token_invalid the session token is missing, wrong or expired: boot again
401 identity_verification_failed the user hash does not match (or identity verification is required and missing)
403 blocked the person is blocked in your workspace
403 origin_not_allowed a website not in the allowed domains (native apps send platform instead)
422 bot_check bot protection is on and asks for a solved challenge: send bot_check from the answer
429 — too many requests: 30 boots per minute per IP, 240 calls and 40 messages per minute per session

Still stuck? Contact