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

# User identity in connectors and webhooks

> Learn which Quintus user asked for an action by validating the identity token Quintus sends to your MCP server, n8n workflow or HTTP endpoint.

When a Quintus agent calls your MCP server, n8n workflow or HTTP endpoint, the call arrives on behalf of a user. This page shows how to turn on the identity token and how to validate it, so your system knows who asked for the action and in which company.

## What it is

The identity token is a short-lived JWT, signed by Quintus with ES256, that says which Quintus user, in which company (tenant), triggered the call.

* It is **not a user credential** and cannot be used to call the Quintus APIs.
* It **carries no roles or permissions**. Your system decides what the user may do, by mapping `sub` or `email` to the permissions you already keep.

## How to enable it

The identity token is optional, off by default, and only a company administrator can turn it on.

**1. Open the connector or the webhook**

On the custom connector, go to the **Identidade do usuário** (User identity) section. On the agent webhook, open the webhook form and use the same option.

**2. Turn on the token**

Switch on **Enviar token de identidade do usuário** (Send the user identity token).

**3. Choose what to include**

Optionally switch on **Incluir e-mail** (Include email) and **Incluir nome** (Include name). Connectors also have **Enviar também no header X-Quintus-Identity** (Also send it in the X-Quintus-Identity header).

**4. Webhooks: declare the body key**

To also receive the token in the JSON body, add `{"json": {"quintus_identity": ""}}` to the webhook's **Dados adicionais** (Additional data). Quintus fills the empty value on every call.

## Where the token arrives

Quintus issues a new token on every call. It never goes in a tool argument, URL or query string, and the model never sees it.

**MCP tool call**: in the request's `_meta` field, on every call.

```json theme={null}
{
  "method": "tools/call",
  "params": {
    "name": "my_tool",
    "arguments": {},
    "_meta": {
      "tec.quintus/identity": { "token": "eyJ..." }
    }
  }
}
```

**Header**: the `X-Quintus-Identity` header carries the same token.

```http theme={null}
X-Quintus-Identity: eyJ...
```

For MCP, the header is only sent on HTTP transports (streamable-http or SSE), with **Enviar também no header X-Quintus-Identity** (Also send it in the X-Quintus-Identity header) switched on. Local connectors run by Quintus Desktop receive only `_meta`. On webhooks with the option enabled, the header is always sent.

**Webhook body**: with `{"json": {"quintus_identity": ""}}` in the additional data, the body you receive has the key filled.

```json theme={null}
{
  "quintus_identity": "eyJ..."
}
```

> [!TIP]
>
> Prefer reading `_meta`. Turning the header on makes Quintus open a new MCP session to your server on every tool call, which is slower and puts more load on the server. Use the header only if your server cannot read `_meta`.

> [!NOTE]
>
> Local connectors run by a Quintus Desktop version that does not advertise `request_meta` support receive no token at all (neither in `_meta` nor in the header): update Quintus Desktop. Async tools of an opt-in connector (tools whose result comes back later through the integration callback) also do not receive the token.

## Claims

The token's JOSE header has `alg` = `ES256`, `kid` (the signing key) and `typ` = `quintus-connector-identity+jwt`. The body has exactly these claims:

| Claim | Description |
| - | - |
| `iss` | Issuer: `https://sso.quintus.tec.br/connector-identity`. |
| `typ` | Always `connector-identity`. |
| `aud` | Connector or webhook id, as shown in Quintus. A token issued for another connector is not valid for yours. |
| `sub` | The user's id in Quintus. |
| `tenant` | The company (tenant) id, an integer. |
| `iat` | Time of issue. |
| `exp` | Expiry, at most 5 minutes after `iat`. |
| `jti` | Unique token identifier, to detect replays. |
| `email` | Optional: only present when the administrator enabled **Incluir e-mail** (Include email). |
| `name` | Optional: only present when the administrator enabled **Incluir nome** (Include name). |

## How to validate

The public keys are at `https://sso.quintus.tec.br/.well-known/connector-identity-jwks.json`. Follow these steps in this order:

1. Fetch the keys from that URL (JWKS) and pick the key by the token's `kid`. Cache them and fetch again when an unknown `kid` shows up.
2. Accept `alg` ES256 only. Reject `none`, HS\* and RS\*.
3. Check that `iss` is `https://sso.quintus.tec.br/connector-identity`.
4. Check that `aud` is the id of your own connector or webhook. Refuse tokens issued for another one.
5. Check that `tenant` is your company's id in Quintus (ask Quintus support if you don't know it). Refuse tokens from another company.
6. Check that `exp` has not passed (clock tolerance of at most 60 seconds) and that the `typ` claim is `connector-identity`.
7. Check that the `jti` has never been seen: store each `jti` until its `exp` plus the clock tolerance (so a replay inside the tolerance is also refused) and refuse repeats.
8. Only then authorize the action by `sub` or `email`.

> [!WARNING]
>
> Refuse the request when the token is absent or invalid. Never fall back to a user id sent in arguments or params. The `USER_ID` and `TENANT_ID` connection placeholders are filled only by the platform and cannot be overridden by connection params, but they are not signed: use the token for authorization decisions.

## Example: n8n

n8n's JWT node does not read a JWKS URL and does not check `iss` or `aud`. So the workflow uses the PEM public key in the JWT node and checks the rest in an IF node.

**1. Receive the call**

Add a **Webhook** node as the trigger.

**2. Verify the signature**

Add a **JWT** node with the **Verify** operation. For **Token**, use `{{ $json.headers["x-quintus-identity"] }}` (or `{{ $json.body.quintus_identity }}`). In the **JWT Auth** credential, use **Key Type** `PEM Key`, **Algorithm** `ES256` and, in **Public Key**, the PEM of the current JWKS key (see below).

