Plugin context and session token
Your page learns who is looking at which ticket from Konvo, over
postMessage, once it says it is ready. The SDK does this for you; this
article documents what travels, for pages that don't use it.
The handshake
- Konvo loads your page in a sandboxed iframe, with
?theme=…&lang=…. - Your page posts
{ konvo: 1, type: "ready" }to its parent. - Konvo answers with:
{
"konvo": 1,
"type": "init",
"context": {
"ticketId": "8f3c…",
"organizationId": "org_01…",
"language": "es",
"theme": "dark"
},
"token": "eyJhbGciOiJFUzI1NiIs…",
"expiresAt": "2026-11-11T10:05:00.000Z"
}
Other messages:
| From your page | Konvo answers |
|---|---|
{ konvo: 1, type: "token" } |
{ konvo: 1, type: "token", token, expiresAt }, a fresh token |
{ konvo: 1, type: "resize", height } |
nothing; the section takes that height (120–800) |
| From Konvo | When |
|---|---|
{ konvo: 1, type: "context", context } |
the agent switched theme or language |
When the agent opens another ticket, Konvo loads your page again. A page never stays on one ticket while the agent looks at another.
Konvo only posts to your page's origin, and only reads messages from your
frame and that origin. Read Konvo's messages only from
https://k2.konvoai.com (event.origin) and window.parent
(event.source).
The token
An ES256 JSON Web Token, valid for 5 minutes. Ask for a new one with
Konvo.getToken() (or the token message) when it is about to expire.
| Claim | Meaning |
|---|---|
iss |
https://api.k2.konvoai.com |
aud |
Your page's origin, e.g. https://konvo.acme-agency.com |
sub |
The Konvo user looking at the ticket |
org_id |
Their organization |
ticket_id |
The ticket they have open |
role |
Their role: owner, admin, manager, agent, associate or partner |
plugin_id |
Your manifest's id |
iat, exp, jti |
Issued at, expiry, unique id |
The token carries no name or email. Konvo issues one only to a member of the organization, for a ticket they can see, and never while Konvo staff are impersonating a member.
The token is not a Konvo credential. It can't call the Konvo API. To read the ticket, your backend uses an API key.
Verifying it
Konvo's public keys are at https://api.k2.konvoai.com/.well-known/jwks.json.
Check the signature, iss, exp, aud (your own origin), and then
org_id against your own list of customers.
Node / Bun
import { createRemoteJWKSet, jwtVerify } from "jose";
const keys = createRemoteJWKSet(
new URL("https://api.k2.konvoai.com/.well-known/jwks.json"),
);
const { payload } = await jwtVerify(token, keys, {
issuer: "https://api.k2.konvoai.com",
audience: "https://konvo.acme-agency.com",
algorithms: ["ES256"],
});
PHP (firebase/php-jwt)
use Firebase\JWT\JWT;
use Firebase\JWT\JWK;
$jwks = json_decode(file_get_contents('https://api.k2.konvoai.com/.well-known/jwks.json'), true);
$payload = JWT::decode($token, JWK::parseKeySet($jwks, 'ES256'));
if ($payload->iss !== 'https://api.k2.konvoai.com'
|| $payload->aud !== 'https://konvo.acme-agency.com') {
throw new Exception('Not a token for this plugin');
}
Python (PyJWT)
import jwt
keys = jwt.PyJWKClient("https://api.k2.konvoai.com/.well-known/jwks.json")
signing_key = keys.get_signing_key_from_jwt(token)
payload = jwt.decode(
token,
signing_key.key,
algorithms=["ES256"],
issuer="https://api.k2.konvoai.com",
audience="https://konvo.acme-agency.com",
)
Cache the key set: it changes only when Konvo rotates keys, and a new key is published before it signs anything.