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

# API Keys

> Your secret password for talking to Mailofly from your code.

# API Keys 🔑

An API key is how your code proves it's allowed to use your Mailofly account. Think of it as a password — but one that your app uses instead of you typing it in every time.

> [!WARNING]
>
> Your key is shown **one time only** when you create it. Copy it right away — we don't save the full key, only a hash of it.

***

## Creating a key

1. Go to **[API Keys](https://www.mailofly.com/user/api-keys)** in your dashboard
2. Click **Create Key** and give it a name (like `production` or `staging`)
3. Copy the key — it'll start with `mfly_live_`

Then store it as an environment variable so it's not sitting in your code:

```bash theme={null}
export MAILOFLY_API_KEY=mfly_live_your_key_here
```

***

## Using it in your app

Every API request needs this header:

```http theme={null}
Authorization: Bearer mfly_live_your_key_here
```

**In Node.js / TypeScript:**

```ts theme={null}
import { Mailofly } from "@mailofly/node";

const client = new Mailofly({ apiKey: process.env.MAILOFLY_API_KEY! });
```

**With cURL:**

```bash theme={null}
curl https://api.mailofly.com/accounts \
  -H "Authorization: Bearer $MAILOFLY_API_KEY"
```

***

## Tips for keeping your key safe

* 🔑 **One key per service** — if a key leaks, you only have to rotate that one
* 🚫 **Never commit it to git** — seriously, even "just for testing"
* ⏰ **Use short-lived keys** for contractors, staging, or one-off scripts
* 🔄 **Rotate regularly** — especially if you think it might have been exposed

***

## What's next?

* [Connect a sending account](sending-accounts.md) — you'll need an `acc_…` key to actually send emails
* [Node.js quickstart](/docs/getting-started/nodejs.md) — send your first email in 60 seconds
* [API Reference](/docs/api.md) — full docs for every endpoint


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