**3. Check issuer, audience, tenant and type**

Add an **IF** node requiring `{{ $json.payload.iss }}` to equal `https://sso.quintus.tec.br/connector-identity`, `{{ $json.payload.aud }}` to equal your webhook id, `{{ $json.payload.tenant }}` to equal your company's id in Quintus and `{{ $json.payload.typ }}` to equal `connector-identity`. Connect your actions only to the IF node's "true" output, after **Remove Duplicates**; the "false" output must not reach them.

**4. Refuse replays**

Add a **Remove Duplicates** node with the **Remove Items Processed in Previous Executions** operation and the value `{{ $json.payload.jti }}`.

To convert the JWKS key to PEM, save this as `jwks-to-pem.mjs` and run `node jwks-to-pem.mjs`:

```js theme={null}
import { createPublicKey } from "node:crypto";
const jwks = await (await fetch("https://sso.quintus.tec.br/.well-known/connector-identity-jwks.json")).json();
for (const jwk of jwks.keys) console.log(jwk.kid, createPublicKey({ key: jwk, format: "jwk" }).export({ type: "spki", format: "pem" }));
```

> [!NOTE]
>
> The JWT node does not read a JWKS URL: update the PEM when Quintus rotates its keys (a new `kid` appears in the JWKS). The symptom is verification failing for a token that looks valid. The node refuses an invalid signature or an expired token; do not enable **Continue On Fail** on it.

## Code examples

```python Python theme={null}
# pip install "pyjwt[crypto]>=2.15"
import time
import jwt

JWKS_URL = "https://sso.quintus.tec.br/.well-known/connector-identity-jwks.json"
ISSUER = "https://sso.quintus.tec.br/connector-identity"
MY_ID = "<your connector or webhook id>"
MY_TENANT = 0  # your company's id in Quintus

LEEWAY = 30  # clock tolerance in seconds; the jti store below uses the same value

jwks = jwt.PyJWKClient(JWKS_URL)  # caches the keys

_seen = {}  # jti -> exp. In production, use Redis `SET jti 1 NX EX <exp - now + LEEWAY>` or a table with a TTL.

def remember_jti(jti, exp):
    now = time.time()
    for k in [k for k, v in _seen.items() if v < now]:
        del _seen[k]
    if jti in _seen:
        return False
    _seen[jti] = exp + LEEWAY
    return True

def verify_identity(token):
    key = jwks.get_signing_key_from_jwt(token)
    claims = jwt.decode(token, key.key, algorithms=["ES256"], audience=MY_ID, issuer=ISSUER, leeway=LEEWAY,
                        options={"require": ["exp", "iat", "iss", "aud", "sub", "jti", "tenant"]})
    if (jwt.get_unverified_header(token).get("typ") != "quintus-connector-identity+jwt"
            or claims.get("typ") != "connector-identity" or claims["tenant"] != MY_TENANT
            or not remember_jti(claims["jti"], claims["exp"])):
        raise PermissionError("invalid identity token")
    return claims
```

```js Node theme={null}
// npm i jose
import { createRemoteJWKSet, jwtVerify } from "jose";

const JWKS_URL = "https://sso.quintus.tec.br/.well-known/connector-identity-jwks.json";
const ISSUER = "https://sso.quintus.tec.br/connector-identity";
const MY_ID = "<your connector or webhook id>";
const MY_TENANT = 0; // your company's id in Quintus

const LEEWAY = 30; // clock tolerance in seconds; the jti store below uses the same value

const JWKS = createRemoteJWKSet(new URL(JWKS_URL)); // caches the keys

const seen = new Map(); // jti -> exp. In production, use Redis `SET jti 1 NX EX <exp - now + LEEWAY>` or a table with a TTL.
function rememberJti(jti, exp) {
  const now = Date.now() / 1000;
  for (const [k, v] of seen) if (v < now) seen.delete(k);
  if (seen.has(jti)) return false;
  seen.set(jti, exp + LEEWAY);
  return true;
}

export async function verifyIdentity(token) {
  const { payload } = await jwtVerify(token, JWKS, { algorithms: ["ES256"], issuer: ISSUER, audience: MY_ID,
    typ: "quintus-connector-identity+jwt", requiredClaims: ["exp", "iat", "sub", "jti", "tenant"], clockTolerance: LEEWAY });
  if (payload.typ !== "connector-identity" || payload.tenant !== MY_TENANT || !rememberJti(payload.jti, payload.exp)) {
    throw new Error("invalid identity token");
  }
  return payload;
}
```

In a Python MCP server (FastMCP, the `mcp` SDK), read the token from the request's `_meta` and pass it to the verifier:

```python theme={null}
meta = ctx.request_context.meta
token = ((meta.model_extra or {}).get("tec.quintus/identity") or {}).get("token") if meta else None
```

## When the token is not sent

> [!NOTE]
>
> Quintus does not send the token in these cases, and your system must treat its absence as "unknown user":
>
> * API-key integrations (including the Agents API), even on a connector or webhook with the option on.
> * The public chat and the chat widget, even on a connector or webhook with the option on.
> * Connectors and webhooks without the option on.
> * Local connectors on Quintus Desktop without `request_meta` support.
> * Async tools of an opt-in connector (result returned through the integration callback).
> * When Quintus cannot issue the token (for example, SSO is unavailable): the call goes on without it.

## Security

* Never write the token to logs.
* The token proves identity for at most 5 minutes and for a single connector or webhook.
* Never forward it to third parties.


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