> For the complete documentation index, see [llms.txt](https://docs.mailofly.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mailofly.com/get-started/api-keys.md).

# Create API key

API keys let your app call the Mailofly REST API and SDKs.

{% hint style="warning" %}
The secret is shown **once**. Copy it immediately — Mailofly only stores a hash.
{% endhint %}

***

## Create a key

1. Open [**API keys**](https://www.mailofly.com/user/api-keys)
2. Click **Create key** and give it a name (e.g. `production`)
3. Copy the value — it starts with `mf_live_`

Store it as an environment variable:

```bash
export MAILOFLY_API_KEY=mf_live_…
```

***

## Use it

Every authenticated request needs:

```http
Authorization: Bearer mf_live_…
```

**SDK example (Node.js):**

```ts
import { Mailofly } from "mailofly";

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

**cURL:**

```bash
curl https://api.mailofly.com/v1/accounts \
  -H "Authorization: Bearer $MAILOFLY_API_KEY"
```

***

## Tips

* One key per service (easier to rotate)
* Never commit keys to git
* Prefer short-lived keys for contractors / staging

***

## Next

* [Connect a sending account](/get-started/sending-accounts.md) — you need an `acc_…` key to send
* [Node.js quickstart](/quickstarts/nodejs.md) — send your first email from code
* [API Reference](https://docs.mailofly.com/api)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mailofly.com/get-started/api-keys.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
