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 in the x-api-key header.
curl -X GET "https://api.fhirfly.io/v1/ndc/0069-0151-01" \
-H "x-api-key: ffly_sk_live_abc123..."
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.
1. Create a Secure Credential
Create a Secure credential in your dashboard to get a client_id and client_secret.
2. Exchange for Access Token
curl -X POST "https://api.fhirfly.io/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET" \
-d "scope=ndc:read npi:read"
3. Use the Access Token
curl -X GET "https://api.fhirfly.io/v1/ndc/0069-0151-01" \
-H "Authorization: Bearer eyJhbGciOiJSUzI1..."
Token Lifetime
- Access tokens expire after 1 hour
- Request a new token when expired
- No refresh tokens for client credentials flow
MCP (Model Context Protocol)
Connect FHIRfly directly to AI assistants like Claude Desktop.
See MCP Integration for setup instructions.
Scopes
Scopes control what data your credential can access:
| Scope | Description |
|---|---|
ndc.read | Read NDC drug data |
ndc.batch | Batch NDC lookups |
npi.read | Read NPI provider data |
npi.batch | Batch NPI lookups |
rxnorm.read | Read RxNorm data |
loinc.read | Read LOINC codes |
icd10.read | Read ICD-10 codes |
cvx.read | Read CVX vaccine codes |
mvx.read | Read MVX manufacturer codes |
fda.read | Read FDA drug labels |
Security Best Practices
- Never expose API keys in client-side code - Use server-side requests only
- Rotate keys regularly - Use the dashboard to rotate compromised keys
- Use minimal scopes - Only request the scopes you need
- Monitor usage - Check your dashboard for unusual activity