> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paubox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js SDK authentication

> Configure Paubox API credentials for the Node.js SDK with environment variables or direct configuration, plus Forms service setup and key security notes.

## 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](https://next.paubox.com) under **API Credentials**.

## Option 1: Environment variables (recommended)

Create a `.env` file in your project root:

```bash theme={null}
API_KEY=YOUR_API_KEY
```

The SDK loads this automatically via `dotenv`. Call the factory with no arguments:

```javascript theme={null}
const pbMail  = require('paubox-node');
const service = pbMail.emailService();
```

## Option 2: Direct configuration

Pass the API key explicitly to the factory:

```javascript theme={null}
const service = pbMail.emailService({
  apiKey: 'YOUR_API_KEY'
});
```

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:

```
Authorization: Token token=YOUR_API_KEY
```

## Forms service

`formService` requires no credentials:

```javascript theme={null}
const formsService = pbMail.formService();
```

## 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.