Authentication
FHIRfly supports multiple authentication methods to fit different use cases.
Authentication Methods
| Method | Best For | Header |
|---|---|---|
| API Key | Server-side integrations | x-api-key: YOUR_KEY |
| OAuth2 | Enterprise applications | Authorization: Bearer TOKEN |
| MCP | AI assistants (Claude) | Configured via MCP server |
API Keys (Simple Credentials)
The simplest way to authenticate. Create an API key in your dashboard and include it with every request.
Setup
Node.js
import { Fhirfly } from "@fhirfly-io/terminology";
const client = new Fhirfly({ apiKey: "ffly_sk_live_abc123..." });
// The SDK sends the API key via the x-api-key header automatically
const ndc = await client.ndc.lookup("0069-0151-01");
console.log(ndc.data.brand_name);
Creating an API Key
- Go to Dashboard → Credentials
- Click Create Credential
- Select Simple (API Key)
- Choose your scopes (e.g.,
ndc.read,npi.read) - Copy your API key (shown only once!)
API Key Format
ffly_sk_live_abc123... # Production key
ffly_sk_test_abc123... # Test/sandbox key
OAuth2 Client Credentials
For enterprise applications that need short-lived tokens and stricter security.
Setup
Node.js
import { Fhirfly } from "@fhirfly-io/terminology";
const client = new Fhirfly({
clientId: "ffly_client_...",
clientSecret: "ffly_secret_...",
// tokenUrl defaults to "https://api.fhirfly.io/oauth2/token"
});
// The SDK automatically exchanges credentials, caches the token,
// refreshes before expiry, and retries on rejection
const ndc = await client.ndc.lookup("0069-0151-01");
console.log(ndc.data.brand_name);
Creating a Secure Credential
- Go to Dashboard → Credentials
- Click Create Credential
- Select Secure (OAuth2)
- Choose your scopes
- Copy your
client_idandclient_secret(secret shown only once!)
Token Lifetime
- Access tokens expire after 10 minutes
- The SDK automatically refreshes tokens before expiry
- No refresh tokens — use the client credentials grant again
Next Steps
- Scopes — Control what data your credentials can access
- Security — Security model and best practices
- MCP Integration — Connect FHIRfly to AI assistants like Claude