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

# Rust SDK authentication

> Configure Paubox API credentials for the Rust SDK with environment variables, a direct constructor, or a builder with custom timeout and base URL.

## Obtain your credentials

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

## Option 1: Environment variables (recommended)

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

```rust theme={null}
let client = PauboxClient::from_env()?;
```

`from_env()` returns `Err(PauboxError::EnvVar(...))` immediately if the variable is missing or empty.

## Option 2: Direct constructor

```rust theme={null}
let client = PauboxClient::new("YOUR_API_KEY");
```

## Option 3: Builder (with custom timeout or base URL)

```rust theme={null}
use std::time::Duration;

let client = PauboxClient::builder()
    .api_key("YOUR_API_KEY")
    .timeout(Duration::from_secs(15))
    .build()?;
```

Use `.base_url(url)` in tests to point at a mock server.

The SDK sets the `Authorization` header automatically on every request:

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

## Forms client

`FormsClient` requires no credentials:

```rust theme={null}
let forms = FormsClient::new();
```

If you already have a `PauboxClient`, reuse its HTTP connection pool:

```rust theme={null}
let forms = email_client.forms();
```

## Security notes

* Never hard-code credentials in source files.
* The SDK does not log API keys or request bodies.


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