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

# Authentication

> Configure your Paubox API credentials in a Rails initializer.

## Obtain your credentials

The Email API requires two credentials:

* **API key**: a secret token that authenticates your requests
* **Username**: your Paubox API endpoint username (not your login email)

Both are available in the [Paubox dashboard](https://next.paubox.com) under **API Credentials**.

## Configure the initializer

Create `config/initializers/paubox.rb`:

```ruby theme={null}
Paubox.configure do |config|
  config.api_key  = ENV['PAUBOX_API_KEY']
  config.api_user = ENV['PAUBOX_API_USER']
end
```

The gem registers itself as a Railtie, so this initializer runs before ActionMailer is configured. Credentials are automatically applied to every email delivery — no per-request setup is needed.

## Set environment variables

Add your credentials to your environment (e.g. via a `.env` file with `dotenv-rails`, Rails credentials, or your deployment platform's secret management):

```bash theme={null}
PAUBOX_API_KEY=YOUR_API_KEY
PAUBOX_API_USER=YOUR_USERNAME
```

## Forms client

`PauboxRails::Forms::Client` requires no credentials. Form submissions are associated with the form ID, not an API key.

```ruby theme={null}
client = PauboxRails::Forms.client
```

## Security notes

* Never hard-code credentials in initializer files — always read from environment variables or encrypted credentials.
* The gem does not log API keys or request bodies.
