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

# PHP SDK authentication

> Configure your Paubox API key for the PHP SDK with a .env file, plus Forms client setup and security notes for handling the key.

## Obtain your API key

The Email API client 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**.

## Create a .env file

Add your API key to a `.env` file at your project root:

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

The SDK reads `PAUBOX_API_KEY` with `getenv()` but does not load `.env` files. Load it with `vlucas/phpdotenv` (installed with the SDK) before creating the client; no constructor arguments are needed:

```php theme={null}
require_once __DIR__ . '/vendor/autoload.php';

Dotenv\Dotenv::createUnsafeImmutable(__DIR__)->load();

$paubox = new Paubox\Paubox();
```

Any other way of setting the `PAUBOX_API_KEY` environment variable also works.

`Paubox\Paubox` sets this `Authorization` header on every request:

```
Authorization: Bearer YOUR_API_KEY
```

`Paubox\PauboxReceiving` takes the same key as a constructor argument, or reads `PAUBOX_API_KEY` when it is omitted. It sends it in the legacy `Authorization: Token token=YOUR_API_KEY` format, which the Email API also accepts.

`Paubox\PauboxWebhooks` needs a scoped API key, sent as `Authorization: Bearer YOUR_API_KEY`. Pass it to the constructor, or set `PAUBOX_WEBHOOKS_API_KEY`. See [Webhook client](https://docs.paubox.com/php-sdk/webhook-client.md).

## Forms client

`getForm` and `submitForm` on `Paubox\PauboxForms` require no credentials. Form submissions are associated with the form ID, not an API key.

```php theme={null}
$forms = new Paubox\PauboxForms();
```

The form management methods (for example `listForms`, `createForm`, and `listSubmissions`) require a scoped API key with the `forms` scope. It can be the same key as `PAUBOX_API_KEY` if that key also has the `forms` scope. Pass it to the constructor or set `PAUBOX_FORMS_API_KEY`:

```php theme={null}
$forms = new Paubox\PauboxForms('YOUR_FORMS_API_KEY');
```

## Security notes

* Never commit `.env` files to source control. Add `.env` to your `.gitignore`.
* The SDK does not expose credentials in error messages or logs.


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