Developer docs
Supprtly SDK install guide
Add the support widget to your web app, tell it who your users are, and (recommended) verify that identity so every ticket reliably shows which user and which customer account it came from.
Choose a setup level
The levels build on each other and match the toggles in Settings → Install. The same script tag works at every level; identity is added on top and is never required.
| Level | Settings → Install | Code needed | What you get |
|---|---|---|---|
| 1. Simple embed | Always on | One script tag. No other code. | Tickets with the name and email the user types, plus any capture data you enabled. |
| 2. Capture user & tenant info | Capture user & tenant info | Call Supprtly.identify() after sign-in and Supprtly.reset() on logout. | Every ticket shows the user and customer account it came from, marked Unverified. |
| 3. Verified identity (recommended for production) | Verify identity (+ optionally Block unverified tickets) | Your server signs a short-lived token; pass it to Supprtly.identify({ token }). | Tickets marked Verified, users see their recent tickets, and you can reject unverified tickets. |
Level 1: Simple embed
Copy your snippet from Settings → Install (it has your button's embed key) and paste it before the closing </body> tag.
<script src="https://app.supprtly.com/widget.js" data-embed="wgt_YOUR_EMBED_KEY" data-mode="widget" async></script>data-mode is widget (floating button), inline (renders where the tag is) or link. Without identify(), the form asks for the user's name and email.
Level 2: Capture user & tenant info
Turn on Capture user & tenant info in Settings → Install, then add the small queue snippet before the widget so Supprtly.identify() works even if it runs before the widget has loaded:
<script>
window.Supprtly = window.Supprtly || { q: [],
identify: function (o) { this.q.push(["identify", o]); },
reset: function () { this.q.push(["reset"]); } };
</script>
<script src="https://app.supprtly.com/widget.js" data-embed="wgt_YOUR_EMBED_KEY" data-mode="widget" async></script>After the user signs in, and on each page load while they're signed in, call Supprtly.identify():
// After your user signs in (and on every page load while signed in):
Supprtly.identify({
userId: user.id, // required
email: user.email,
name: user.name,
tenantId: account.id, // the customer account they belong to
tenantName: account.name,
plan: account.plan,
metadata: { role: user.role },
});"use client";
import { useEffect } from "react";
// Render once inside your signed-in layout, e.g. <SupprtlyIdentify user={user} account={account} />
export function SupprtlyIdentify({ user, account }: { user: User | null; account: Account | null }) {
useEffect(() => {
const supprtly = (window as any).Supprtly;
if (!supprtly) return;
if (!user) {
supprtly.reset();
return;
}
supprtly.identify({
userId: user.id,
email: user.email,
name: user.name,
tenantId: account?.id,
tenantName: account?.name,
plan: account?.plan,
});
}, [user?.id, account?.id]);
return null;
}
// Next.js: add the embed to app/layout.tsx with next/script, e.g.
// <Script id="supprtly-stub" strategy="beforeInteractive">{`window.Supprtly = window.Supprtly || { q: [], identify: function (o) { this.q.push(["identify", o]); }, reset: function () { this.q.push(["reset"]); } };`}</Script>
// <Script src="<widget.js URL from step 1>" data-embed="<embed key>" strategy="afterInteractive" />// e.g. in App.vue <script setup> or your auth store
import { watch } from "vue";
watch(
() => [auth.user, auth.account],
([user, account]) => {
if (!window.Supprtly) return;
if (!user) {
window.Supprtly.reset();
return;
}
window.Supprtly.identify({
userId: user.id,
email: user.email,
name: user.name,
tenantId: account?.id,
tenantName: account?.name,
plan: account?.plan,
});
},
{ immediate: true }
);| Field | Required | Description |
|---|---|---|
userId | Required | Your user's unique, stable ID. |
email | Optional | Used for replies; the form won't ask for it. |
name | Optional | Shown on the ticket; the form won't ask for it. |
tenantId | Optional | The customer account / workspace the user belongs to. |
tenantName | Optional | Readable name of that account. |
plan | Optional | The account's plan, e.g. "pro". |
metadata | Optional | Extra flat key/values (text, numbers, true/false). Max 20 keys, 2 KB. |
- Each call replaces the previous identity. Calls made before the widget loads are queued and applied in order.
- When the user is identified, the form doesn't ask for name and email again.
- Identity sent this way is shown as Unverified, because anyone using your page could change it. Use Level 3 in production.
- The widget never writes identity data or tokens to the browser console.
Supprtly.reset(): logout & switching tenants
Call Supprtly.reset() when the user logs out, and when they switch to another customer account or workspace (then call identify() again). It clears the stored identity and the widget's cached session data (console and network logs, session replay, pending screenshot and recent tickets), so the next ticket isn't filed under the previous user.
// When the user logs out:
Supprtly.reset();
// When the user switches to another account / workspace:
Supprtly.reset();
Supprtly.identify({ userId: user.id, email: user.email, tenantId: newAccount.id, tenantName: newAccount.name });Level 3: Verify identity (recommended for production)
- In Settings → Install, turn on Verify identity. An admin can reveal or copy the workspace's identity secret there.
- Store it only on your server, for example as the environment variable
SUPPRTLY_IDENTITY_SECRET. Never put it in frontend code, a mobile app, or a public repository. - Add an endpoint (for example
/api/supprtly-token) that, for the signed-in user, signs a short-lived HS256 JWT with that secret. - In your frontend, fetch the token and pass it to
Supprtly.identify({ token }).
Token claims
| Claim | Required | Description |
|---|---|---|
userId | Required | Your user's unique, stable ID (string). |
exp | Required | Expiry (Unix seconds). At most 24 hours after the token is issued. |
iat | Recommended | Issued-at time (Unix seconds). |
email | Optional | User's email (used for replies). |
name | Optional | User's display name. |
tenantId | Optional | The customer account / workspace the user belongs to. |
tenantName | Optional | Readable name of that account. |
plan | Optional | The account's plan. |
Signed claims override any plain fields passed to identify() alongside the token. metadata is not a claim; pass it to identify() as usual.
Sign the token on your server
// npm install jsonwebtoken
import jwt from "jsonwebtoken";
// Only for signed-in users (use your own auth middleware).
app.get("/api/supprtly-token", requireLogin, (req, res) => {
const token = jwt.sign(
{
userId: String(req.user.id), // required
email: req.user.email,
name: req.user.name,
tenantId: String(req.user.accountId),
tenantName: req.user.accountName,
plan: req.user.plan,
},
process.env.SUPPRTLY_IDENTITY_SECRET, // server-only secret, never in frontend code
{ algorithm: "HS256", expiresIn: "1h" } // max 24h
);
res.json({ token });
});// app/api/supprtly-token/route.ts (npm install jose)
import { SignJWT } from "jose";
export async function GET() {
const user = await getCurrentUser(); // your auth
if (!user) return new Response("Unauthorized", { status: 401 });
const token = await new SignJWT({
userId: String(user.id), // required
email: user.email,
name: user.name,
tenantId: String(user.accountId),
tenantName: user.accountName,
plan: user.plan,
})
.setProtectedHeader({ alg: "HS256" })
.setIssuedAt()
.setExpirationTime("1h") // max 24h
.sign(new TextEncoder().encode(process.env.SUPPRTLY_IDENTITY_SECRET!));
return Response.json({ token });
}# pip install pyjwt
import os, time, jwt
from fastapi import Depends
@app.get("/api/supprtly-token")
def supprtly_token(user = Depends(current_user)): # your auth dependency
now = int(time.time())
token = jwt.encode(
{
"userId": str(user.id), # required
"email": user.email,
"name": user.name,
"tenantId": str(user.account_id),
"tenantName": user.account_name,
"plan": user.plan,
"iat": now,
"exp": now + 3600, # max 24h
},
os.environ["SUPPRTLY_IDENTITY_SECRET"],
algorithm="HS256",
)
return {"token": token}
# Flask: same jwt.encode(...) call inside a @login_required route returning jsonify(token=token).<?php
// composer require firebase/php-jwt
use Firebase\JWT\JWT;
// Only for signed-in users (check your session first).
$now = time();
$token = JWT::encode([
'userId' => (string) $user->id, // required
'email' => $user->email,
'name' => $user->name,
'tenantId' => (string) $user->account_id,
'tenantName' => $user->account_name,
'plan' => $user->plan,
'iat' => $now,
'exp' => $now + 3600, // max 24h
], getenv('SUPPRTLY_IDENTITY_SECRET'), 'HS256');
header('Content-Type: application/json');
echo json_encode(['token' => $token]);Pass it to the widget
// After sign-in, and again before the token expires (e.g. every 50 minutes):
async function identifySupprtly() {
const res = await fetch("/api/supprtly-token", { credentials: "include" });
if (!res.ok) return;
const { token } = await res.json();
Supprtly.identify({ token }); // the signed details override any plain fields
}
identifySupprtly();
setInterval(identifySupprtly, 50 * 60 * 1000);Tokens can live at most 24 hours; refresh them before they expire (the example refreshes every 50 minutes).
Block unverified tickets
Once your first verified ticket has arrived, an admin can turn on Block unverified tickets. From then on, tickets without a valid token are rejected and the widget tells the user it couldn't verify their account. The API returns HTTP 401 with one of these codes:
| Code | Meaning |
|---|---|
IDENTITY_VERIFICATION_REQUIRED | Block unverified tickets is on and no token was sent. |
IDENTITY_TOKEN_INVALID | Bad signature, wrong algorithm (only HS256), missing userId/exp, or a lifetime over 24 h. |
IDENTITY_TOKEN_EXPIRED | The token's exp has passed. Fetch a new token and call identify() again. |
Recent tickets
Verified users see their recent tickets in the widget. Only tickets filed with a verified identity for the same userId and tenantId are shown.
Rotating the secret
Rotate the secret in Settings → Install if it may have leaked. The previous secret keeps working for 24 hours so you can deploy the new one without failed tickets.
What populates a ticket automatically
| Data | Source | When |
|---|---|---|
| Subject, description, category, custom fields | What the user enters in the form | Always |
| Name & email | Typed in the form, or taken from identify() (the form then skips them) | Always |
| User ID, email, name (reporter) | Supprtly.identify() or the signed token | Level 2+ |
| Tenant ID & tenant name | Supprtly.identify() or the signed token | Level 2+ |
| Plan & custom metadata | Supprtly.identify() (plan can also be a token claim) | Level 2+ |
| Verification status (Verified / Unverified) | Verified only when a valid signed token was sent | Level 2+ (Verified at level 3) |
| Page URL, browser, device | Captured by the widget | If enabled in the button's capture settings |
| Console & network errors | Captured by the widget (sensitive values redacted) | If enabled |
| Screenshot | Captured after the user agrees (sensitive info blocked out unless they turn that off) | If enabled |
| Session replay | Privacy-masked interaction recording | If enabled |
| Screen recording | When the user chooses Record my screen | If the button offers it |
Hide sensitive info in screenshots & recordings
Before a screenshot, screen recording or session replay is captured, the widget offers Hide sensitive info. It's on by default and remembers the user's last choice. When it's on, sensitive details are blocked out in the user's browser, before anything is uploaded:
- Email addresses, phone numbers, card numbers, IBANs, US Social Security and UK National Insurance numbers, street addresses, API keys and tokens
- Fields of type
email,telandpassword, and fields whoseautocomplete, name or label marks them as personal data - The name and email you pass to
Supprtly.identify() - Anything you mark with
data-supprtly-mask
Detection can't find everything. For example, it can't recognize names in ordinary text or text inside images and canvases. Add data-supprtly-mask to any element that shows customer data. The element and everything inside it is blocked out:
<div class="account-card" data-supprtly-mask>
<p>Jane Smith</p>
<p>Account 0042-1187</p>
</div>
<input name="customer-ref" data-supprtly-mask>To stop clicks inside an element being recorded at all (they appear in the ticket's activity log by name, like Clicked "Save" (button#save)), add data-norecord to it.
For screen recordings, the widget can only hide information on your page. If the user chooses to share their whole screen or another window, anything outside your page is recorded as it appears.
Need help? Open Settings → Install in your Supprtly dashboard and use Send test ticket to try each level.