Users
Users are your site’s users, addressed by your own id: the sub of the client token, called external_id in the API. mondochat stores a display name, avatar, language and role, never an email.
Before you start
Section titled “Before you start”-
An app with an active server secret. Every call below sends two headers:
Authorization: Bearer <mcs_ server secret>Mondochat-App-Id: <app id> -
Roles that exist in the app’s settings, if you pass
role. See Settings overview. -
For export and delete, a webhook endpoint that listens for
user.exportedanduser.deleted. See Webhooks overview.
-
Create or update a user without a browser, for example so others can open a conversation with them before they ever sign in.
nameis required.avatar(https),role,lang,permsandtierare optional.Terminal window curl -X PUT https://app.mondochat.io/v1/server/users/bob \-H "Authorization: Bearer $MONDOCHAT_SERVER_SECRET" -H "Mondochat-App-Id: $MONDOCHAT_APP_ID" \-H 'content-type: application/json' \-d '{"name": "Bob", "role": "member", "lang": "en"}'The answer is
{id, external_id, kind, role, name, avatar}.kindismemberorguest. A user also exists after their first session. An upsert alone sends nouser.createdwebhook: it goes out with the user’s first session, whether from an exchange,POST /v1/server/sessionsor an installed-app sign-in. An avatar the user uploaded wins overavatar, and an upsert never clears it. See Upsert a user. -
Read a user back with
GET /v1/server/users/{external_id}:Terminal window curl https://app.mondochat.io/v1/server/users/bob \-H "Authorization: Bearer $MONDOCHAT_SERVER_SECRET" -H "Mondochat-App-Id: $MONDOCHAT_APP_ID" -
Export a user’s data. The call answers 202 with
{export_id}. When the export is ready, auser.exportedwebhook carries a download URL that works for 24 hours. The export is a zip in S3 with a JSON file (profile, conversations, messages, purchases and reports by the user) and the user’s photos.Terminal window curl -X POST https://app.mondochat.io/v1/server/users/bob/export \-H "Authorization: Bearer $MONDOCHAT_SERVER_SECRET" -H "Mondochat-App-Id: $MONDOCHAT_APP_ID" \-H 'Idempotency-Key: export-bob-1'See Export a user.
-
Delete a user. The call answers 202. The user and their data are deleted within 24 hours, then a
user.deletedwebhook is sent.Terminal window curl -X DELETE https://app.mondochat.io/v1/server/users/bob \-H "Authorization: Bearer $MONDOCHAT_SERVER_SECRET" -H "Mondochat-App-Id: $MONDOCHAT_APP_ID"Deletion removes the user’s messages, photos, IPs and profile fields. The row stays as a tombstone so conversations keep their shape: the peer sees “deleted user” and only their own messages. The open frame gets
session.revokedwith reasondeleted, and the user’s devices are deleted. See Delete a user. -
Revoke a user’s installed-app devices when they lose chat access. The call answers 204, or 404 for an unknown user:
Terminal window curl -X DELETE https://app.mondochat.io/v1/server/users/bob/devices \-H "Authorization: Bearer $MONDOCHAT_SERVER_SECRET" -H "Mondochat-App-Id: $MONDOCHAT_APP_ID"Their sessions stop refreshing within 15 minutes. See Installed app and Revoke devices.
-
Let users manage their own profile from the chat or a headless client. With a session token,
GET /v1/mereturns the user andPATCH /v1/mechanges these fields. A field left out is unchanged, and any other value answers 422.Field Values Effect langen,it,es,frThe user’s interface language. last_seeneveryoneornobodynobodyhides the user’s last seen from everyone and everyone’s from them.onlinestays visible.read_receiptstrueorfalsefalsestops read ticks both ways.inboundeveryoneormembersmembersrefuses guests. It needsworkspace.inboundand a member that is not guest-like, else 403policy_deniedwith reasoninbound.New users have
last_seen: everyone,read_receipts: trueandinbound: everyone. Webhooks carry the reallast_seen_atand read pointer whatever these choices say, because they go to your server and not to peers. Withchat.avatar_uploadon, a user uploads a picture that photo moderation checks before it shows.
Check it works
Section titled “Check it works”- The upsert answers 200 with the user, and
GETreturns the sameexternal_id. - After step 3, your endpoint receives
user.exportedwith aurlandexpires_at. After step 4, it receivesuser.deletedwith theexternal_id. - After step 4, the peer’s inbox shows “deleted user”.
When it fails
Section titled “When it fails”| Answer | Cause |
|---|---|
401 unauthorized |
The secret or the app id is missing, wrong or revoked. |
404 not_found |
The user does not exist in this app. Ids from another app answer 404 too. |
409 idempotency_conflict |
The same Idempotency-Key was sent with a different body. |
422 validation |
A field is missing or malformed, for example a role that is not in the app’s settings. errors lists each one. |
403 forbidden with reason test_user_limit |
A tenant in test status accepts 50 users per app. |
Limits
Section titled “Limits”- Export and delete take an
Idempotency-Key. A repeat with the same key within 24 hours returns the first answer withIdempotent-Replayed: true. - A deletion finishes within 24 hours, not at once.
- An export URL works for 24 hours.
- After a hard delete, a client that holds an old sync cursor for an affected conversation gets 410
gonewith reasonstale_cursorand reloads. See Sync and recovery. retention.messages_days,retention.photos_daysandretention.ip_log_days(default 90) delete old data on their own. See Settings reference.