Quickstart
From API key to a working Wirebird view in your app.
Get your credentials
When we set up your platform, Wirebird gives you a secret API key: wb_live_… for production
and wb_test_… for testing. It goes in your server's environment (for example WIREBIRD_API_KEY),
never in browser code or a repository.
Tell us every origin your app runs on, such as https://app.yourcompany.com. Wirebird refuses
browser requests from any other origin.
Add a session endpoint to your server
This endpoint sits behind your own login. It works out which business and user are signed in, asks Wirebird for a session, and returns only the short-lived token to the browser.
export async function POST(request: Request) {
const user = await requireSignedInUser(request); // your auth: decides the business, not the browser
const response = await fetch('https://api.getwirebird.com/v1/embed/sessions', {
method: 'POST',
headers: {
authorization: `Bearer ${process.env.WIREBIRD_API_KEY}`,
'content-type': 'application/json',
},
body: JSON.stringify({
business: { externalId: user.companyId, name: user.companyName, timezone: 'America/Chicago' },
businessUser: { externalId: user.id, name: user.name, email: user.email, role: user.role },
}),
cache: 'no-store',
});
if (!response.ok) return Response.json({ error: 'Wirebird unavailable' }, { status: 502 });
const { data } = await response.json(); // { token, expiresAt }
return Response.json(data, { headers: { 'cache-control': 'no-store' } });
}Never let the browser choose the business
Don't read a business id from the request body or query string. Take it from your own session, so a user can only ever get a token for the business they belong to.
The first call with a new externalId creates that business in Wirebird. See
External IDs.
Mount the provider once
Put WirebirdProvider near the root of your app, above your router in a single-page app. It holds
the session and the live-update connection, so they survive page changes.
'use client';
import { WirebirdProvider, type FetchedToken } from '@wirebird/react';
import type { ReactNode } from 'react';
async function fetchToken(): Promise<FetchedToken> {
const response = await fetch('/api/wirebird-session', { method: 'POST' });
if (!response.ok) throw new Error('Could not start a Wirebird session');
return response.json();
}
export function WirebirdRoot({ children }: { children: ReactNode }) {
return (
<WirebirdProvider fetchToken={fetchToken} theme={{ colorPrimary: '#0a7cff', radius: '6px' }}>
{children}
</WirebirdProvider>
);
}Render a component
Anywhere below the provider:
import { Wirebird } from '@wirebird/react';
export default function PhonePage() {
return <Wirebird />;
}<Wirebird /> starts on setup until the business has a number, then opens the inbox. That's the whole
integration. Next, theme it to match your app and check your
Content Security Policy.
The SDK works with React 18 and 19 and is safe to server-render.