Prerequisites
- An API key with appropriate permissions (see API Keys and Permissions Reference)
- The Narrative SDK installed in your project
Authentication methods
Environment variable (recommended)
Store your API key in an environment variable to keep it out of source control:- Mac/Linux
- Windows (PowerShell)
- Windows (CMD)
Using a .env file
For local development, use a.env file with a package like dotenv:
.env file in your project root:
Direct configuration
For testing or when credentials are managed externally:Environment selection
The SDK supports multiple environments:Verifying authentication
Test your credentials by making a simple API call:Updating credentials at runtime
You can change the API key after initialization:Security best practices
Troubleshooting
Related content
API Keys
Create and manage API keys
Configuration Reference
Complete configuration options
Error Handling
Handle authentication errors gracefully
Permissions Reference
All available permission resources and access levels

