Guide

Authentication

Every /v1 resource accepts either of two credentials. Pick the one that fits — an integration uses an API key.

Two ways to authenticate

The /v1 surface is one API with two front doors. Each resource endpoint resolves whichever credential you send:

  • X-API-Key — an integration key, scoped to one organization. This is how machine integrations authenticate.
  • Authorization: Bearer <JWT> — a short-lived user token that the Comflyant dashboard holds. The dashboard is just another client of the same /v1 API (we use our own product the way you do).

Because both are accepted, the same endpoint serves your integration and our web app. If a request somehow carries both, the JWT wins. As an integrator you'll use an API key:

X-API-Key: your-api-key

The key resolves to exactly one organization, and that organization scopes every resource you can read or write — there is no cross-tenant access. Store keys only as a server-side secret. They are kept as a hash (never in plaintext), can carry an optional expiry, and are revocable immediately. A missing or invalid credential returns 401 Unauthorized.

The /app/* endpoints (login, MFA, team management) are the dashboard control plane and are JWT-only — they are not part of the public resource API. Build integrations against /v1.

Plans & entitlements

Some capabilities are gated by your plan. Using the API with an X-API-Key requires the api_access entitlement, which is included on the Professional plan and higher. (The dashboard JWT works on any plan — it's how you manage the account.)

Entitlement requirements are self-describing in the spec: an endpoint that needs one carries an x-required-entitlement extension and a note in its description in the API reference. You never have to guess which endpoints need which plan — the badge is generated from the same gate the server enforces, so it can't drift.

The 402 upgrade path

If your organization's plan lacks a required entitlement, the request returns 402 Payment Required with a message naming the entitlement to upgrade for:

HTTP/1.1 402 Payment Required

{
  "detail": "API access requires the Professional plan or higher — upgrade to use the API."
}

402 is deliberately distinct from 403 Forbidden:

  • 402 — your plan doesn't include this capability. Upgrade the plan and retry.
  • 403 — you're authenticated, but this user's role isn't permitted the action (role-based access control). Upgrading the plan won't help; the account needs the right permission.

Partner provisioning (Enterprise add-on)

If you build on top of Comflyant — signing up your own customers as separate tenants — you can create and manage their organizations programmatically with POST /v1/organizations (and list them with GET /v1/organizations). Each call creates an isolated tenant org and returns it together with its first API key (the raw key is shown once). See the API reference for the exact shapes.

This requires the partner_provisioning entitlement — an Enterprise add-on, enabled per partner (talk to us to turn it on). Two things are worth knowing about how it behaves:

  • Tenants inherit your plan, and you're billed once. A provisioned tenant has no subscription of its own — it rides your plan's entitlements, so its key works on the API immediately, and everything bills through your one account. If your plan lapses, your tenants lose access with it.
  • Tenants can't provision further tenants. The partner_provisioning capability is never inherited, so provisioning stays one level deep — a tenant you create can use the API but can't mint its own sub-tenants.

A note on data protection: when you provision tenants that handle patient data, you are acting as a sub-processor in the chain between those tenants (the controllers) and Comflyant. Make sure your agreements reflect that.