Token Authâ
Courier provides API keys to authenticate your requests. Each workspace has multiple API keys corresponding to different environments (Production/Test) and states (published/draft). You can retrieve your API keys from the API Keys settings page in your workspace.API Key Types
Courier provides four types of API keys, each identified by a unique prefix:- pk_prod_ - Published key for Production environment (use for live notifications)
- dk_prod_ - Draft key for Production environment (use for testing draft templates in production)
- pk_test_ - Published key for Test environment (use for testing without affecting production)
- dk_test_ - Draft key for Test environment (use for testing draft templates in test)
For complete details on environments, API keys, and managing assets across environments, see Environments, API Keys, and Assets.
Using Your API Key
Pass your API key as aBearer Token in an Authorization header with each request. Remember to store your authorization token securely using environment variables or a secure configuration systemânever commit tokens to source control.
- cURL
- Ruby
- Python
- JavaScript
Basic Auth
Basic Auth works by passing a username and password in anAuthorization header. These credentials should be Base64 encoded, which can typically be accomplished using a function or method available in your language of choice. For example, JavaScript provides the btoa() and atob() functions to Base64 encode and decode respectively.
A username of normanosborn@oscorp.com and password of goblin616 are concatenated to normanosborn@oscorp.com:goblin616. This concatenated string becomes âbm9ybWFub3Nib3JuQG9zY29ycC5jb206Z29ibGluNjE2â once it is Base64 encoded.
- cURL
- Ruby
- Python
- JavaScript