Skip to main content

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 a Bearer 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
curl --request POST \
     --url https://api.courier.com/send \
     --header 'Authorization: Bearer <token>'

Basic Auth

Basic Auth works by passing a username and password in an Authorization 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
curl --request POST \
     --url https://api.courier.com/send \
     --header 'Authorization: Basic <Base64 encoded string>'
To authenticate with the Courier REST API, use the email associated with your account as the username and the Auth Token as your password.