Skip to Content
Wirebird Docs

Sessions and tokens

Your secret key stays on your server. The browser only ever holds a one-hour token for one business.

Secret API keySession token
Looks likewb_live_… / wb_test_…an opaque string
LivesYour server onlyThe user's browser
Can doCreate sessions for any business on your platformUse Wirebird as one user of one business
LifetimeUntil rotated1 hour

Why two credentials

Your API key can open a session for any of your businesses, so it must never reach a browser. A session token is scoped to exactly one business and one user, and expires after an hour, so it's safe to hand to the signed-in user.

Your server decides the business

The session request names the business, and your server is the only thing that should decide it, from your own login. Never accept a business ID from the browser and pass it through:

// Don't: anyone can ask for any business.
const { companyId } = await request.json();

// Do: the business comes from who is signed in.
const user = await requireSignedInUser(request);
const companyId = user.companyId;

Refreshing

You don't manage expiry. WirebirdProvider calls your fetchToken function:

  • when it first mounts (unless you pass a token you already have),
  • five minutes before the current token expires,
  • and once more if a request comes back 401.

fetchToken resolves to { token, expiresAt }, exactly the data from the session response. If it throws, components show an error with a retry button.

Limiting components

A session can optionally list which parts of Wirebird it allows, with components (setup, inbox, conversation, call_bar, call_settings, call_log, unread_badge). Leave it out to allow everything. See Create a session.

On this page