Getting started
Quickstart
From credentials to first scheduled event in five minutes.
Key points
- You need a JWT token (from your identity provider) and an organization ID before starting
- Replace the example UUIDs with real entities from your organization once you’ve created them
- Every endpoint accepts and returns JSON; field names use camelCase consistently
- This guide uses curl for clarity; equivalent TypeScript follows at the bottom
1. Verify connectivity
Before doing anything else, hit the health endpoint to confirm your token and organization ID work and the engine is reachable:
curl https://api.flexischeduler.com/api/v1/health \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "x-organization-id: $ORG_ID"
# Response (200)
# {
# "status": "healthy",
# "timestamp": "2026-04-26T15:30:00Z",
# "checks": {
# "postgres": "healthy",
# "mongodb": "healthy",
# "redis": "healthy"
# }
# }A 200 response with status: “healthy” confirms the request authenticated and routed correctly. If you see a 401 or 403, see the Authentication page — those are the two failure modes specific to auth.
Don’t commit your JWT
2. Find optimal slots
Before creating an event, ask the engine which slots would work. The optimal-slots endpoint runs constraint validation across candidate windows and returns ranked alternatives:
curl "https://api.flexischeduler.com/api/v1/bookings/optimal-slots?\
eventType=home_visit&\
primaryEntityId=a1b2c3d4-e5f6-7890-abcd-ef1234567890&\
preferredStart=2026-05-08T10:00:00Z&\
durationMinutes=60&\
flexibilityDays=7" \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "x-organization-id: $ORG_ID"The response carries scored slots with allocated resources where applicable:
{
"slots": [
{
"startTime": "2026-05-08T10:00:00Z",
"endTime": "2026-05-08T11:00:00Z",
"score": 0.95,
"primaryEntityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"availableResources": [
{ "resourceId": "res_van_2", "resourceType": "transport_vehicle" }
],
"metadata": {
"mergeOpportunity": false
}
},
{
"startTime": "2026-05-08T14:00:00Z",
"endTime": "2026-05-08T15:00:00Z",
"score": 0.88,
"metadata": {
"mergeOpportunity": true,
"existingEventIds": ["evt_pt_session_a"]
}
}
]
}The score reflects how well each slot matches your preferences and any allocator extensions configured for your template. metadata.mergeOpportunity flags slots where the booking would consolidate with existing same-day events for the entity — useful for surfaces that can present the “combine with existing” affordance.
When no slots come back
An empty slots array means no candidate window passed validation. Common causes:
- The primary entity has no availability in the flexibility window
- Required resources are fully allocated across all candidate windows
- A hard constraint (daily hour limit, capability match) blocks all candidates
Use POST /api/v1/conflicts/detect on a specific proposed event to get a structured explanation of why a particular slot fails — it returns conflict objects naming the failing constraints.
3. Create the event
Once you have a viable slot, create the event:
curl https://api.flexischeduler.com/api/v1/events \
-X POST \
-H "Authorization: Bearer $JWT_TOKEN" \
-H "x-organization-id: $ORG_ID" \
-H "Content-Type: application/json" \
-d '{
"eventType": "home_visit",
"title": "Weekly Home Visit",
"primaryEntityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"startTime": "2026-05-08T10:00:00Z",
"endTime": "2026-05-08T11:00:00Z",
"participants": [
{
"entityId": "stf_a8f4c2d1-...",
"role": "provider",
"isRequired": true
}
],
"resources": [
{
"entityId": "res_van_2",
"resourceType": "transport_vehicle",
"quantity": 1
}
]
}'The engine re-runs constraint validation on creation to prevent races between optimal-slot lookup and create. If anything has changed in the gap between calls (someone else booked the resource, an availability pattern changed), the create fails with the up-to-date conflict.
A successful create returns the full event:
{
"eventId": "evt_b29f4e58-1234-5678-90ab-cdef12345678",
"status": "scheduled",
"eventType": "home_visit",
"startTime": "2026-05-08T10:00:00Z",
"endTime": "2026-05-08T11:00:00Z",
"primaryEntityId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"participants": [...],
"resources": [...],
"createdAt": "2026-04-26T15:32:11Z"
}Note the returned eventId — you’ll need it for any subsequent updates, cancellations, or audit lookups. Persist it in your application’s database alongside your own record of the booking.
In TypeScript
For reference, here’s the same flow in TypeScript using the native fetch API:
// Same flow in TypeScript using fetch
const baseUrl = 'https://api.flexischeduler.com';
const headers = {
Authorization: `Bearer ${process.env.JWT_TOKEN}`,
'x-organization-id': process.env.ORG_ID!,
'Content-Type': 'application/json',
};
// 1. Find optimal slots
const slotsRes = await fetch(
`${baseUrl}/api/v1/bookings/optimal-slots?` +
new URLSearchParams({
eventType: 'home_visit',
primaryEntityId: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
preferredStart: '2026-05-08T10:00:00Z',
durationMinutes: '60',
flexibilityDays: '7',
}),
{ headers },
);
const { slots } = await slotsRes.json();
// 2. Pick the best slot and create the event
const best = slots[0];
const eventRes = await fetch(`${baseUrl}/api/v1/events`, {
method: 'POST',
headers,
body: JSON.stringify({
eventType: 'home_visit',
primaryEntityId: best.primaryEntityId,
startTime: best.startTime,
endTime: best.endTime,
resources: best.availableResources?.map((r) => ({
entityId: r.resourceId,
resourceType: r.resourceType,
quantity: 1,
})),
}),
});
const event = await eventRes.json();
console.log('Created event:', event.eventId);What to read next
That’s the full booking flow — verify, find, create. Where to go from here:
- Authentication covers the JWT and organization-id model in detail, including error handling.
- API reference documents every endpoint with full request and response shapes.
- Extension SDK is for when JSON templates aren’t enough — when you need custom validators, allocators, or external API calls during scheduling.