Skip to main content

Obtain your credentials

The Email API service requires one credential:
  • API key: a secret token that authenticates your requests
It is available in the Paubox dashboard under API Credentials. Create a .env file in your project root:
The SDK reads API_KEY from process.env but does not load .env files itself. Load the file with dotenv (npm install dotenv) before creating the service, then call the factory with no arguments:

Option 2: Direct configuration

Pass the API key explicitly to the factory:
The service factory throws immediately if the API key is missing, so errors surface at startup rather than at send time. The SDK sets the Authorization header automatically on every request:

Forms service

getForm and submitForm are public and need no credentials:
All other formService methods need an API key with the forms scope, sent as Authorization: Bearer YOUR_API_KEY. Set FORMS_API_KEY in the environment, or pass it directly. FORMS_BASE_URL (or the baseURL option) overrides the default https://api.paubox.com/v1/forms.

Security notes

  • Add .env to your .gitignore; never commit credentials to source control.
  • In production, prefer your platform’s secret management (environment variables injected by your hosting provider) over .env files.