Skip to main content

What a User is

A User is a person in your application who sends and receives messages through Surge’s embeddable UI components. You create Users through the Surge API or the dashboard, and each one belongs to a specific account. They are separate from people who log in to hq.surge.app. If you’re building a SaaS platform where your customers interact with Surge-powered messaging, Users are typically your customers’ employees, not your customers’ own customers. Users are used in two ways:
  1. Embedded UI: the inbox and conversation components authenticate as a specific User, showing that user’s conversations and sending messages on their behalf
  2. Attribution: messages and calls can be tied to a User, so you can trace activity back to the individual
Users do not have Surge passwords or sessions. Authentication for embedded components goes through a short-lived JWT that your server generates.

Provision a User

Create a User via the API before you mount any components for them:
Store the returned id alongside the user’s record in your database. You’ll use it to generate component tokens and attribute messages.

Create a User in the dashboard

You can also create Users without writing code. In the Surge dashboard at hq.surge.app, open the account and select Embed users in the sidebar, then click New embed user. Enter a first name and an optional last name. Click Add metadata for each key-value pair you want to store, then click Create user. Copy the User ID from the user’s details page to use with the token endpoint.

Generate a component token

Your server generates a short-lived JWT for each user session. The JWT scopes the embedded component to that specific user’s data. The simplest path is the token endpoint:
Return this token to your frontend and use it to mount the component. Generate a new token on each page load because tokens are short-lived.

Typical vertical SaaS flow

  1. When one of your customer’s employees is added to your SaaS product, create a Surge User via POST /accounts/{account_id}/users. Store the id.
  2. When that employee loads a page in your app that includes embedded messaging, your server calls POST /users/{user_id}/tokens to get a fresh JWT.
  3. Your frontend receives the JWT and mounts the Surge Inbox or Conversation component with it.
  4. The component shows only that user’s conversations and sends messages attributed to them.

List and manage Users

The Embed users page in the dashboard covers the same tasks. Search by name or User ID, open a user to see their profile and metadata, and edit or delete them from the details page. To delete a User, click Delete user and type the user’s full name to confirm. Deleting a User removes their Surge record but does not delete message history.

Next steps

Inbox component

Mount a conversation list for the current User.

Conversation component

Mount a single threaded conversation view.

Unread Count component

Show a live unread badge in your navigation.