Protocol reference
Everything the code in the platform guides does, for writing your own: a signed redirect from your server to your portal’s callback URL.
In one paragraph
When a logged-in customer opens your sign-in link, your server builds a small JSON payload saying who they are, base64-encodes it, signs the base64 text with HMAC-SHA256 using your secret key, and redirects the browser to your callback URL with ?payload= and &sig=. We check the signature and the expiry, find or create the customer, and open the portal signed in. Signing needs the secret key, so it always happens on a server, never in the browser.
Callback URL
Shown in Settings → Help center & portal → Portal sign-in under “For developers” in step 2 (Add the code to your website), and already filled in when you copy the code from there. It has one of two forms, which behave the same:
| Your help center is on | Callback URL |
|---|---|
| GetSupportX’s address | https://<app address>/portal/<your-workspace>/handoff |
| Your own domain (verified) | https://<your-domain>/portal/handoff |
Copy the one Settings shows; don’t build it by hand. The guides’ code on these docs pages has https://<your-help-center>/portal/handoff in its place: replace that whole address. Once a custom domain is verified, Settings switches to it.
The request
GET <callback URL>?payload=<base64 JSON>&sig=<hex HMAC-SHA256>[&redirect=<portal path>]Payload encoding
- JSON, encoded as UTF-8, then standard base64. Put it in the URL with URL-encoding (
encodeURIComponent,rawurlencode,quote(…, safe="")): a raw+in a query string reads as a space, and the signature then fails. - Keep it small: it rides in a URL. A few hundred characters of profile data is fine; don’t send large blobs.
Signature
- HMAC-SHA256 of the base64 text exactly as you send it, not of the JSON.
- The key is your secret key used as text, exactly as Settings showed it (64 characters). Don’t hex-decode it.
- Sent as a hex digest. Upper or lower case both work: we lower-case it before checking it, and before the one-time check.
// Node.js — the same steps in every language
const json = JSON.stringify(payload); // 1. JSON
const b64 = Buffer.from(json, "utf8").toString("base64"); // 2. base64 (standard)
const sig = crypto.createHmac("sha256", process.env.GSX_SSO_SECRET)
.update(b64) // 3. sign the base64 TEXT
.digest("hex"); // hex digest
const url = CALLBACK + "?payload=" + encodeURIComponent(b64) // 4. URL-encode it
+ "&sig=" + sig;Required and core fields
| Field | Required | Type | Rules |
|---|---|---|---|
externalId | Yes | Text (or a whole number) | Your id for this customer. It must never change and never be reused: it is what keeps their requests together. Prefix it with your site (the guides use yourwebsite.com:42) if more than one website uses your workspace. |
exp | Yes | Number: Unix time in seconds | In the future, and no more than 600 seconds (10 minutes) ahead. Use now + 300. Seconds, not milliseconds. |
iat | No | Number: Unix time in seconds | When sent, exp − iat must be 600 or less. |
jti | No (the guides’ code sends one) | Text: 32–128 hex characters | A random id for this one link (16 or more random bytes, as hex). Every guide’s code sends a fresh one. Any other value is ignored. See one-time links. |
email | No | Text | The customer’s email. Updated on their profile when it changes. See email. |
site | No | Text: an http(s) origin | Your website’s origin, for example https://yourwebsite.com. Says externalId is prefixed. If sent, it must be a valid http or https address with no user name or password, or the sign-in (and a connection check) is refused. |
legacyExternalId | No | Text or whole number, 1–200 characters | Your older, unprefixed id for the same customer. Only used together with site. See changing ids. |
test | No | true | A connection check. See connection checks. |
{
"externalId": "yourwebsite.com:42",
"site": "https://yourwebsite.com",
"email": "[email protected]",
"name": "Alice Jones",
"plan": "Pro",
"mrr": "$49",
"attributes": { "orders": 14 },
"jti": "9f2c4e1a7b3d5f60a8c2e4b6d8f01357",
"iat": 1795000000,
"exp": 1795000300
}Optional customer details
Send any of these and your team sees them next to the customer’s requests. They are updated every time the customer signs in, so you don’t need a separate sync.
| Field | Type | Limit | What it’s for |
|---|---|---|---|
name | Text | Up to 200 characters; longer is cut | The customer’s name, as your team sees it. |
phone | Text | Up to 200 characters; longer is cut | Phone number, on the customer’s profile. |
avatar | Text | Up to 200 characters; longer is cut | A picture URL, stored on the customer’s profile. |
locale | Text | Up to 200 characters; longer is cut | Language and region, for example en-GB. |
timezone | Text | Up to 200 characters; longer is cut | IANA time zone, for example Europe/London. Your team sees the customer’s local time. |
plan | Text, number or true/false | Text up to 500 characters | Plan name. Shown in the customer’s billing details. |
seats | Text, number or true/false | Text up to 500 characters | Number of seats. Shown in the billing details. |
subscriptionStatus | Text, number or true/false | Text up to 500 characters | For example active, trialing or past due. Shown in the billing details. |
mrr | Text, number or true/false | Text up to 500 characters | Monthly revenue, shown as you send it (send “$49” or 49). |
renews | Text, number or true/false | Text up to 500 characters | Renewal date, shown as you send it. |
payment | Text, number or true/false | Text up to 500 characters | Payment method, for example “Visa ending 4242”. Shown as you send it. |
ltv | Text, number or true/false | Text up to 500 characters | Lifetime value, shown as you send it. |
role | Text, number or true/false | Text up to 500 characters | Their role at their company. Shown under custom data. |
website | Text, number or true/false | Text up to 500 characters | Their website. Shown under custom data. |
company | Text, number or true/false | Text up to 500 characters | Their company name, stored as text under custom data. Customers are linked to companies by their email domain, not by this field. |
attributes | Object of key → text, number or true/false | Keys up to 60 characters, values up to 500 | Anything else you want your team to see, shown under custom data. Nested objects and lists are dropped. |
- Only fields you send are written. A field you leave out keeps its value, including anything your team typed by hand. Empty text and
nullare skipped too. - Custom data is merged with what’s stored, never replaced. At most 30 custom values are kept from one sign-in, counting the top-level ones above.
- Keys starting with
__are reserved and ignored. Nested objects and lists are dropped, not stored. - Values over a limit are cut, not refused: the sign-in still works.
Expiry and clocks
We check exp against our clock when the link arrives. Build the signed link at the moment the customer opens your sign-in link, never earlier (for example, into a page when it loads), and keep your server’s clock in sync. A link that arrives after exp is refused as expired; one whose exp is more than 10 minutes ahead is refused as too long.
One-time links
Each signed link works once. The first use signs the customer in; any later use of the same link is refused (and after exp it would be refused as expired anyway). With a valid jti we remember the link by that id; without one, by its payload and signature. The signature’s case doesn’t matter, so re-casing a used link doesn’t make it new.
Every guide’s code sends a fresh jti, iat and exp on every click. Writing your own code? Do the same, and never let a page cache or CDN store the redirect (send Cache-Control: no-store).
Customer ids and several websites
We find the customer by externalId within your workspace. If two websites share one workspace, their user number 5s are different people, so the guides prefix ids with the site (yourwebsite.com:5, or wp:<site key>:5 on WordPress) and send site. We treat externalId as opaque text and never take it apart.
Changing ids (legacyExternalId)
Moving from bare ids (5) to prefixed ones? Send the new externalId, plus site and the old id as legacyExternalId. If no customer has the new id yet, we look up the one stored under the old id and move them to the new id, keeping their requests, but only when the email you send matches theirs. Otherwise the old customer is left alone and a new one is created. legacyExternalId is ignored without site.
If no customer has this externalId but one with the same email has written to you before (and isn’t linked to another id), they are linked to this id and keep their history. If that email already belongs to a customer linked to a different id, the sign-in is refused rather than merging two people. Send only email addresses your site has confirmed; here’s why.
Landing page: the redirect parameter
Add &redirect=<path> to the callback URL to choose which portal page the customer lands on. It is not signed, so we only follow it when it is a plain path inside your portal. A portal path in either form is accepted, whichever address your callback is on, and is moved to that address:
| You send | Form | The customer lands on |
|---|---|---|
/portal/<your-workspace>/… | GetSupportX’s address | That page, on the address your callback is on |
/portal/… | Your own domain | That page, on the address your callback is on |
| Anything else | Portal home |
For example, /portal/<your-workspace>/t/5 sent to a callback on your own domain lands on /portal/t/5 there. Full addresses, other sites, other workspaces’ portals, other parts of the app, and tricks such as //, backslashes or .. all land on the portal home. The redirect can never change who is signed in.
The return path (gsx_return)
When a customer heading to a specific portal page (a request they opened from an email, say) clicks your portal’s sign-in button, we add that page to your sign-in link as ?gsx_return=<path> (or &gsx_return= when your link already has a query, like WordPress’s ?gsx_support=1). It is left off for the portal home. Your code should:
- pass it to the callback as
&redirect=, URL-encoded, when it starts with/(but not//or/\); - keep it when it sends a logged-out visitor to log in first, so it is still there when they come back (the guides send your login page the full sign-in address as
next).
Your code’s check only avoids passing on junk; ours on the callback is the one that counts.
The guides’ code does all of this, and so does the WordPress plugin from version 0.5.2. Older plugins (0.5.1 or earlier) ignore gsx_return, so their customers land on the portal home.
Connection checks (test: true)
A payload with "test": true goes through the same checks as a sign-in (signature, exp, the 10-minute limit, a malformed site) and fails in the same way. Then it stops. The only differences: nobody is signed in, no customer is created, and the link is not used up. The callback answers 200 with {"ok":true,"test":true} instead of a redirect. It shows in Settings as the last connection check from your site. externalId is still required.
What happens next
| Result | The browser goes to | Where you see it |
|---|---|---|
| Signed in | The portal (or the redirect page), signed in | “Last sign-in through your website” |
| Refused | Your portal’s sign-in page with ?error=sso: one short message, and the emailed link still works | The reason, under recent failed sign-ins. Every reason |
| Connection check | Nowhere: 200 JSON for your code | “Last connection check from your site” |
Where to look
Settings → Help center & portal → Portal sign-in → Check it works shows the last sign-in, the last connection check and the 5 most recent failures. We keep them for 30 days (up to 10 failures).
Login provider (OIDC)
Sign in with your login provider makes your portal an OpenID Connect relying party: your provider signs the customer in, and nothing runs on your website. Everything above is for sign-in through your website; this section is the whole of the OIDC side. Setup guide
Redirect URIs
| The sign-in starts on | Redirect URI to register |
|---|---|
| GetSupportX’s address | https://<app address>/portal/<your-workspace>/oidc/callback |
| Each verified custom domain | https://<your-domain>/portal/oidc/callback |
Register each one exactly; Settings shows them with Copy buttons. The portal’s button goes to …/oidc/start on the same address, carrying ?redirect= with the page the customer wanted, under the same rules as the redirect parameter.
Flow
- Authorization code flow (
response_type=code) with PKCE (S256),stateandnonce. Scope:openid email profile. - State, nonce and the PKCE verifier live in one encrypted, HttpOnly cookie for 10 minutes, tied to your workspace. The callback deletes it whatever the outcome, so each sign-in can finish once.
- Settings come from
<issuer>/.well-known/openid-configuration, which must name the same issuer, give https endpoints and support the code flow. Save stores the provider’s own spelling of the issuer. Signing keys come from itsjwks_uri, cached for an hour and fetched again (at most once a minute) when a token names a key we don’t have. A provider that names itself on the way back (iss, RFC 9207) must name the same issuer. - Confidential client. The secret goes to the token endpoint as
client_secret_basicwhen the provider offers it (or lists nothing), else asclient_secret_post. We never follow a redirect from the token endpoint, so the secret can’t be replayed to another host.
ID token checks
- Signed, not encrypted. Accepted algorithms:
RS256,RS384,RS512,PS256,PS384,PS512,ES256,ES384, and only those your provider also lists.HS256,HS384,HS512andnoneare refused: the algorithm is ours to choose, never the token’s. - The key must fit the algorithm (type, curve,
useofsig), is picked bykid, and an RSA key needs 2048 bits or more. Tokens withcritheaders are refused. issequals the saved issuer exactly.audis your client ID and nothing else (azp, if sent, too).expis in the future andiatwithin the last 10 minutes, with 2 minutes’ allowance for clocks.noncematches this sign-in.subis present.
Who the customer is
- Identity is issuer plus
sub, stored as the customer idoidc:<issuer key>:<sub>, where the issuer key is the first 12 hex characters of the SHA-256 of the issuer. The email is never an identifier. emailis stored and matched only whenemail_verifiedis the booleantrue. Microsoft Entra sends noemail_verified, so those customers are known bysubalone.- Lookup order: the customer already holding this identity; else, with a verified email, the customer who owns that email, who gets this identity added and keeps their history (their website id is left alone, so both sign-in methods keep working); else a new customer.
name(orgiven_name+family_name) fills in a missing name; it never overwrites one.
A refused sign-in lands on your portal’s sign-in page with ?error=oidc; the reason goes to Check it works. Every OIDC reason
Read next