> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowpayroll.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Show your own support inside Flow Payroll

> Host a support page of your own, and Flow Payroll shows it in a panel inside the app, already knowing who is asking and which organisation they are working in.

If you run Flow Payroll under your own brand, you can give your users your own support without sending them out of the app. You host a page. Flow Payroll shows it in a **Support** panel and tells it, in a way you can verify, who the signed-in person is and which organisation they are working in. Your page then starts whatever support tool you use.

Flow Payroll never holds your support provider's credentials, and never sees your conversations. You can change provider, routing or design whenever you like, with nothing to ask of us.

## How it works

**1. Somebody opens Support**

They choose the **Support** button at the foot of the app's side menu. The app asks Flow Payroll for a support session and shows your page in a frame. Nothing about the person is in your page's address.

**2. Your page says it is ready**

It posts a `ready` message to the app.

**3. The app hands over a token, then the screen**

An `auth` message carries a signed token. A `context` message says where the person is in the app, and is sent again whenever that changes.

**4. Your server verifies the token**

Your page sends the token to your own server, which checks it against Flow Payroll's public keys and learns who the person and the organisation are, in your own identifiers.

**5. Your support tool starts**

Your server signs the person in to your support tool with your own secret, and your page shows it.

## Before you start

* Your account needs white label. The support panel is part of your brand.
* Give your people, your guests and your organisations an `externalId`, so the token names them the way your own systems do. Set it when you [invite people](https://docs.flowpayroll.ai/api-reference/administration/users-roles-and-permissions.md), through [SCIM](https://docs.flowpayroll.ai/api-reference/administration/scim-provisioning.md), or with `PATCH /users/{principalId}` and `PATCH /organisations/{organisationId}`.
* Tell us the address of your support page, for sandbox and for production: **Ask us to allow your page** on the **Support panel** tab opens an email to us for you to send. We allow each address before it can be shown. Until we have, the app offers no **Support** entry.
* Note your account's customer id, from `GET /customer`. It is the token's audience.

## Set the address

In the app, go to **Administration**, then **Branding**, then the **Support panel** tab. Enter the **Support panel address**, and the **Support panel width** if your tool needs more or less room, then publish the brand.

![The Support panel tab of Branding, with the support panel address, its width, the list of what the page receives and the developer steps](https://mintcdn.com/flowpayroll-1ca487e0/rvZVammeX0YOqbJB/images/screenshots/branding-support-panel.png?fit=max\&auto=format\&n=rvZVammeX0YOqbJB\&q=85\&s=3032a07d14afe527d66de43a10d3af7a)

The Support panel tab: the address and width, what your page receives, and your developers' part

The tab also says where the panel stands: **Off**, **Not published**, **Waiting for us** (published, but we have not allowed the address yet), **Live**, or **Live until you publish** when you have cleared a live address. It lists everything your page receives, as on this page, so whoever approves the panel on your side can see it before you publish.

With the API, send `supportEmbedUrl` and `supportPanelWidth` to `PATCH /customer/branding/draft` and publish with `POST /customer/branding/revisions`.

The address must start with `https://` and have no `#` part. Leave it empty and publish to remove the panel.

The width is in pixels, from 360 to 720. Leave it empty for 420. It applies on a computer; on a phone the panel always fills the screen.

Sandbox and production each have their own brand, so each has its own address.

## Host the page

Your page is an ordinary web page on an address you control. Three things are required of it.

**Allow Flow Payroll to frame it, and nobody else.** Send a `Content-Security-Policy` header naming the app's addresses:

```text theme={null}
Content-Security-Policy: frame-ancestors https://app.flowpayroll.ai https://payroll.yourbrand.example
```

Use `https://sandbox.app.flowpayroll.ai` in sandbox. Add your own payroll address if you have one. Do not send `X-Frame-Options: DENY` or `SAMEORIGIN`.

**Start every load signed out.** Do not show anybody's conversations until a token has arrived and your server has verified it.

**Take messages only from the app.** Check both the sender and its origin on every message, as the example below does.

The page is shown in a panel beside the person's work, at the width you set (420 pixels unless you change it) on a computer and the full width of a phone. Fill the frame: the app draws the panel's title and its close button.

The frame limits what your page can do. It can run scripts, submit forms, open pop-ups, start downloads and write to the clipboard. It cannot move the app to another address, and it cannot use the camera, the microphone or screen sharing. If your support tool offers calls or screen sharing, have it open them in a new window.

## Messages

The app and your page talk with [`window.postMessage`](https://developer.mozilla.org/docs/Web/API/Window/postMessage). Every message is an object with `source: "flow-payroll-support"` and `version: 1`. Ignore anything else.

Your page sends:

| `type` | Fields | When |
| - | - | - |
| `ready` | | Once, when the page can receive messages. Nothing is sent to you before it. |
| `unread` | `count` | When the number of unread messages changes. The app shows it beside the **Support** button while the panel is closed, up to 999. |
| `close` | | To ask the app to close the panel. |

The app sends:

| `type` | Fields | When |
| - | - | - |
| `auth` | `token`, `expiresAt` | After `ready`, and again with a new token about a minute before each one expires. |
| `context` | `context` | After the first `auth`, whenever the person moves to another screen, and with each new token. |
| `visibility` | `open` | When the panel opens or closes. Your page stays loaded while it is closed. |
| `signout` | | When the person signs out or changes organisation. See [Sign-out](#sign-out-and-changing-organisation). |

`context` looks like this:

```json theme={null}
{
  "screen": { "area": "Pay run", "path": "/pay/wizard/cfg-monthly/2026/7", "tab": "lock" },
  "payRun": { "payrollConfigId": "cfg-monthly", "year": 2026, "period": 7 },
  "attributes": {
    "hasPayRun": true,
    "lastPayRunStatus": "Open",
    "lastCompletedPayRunPayDate": "2026-10-31",
    "nextPayRunPayDate": "2026-11-28"
  }
}
```

`screen.path` is the app's address for the screen, so it can hold an id, such as an employee's or a pay run's. It never holds a name. `payRun` is `null` away from a pay run. `attributes` says where the organisation's payroll stands. It is read when the panel first opens and again with each new token:

| Attribute | Value |
| - | - |
| `hasPayRun` | Whether the organisation has any pay run yet, open or completed. |
| `lastPayRunStatus` | `Open` while a pay run is open, otherwise `Completed`. Left out before the first pay run. |
| `lastCompletedPayRunPayDate` | The pay date of the last completed pay run, as `YYYY-MM-DD`. Left out when there is none. |
| `nextPayRunPayDate` | The pay date of the open pay run that pays soonest, as `YYYY-MM-DD`. Left out when none is open. |

`attributes` is `null` when it cannot be read; the panel still opens. More attributes may be added, so ignore any you do not know.

Set these as attributes on the conversation, so your agents see where the person is without asking. `context` is not signed: use it to help, never to decide what somebody may see.

```html theme={null}
<script>
  // The app's addresses: the only places this page listens to and replies to.
  const APP_ORIGINS = ['https://app.flowpayroll.ai', 'https://payroll.yourbrand.example']
  const envelope = { source: 'flow-payroll-support', version: 1 }
  let appOrigin = null

  const tell = message => {
    for (const origin of appOrigin ? [appOrigin] : APP_ORIGINS) {
      window.parent.postMessage({ ...envelope, ...message }, origin)
    }
  }

  window.addEventListener('message', async event => {
    if (event.source !== window.parent || !APP_ORIGINS.includes(event.origin)) return
    const message = event.data
    if (!message || message.source !== envelope.source || message.version !== envelope.version) return
    appOrigin = event.origin

    if (message.type === 'auth') {
      // Your server verifies the token and answers what your support tool needs to start.
      const response = await fetch('/support-session', {
        method: 'POST',
        headers: { 'content-type': 'application/json' },
        body: JSON.stringify({ token: message.token }),
      })
      if (response.ok) startSupport(await response.json())
      else stopSupport()
    }
    if (message.type === 'context') setConversationAttributes(message.context)
    if (message.type === 'signout') stopSupport()
  })

  tell({ type: 'ready' })
</script>
```

## Verify the token on your server

The token is a JSON Web Token signed with RS256, with `typ` `support-assertion+jwt` in its header. Verify it on your server, never in the page: the person controls their browser, so a check made there proves nothing about who they are.

| Claim | Value |
| - | - |
| `iss` | `https://id.flowpayroll.ai`. In sandbox, `https://id.sandbox.flowpayroll.ai`. |
| `aud` | Your account's customer id. |
| `sub` | Your `externalId` for the person. `flow:` and their Flow Payroll id when they have none. |
| `org` | Your `externalId` for the organisation. `flow:` and its Flow Payroll id when it has none. |
| `principal_id` | The person's Flow Payroll id, always. |
| `organisation_id` | The organisation's Flow Payroll id, always. |
| `org_name` | The organisation's name: its trading name, or its legal name when it has none. |
| `email` | The person's email address. |
| `name` | The person's full name. |
| `given_name`, `family_name` | The person's first and last names. |
| `env` | `prod` or `sandbox`. |
| `ver` | `1`. |
| `iat`, `exp` | When it was issued and when it expires, in seconds. A token lasts 10 minutes. |
| `jti` | An id for this token, and for the support session it opened. Quote it if you ask us about one. |

`email`, `name`, `given_name`, `family_name` and `org_name` use the names OpenID Connect uses, and each is left out when we do not have it. The token carries no payroll data, and it gives no access to the Flow Payroll API.

The public keys are at:

```text theme={null}
https://id.flowpayroll.ai/.well-known/jwks.json
https://id.sandbox.flowpayroll.ai/.well-known/jwks.json
```

Check all of these, and refuse the token if any fails:

1. The algorithm is `RS256`. Do not accept whatever the token's header says.
2. The header's `typ` is `support-assertion+jwt`. Any other token Flow Payroll signs is not a support token.
3. The signature, with the key whose `kid` the header names.
4. `iss` is the issuer for your environment.
5. `aud` is your customer id.
6. `env` is the environment you are running in.
7. `exp` has not passed. Allow 60 seconds for clocks that disagree.

Any JSON Web Token library does this, in the same few lines as a single sign-on integration.

```javascript Node.js theme={null}
import { createRemoteJWKSet, jwtVerify } from 'jose'

const keys = createRemoteJWKSet(new URL('https://id.flowpayroll.ai/.well-known/jwks.json'))

export async function verifySupportToken(token) {
  const { payload } = await jwtVerify(token, keys, {
    issuer: 'https://id.flowpayroll.ai',
    audience: process.env.FLOW_CUSTOMER_ID,
    algorithms: ['RS256'],
    typ: 'support-assertion+jwt',
    clockTolerance: 60,
  })
  if (payload.env !== 'prod') throw new Error('Token is for another environment')
  return { person: payload.sub, organisation: payload.org }
}
```

```python Python theme={null}
import os
import jwt

keys = jwt.PyJWKClient("https://id.flowpayroll.ai/.well-known/jwks.json")

def verify_support_token(token: str) -> dict:
    verified = jwt.decode_complete(
        token,
        keys.get_signing_key_from_jwt(token).key,
        algorithms=["RS256"],
        issuer="https://id.flowpayroll.ai",
        audience=os.environ["FLOW_CUSTOMER_ID"],
        leeway=60,
    )
    if verified["header"].get("typ") != "support-assertion+jwt":
        raise ValueError("Not a support token")
    claims = verified["payload"]
    if claims["env"] != "prod":
        raise ValueError("Token is for another environment")
    return {"person": claims["sub"], "organisation": claims["org"]}
```

### Who the token names

`sub` is your own `externalId` for the person when you have given them one and they are still one of your people or your guests (anybody `GET /users/{principalId}` shows you). Otherwise it is `flow:` followed by their Flow Payroll id. That happens for:

* somebody you have not given an `externalId` yet
* somebody who no longer has any access through your account, even if you gave them one before

Treat a `flow:` person as somebody you do not have on record. You can still help them, and `principal_id` lets you look them up with `GET /users/{principalId}`.

`org` works the same way for the organisation. The organisation is always the one the person has open in the app, so somebody who works across several employers is named with the right one each time.

## Start your support tool

Once your server has verified the token, sign the person in to your support tool the way that tool asks, with its secret, on your server. For Intercom, that is the identity verification its Messenger security settings describe: sign the user with your Intercom secret, send the result to your page, and start the Messenger with it. Use `sub` as the user and `org` as the company, with `email`, `name` and `org_name` as their details.

Your support tool's secret stays on your server. Flow Payroll never has it.

## Renewal

A token lasts 10 minutes. The app sends a new one in an `auth` message about a minute before each expires, for as long as your page is loaded. You do not need to do anything with a renewed token for the same person and organisation, unless your own session depends on it.

## Sign-out and changing organisation

When the person signs out of the app or changes organisation, the app removes your page and sends `signout` as it does. A page that is being removed may not receive it. So do not rely on `signout` alone:

* Start every load signed out, as above.
* When an `auth` token names a different `sub` or `org` from the session you have, end that session and start a new one.
* On `signout`, end the session if you receive it.

## When keys change

The key set holds two keys: the one that signs now, and the one that signs next. We change which one signs from time to time, without notice, and both are published long before either is used.

Cache the keys by `kid`. When a token names a `kid` you do not have, fetch the key set again once, then refuse the token if it is still missing. The libraries above do this for you. The file may be cached for 10 minutes.

## If your page is unavailable

If your page has not said `ready` within 15 seconds, or the app cannot start a support session, the app shows the person your support website and support email from your brand, with a **Try again** button. Set both on the **Help and legal** tab of **Branding** so nobody is left with nothing.

## Limits

* One person can start 120 support sessions an hour. The app asks for about six an hour while the panel is open.
* A support session is for a signed-in person. An API token cannot ask for one.

## Check your integration

**1. Sandbox first**

Set the sandbox address on your sandbox brand and publish. Open an organisation of your account in the sandbox app and choose **Support**.

**2. Refuse what you should**

Check that your server refuses a token with another `aud`, a token from the other environment, an expired token, a token with another `typ`, and a token whose signature you have altered.

**3. Change organisation**

Open Support in one organisation, change to another and open it again. Your tool should show the second organisation.

**4. Somebody with no externalId**

Open Support as somebody with no `externalId`. Your tool should treat them as somebody new.

## Related

* `POST /organisations/{organisationId}/support-sessions` in the Administration API reference, which the app calls for you
* [Users, roles and permissions](https://docs.flowpayroll.ai/api-reference/administration/users-roles-and-permissions.md)
* [Provisioning users with SCIM 2.0](https://docs.flowpayroll.ai/api-reference/administration/scim-provisioning.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.