Getting started
Authentication
How to authenticate against the FlexiScheduler API. JWT bearer tokens for identity, organization-id header for multi-tenant scoping.
Key points
- Every authenticated request needs an Authorization Bearer header and an x-organization-id header
- JWTs identify the principal; the organization header scopes the request to a tenant
- Tokens are issued through your organization’s identity provider — FlexiScheduler does not issue them directly
- A 401 means token is invalid; a 403 means token is valid but lacks permissions for the requested organization
Required headers
Authentication uses two HTTP headers. Both are required on every endpoint except GET /api/v1/health and webhook intake routes:
# Two headers are required on every authenticated request:
Authorization: Bearer <JWT>
# Identifies the user or service principal making the request.
x-organization-id: <UUID>
# Identifies which organization (tenant) the request operates against.
# Required for all multi-tenant endpoints.A typical authenticated call looks like this:
curl https://api.flexischeduler.com/api/v1/health \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "x-organization-id: $ORG_ID"Getting a token
FlexiScheduler does not issue authentication tokens directly. Tokens come from the identity provider configured for your organization — typically an enterprise SSO (Okta, Azure AD, Auth0) or a customer-managed JWT issuer.
Tokens are validated against the organization’s configured public key. The validation checks signature, expiry, and that the token’s claims match the organization referenced in the x-organization-id header.
Setting up your identity provider
Organization scoping
FlexiScheduler is multi-tenant. Every record — entities, events, templates, configurations — belongs to exactly one organization. The x-organization-id header tells the engine which organization the current request operates against.
A few rules:
- The token must have been issued for a principal who has access to the requested organization — otherwise you get a 403
- A single token can grant access to multiple organizations; the header picks which one applies to this request
- The header is required even if the token only has access to one organization — the engine never assumes which org you mean
- Cross-organization queries are not possible through the public API
Errors
Two error codes are specific to authentication:
401 Unauthorized
Your token is missing, malformed, expired, or signed with a key FlexiScheduler doesn’t recognize.
{
"statusCode": 401,
"message": "Unauthorized",
"timestamp": "2026-04-26T15:30:00Z",
"path": "/api/v1/events"
}403 Forbidden
Your token is valid, but it doesn’t have permission for the organization you’re trying to access. Most often this means the x-organization-id header references an organization the token wasn’t issued for.
{
"statusCode": 403,
"message": "Insufficient permissions for this organization",
"timestamp": "2026-04-26T15:30:00Z",
"path": "/api/v1/events"
}Don’t retry on 401 or 403
Building a client
Most teams wrap auth into a small client helper rather than passing headers around manually. Here’s a minimal TypeScript example:
// A minimal authenticated client wrapper
interface FlexiClientOptions {
baseUrl: string;
token: string;
organizationId: string;
}
export function createClient(opts: FlexiClientOptions) {
const headers = {
Authorization: `Bearer ${opts.token}`,
'x-organization-id': opts.organizationId,
'Content-Type': 'application/json',
};
return {
async get<T>(path: string): Promise<T> {
const res = await fetch(`${opts.baseUrl}${path}`, { headers });
if (!res.ok) throw new Error(await res.text());
return res.json();
},
async post<T>(path: string, body: unknown): Promise<T> {
const res = await fetch(`${opts.baseUrl}${path}`, {
method: 'POST',
headers,
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(await res.text());
return res.json();
},
};
}Inject the token from your auth flow at request time — don’t cache it in module scope, since tokens expire and you’ll need to refresh through your IdP’s token renewal flow. The organization ID is more stable; it’s usually fine to set once per session.
What about refresh tokens, scopes, and rotation