An embed key puts a live device in a page of your product: your customer opens the page, taps the device and uses your app on it, with no VibeView account. Each visitor’s session runs in one of your accounts, the account your server names when it signs the visitor in. The session counts against that account’s limits and streaming minutes, like any session of the account.
The frame shows no VibeView name, logo or link. It tells your page what it is doing, so your page writes its own words.
Before you start
- An app your organization shares with your partner (see Apps in accounts), or one of an account’s own apps (see Embed one of an account’s own apps). The key runs that app: the newest build that can run on the device.
- On a shared app, a person with the partner admin permission creates the key on the Partner page, and confirms their sign-in again to do it. On an account’s own app, your server creates it through the API.
- Your contract includes embedding. It also sets how many sites (domains) your keys may list together.
Create an embed key
On the Partner page, open Embed keys and create one: name it, pick the shared app and list the sites that may embed it. A key’s limits apply per account:
| Limit | What it caps |
|---|---|
| Devices at once | Sessions of this key running at once in one account. Another account’s sessions never count. A new key has none of its own: the account’s limit applies. |
| Longest session | Minutes a session may run. A new key has none of its own; the account’s longest session applies whenever it is lower. |
| Sessions per visitor | Sessions one visitor may hold at once in one account: 1. |
The page shows the key’s id (ek_test_… for a test partner, ek_live_… for a live one)
and its visitor secret (vvis_…). The id goes in your page; the secret stays on your
server. You can read the secret again, or rotate it, from the same page. A rotation keeps
the previous secret working for 24 hours, so pages already open keep working; choose to end
the previous secret at once if it leaked.
Embed one of an account’s own apps
An account can also embed an app it owns (one it uploaded or built). Your server creates the
key in that account, with a partner key and VibeView-Account, or the account’s access token
(scope embed:write; embed:read lists and reads its keys):
const key = await client.appEmbedKeys.create({
name: 'Docs demo',
app: 'Q7mZ2xR4kd', // one of the account's own apps
allowed_domains: ['docs.example.com'],
});
// key.id goes in your page; key.secret goes in your own secret store, now.
- The secret is shown once, in that answer. No read returns it again: if you lose it,
rotate it (
client.appEmbedKeys.rotateSecret(key.id)), which answers the new one once. - Sign visitor tokens as below, with
accset to that account. A token naming another account is refused (403 visitor_account_invalid). - Domains count across your partner: the sites this key lists count together with every other embed key of your partner against your contract.
- Limits work as for any key; the account’s own limits still apply to every session.
- Deleting the app: an app with a live embed key cannot be deleted (
409 app_in_use). Revoke the key first (client.appEmbedKeys.revoke(key.id)), then delete the app. Revoking still works after your contract stops including embedding.
The calls are listed in the API reference.
Sign the visitor in
Your server signs a visitor token for each page load: a JWT signed with HS256 and the key’s visitor secret, with these claims:
| Claim | Value |
|---|---|
type | Always embed_visitor. |
key | The embed key’s id. |
acc | The account the session runs in (org_…). |
sub | Your own id for the visitor, 1 to 200 characters. |
iat | When you signed it, in seconds. |
exp | When it stops working: at most 900 seconds after iat. |
With the Node.js package:
import { signVisitorToken } from '@vibeview/platforms';
const token = await signVisitorToken({
embedKey: 'ek_test_0a1b2c3d4e5f6g7h8i9j0k1l',
secret: visitorSecret, // the key's visitor secret, from your own secret store
account: 'org_0123456789abcdef',
subject: 'customer-42',
});
Put the token in the fragment of the frame’s address, which never reaches a server log:
<iframe
src="https://vibeview.io/embed/ek_test_0a1b2c3d4e5f6g7h8i9j0k1l#visitor_token=TOKEN"
style="width: 400px; height: 820px; border: 0"
></iframe>
A visitor who reloads the page gets their session back, in the same account. The same visitor id in another account is another visitor with a session of their own: a session is never handed to a visitor of another account.
A token without an account is refused (403 visitor_account_required). An account that
is not one of yours, or that cannot be used now (suspended or being deleted), is refused
(403 visitor_account_invalid). A frame without a token sends no start request: it shows
an empty card and posts credential_invalid.
Tell your page the frame’s state
The frame posts a message to your page each time its state changes. It is the same message a shared session’s guest page sends (see Sessions from your server):
window.addEventListener("message", (event) => {
if (event.origin !== "https://vibeview.io") return;
const m = event.data;
if (m && m.source === "vibeview" && m.type === "session_state") {
showDeviceState(m.code); // your own words
}
});
Each message is exactly {"source": "vibeview", "type": "session_state", "code": …}, sent
once per change. Act only on messages whose source is "vibeview" and whose type is
"session_state", and ignore anything else: before the frame has loaded your key’s settings
it may send one other message ("source": "vibeview-embed", "type": "ready"). After the
settings load, it sends nothing until the visitor starts a session or a start is refused. A
start that plays sends connecting, waiting, then playing; the end sends
session_ended.
code | The frame |
|---|---|
connecting | Is starting a session. |
waiting | Waits in the queue (the account is using all the devices it may use at once), or the service is briefly busy and the frame keeps trying; or waits for the app to open, or for your app to come back to the front. |
playing | Shows the device with your app. |
reconnecting | Lost the connection to the device and is getting it back. |
credential_invalid | Was given no visitor token, or one that does not verify or that names no usable account of yours. |
credential_expired | Was given a visitor token past its exp: sign a new one. |
session_full | Cannot start: the key’s devices at once in this account are all in use, and its wait line is full. |
session_ended | The session ended. |
connection_lost | Lost the connection for good; reloading the frame starts again. |
browser_unsupported | Is in a browser too old to play the device. |
unavailable | Cannot start or show a session for another reason (the key was revoked, the page is not on one of the key’s sites, your contract no longer includes embedding, your partner or organization cannot be used now, or the start failed). |
These are the same codes the shared session’s guest page sends, for the same events.
The words on screen are yours, written from the codes the frame posts. The frame shows no
other words than its controls (Tap to Start, Cancel, Try again, Start again),
a “Session ended” label after a session ends, and, in a browser too old to play the device,
a short notice saying so (it also posts browser_unsupported). Before a start it shows
only its start button. While it starts, waits in the queue or waits for a busy service, it shows a progress indicator and, where the visitor can leave
that state, a Cancel button: no heading, no place in line and no reason. Where it would
show a reason, it shows an empty card.
While the service is busy (or asks the frame to slow down) it keeps trying and posts
waiting: one start request per try, with waits of about 2, 4, 8 and 16 seconds and then
about 30 seconds between tries, longer when the service asks for longer. A frame never
sends more than 6 start requests in any minute on its own (a visitor who cancels and starts
again by hand is not held to that). Starts are limited per visitor network address: frames
behind one network address share that limit, and a frame that reaches it waits and tries
again, posting waiting meanwhile. After a failed start it shows only a
Try again button; after a session ends, Start again. To start again from your page,
reload the frame.
Until the key’s settings load, the frame’s document title is the embed page’s own
(“VibeView Embed”); once they load it is your app’s name, or “App” when the key cannot be
served. The frame shows no VibeView name, logo or link once the settings load, also when
the key cannot be served (a revoked key, a page not on the key’s sites, a contract
without embedding, your partner or organization not usable): the key’s settings answer then
carries "branding": "none" beside its error, and the frame shows a neutral, empty card and
posts unavailable. A key id that does not exist answers like any unknown key, with nothing
that names a partner.
Where the session counts
Each session is a session of the account the token names: it appears in that account’s
GET /api/v1/sessions/, counts toward its devices at once and its streaming minutes, and
sends the account’s session events. Its session.created event also carries
data.created_via (embed), data.embed_key (the key’s id) and data.visitor (the
token’s sub). See Events and webhooks.
When an account is at its limit of devices at once, a new visitor waits in line and starts as soon as one of the account’s sessions ends, while visitors of your other accounts start at once.
What ends a session
- Revoking the key (on the Partner page, or through the API for an account’s own app) ends its
sessions within moments (
end_reason:link_revoked), and the key starts no new session. - Stopping the share of the key’s app ends its sessions (
end_reason:app_unavailable) and revokes the key. - Suspending or deleting an account ends its sessions, as for any session of the account.
- A frame whose contract no longer includes embedding, or whose keys list more sites than the contract allows, starts nothing until that is fixed.