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

# Managing multiple accounts

> Operate several lemlist accounts from a single integration — the agency setup.

Agencies and power users often run many lemlist accounts at once. You do not
need a separate tool for that: every request is already scoped to one account,
and you pick the account simply by choosing which credential you send.

## One key, one account

A lemlist API key (or OAuth token) resolves to exactly **one** account. There is
no `account` parameter and no separate login step — the credential *is* the
account selector.

To work across several accounts, generate **one API key per account** (each
account owner creates their own key, see [Authentication](/api-reference/getting-started/authentication))
and store them together. Switching account then means switching the key you
send.

<Note>
  Keep each key as securely as a password, and never mix them up between clients.
</Note>

## Switching account over the REST API

Authentication is [HTTP Basic](/api-reference/getting-started/authentication)
with an empty username and the API key as the password. Switching account is
just switching the key:

<CodeGroup>
  ```bash Client X theme={"theme":"dracula"}
  curl --location 'https://api.lemlist.com/api/campaigns' \
    --user ":$CLIENT_X_API_KEY"
  ```

  ```bash Client Y theme={"theme":"dracula"}
  curl --location 'https://api.lemlist.com/api/campaigns' \
    --user ":$CLIENT_Y_API_KEY"
  ```
</CodeGroup>

`curl --user ":$KEY"` builds the `:APIKey` string and Base64-encodes it into the
`Authorization: Basic …` header for you.

## Switching account over the MCP server

The [MCP server](/mcp/setup) works the same way, and supports both
authentication modes:

* **API key** — send that account's key in the `X-API-Key` header. One key, one
  account.
* **OAuth** — the consent screen asks you to pick a team, so each connection is
  bound to a single account. To manage several, add **one connector per
  account** (name them `lemlist-client-x`, `lemlist-client-y`, …).

## Looping over all your accounts

Because the account is just the key, iterating over every client is a plain
loop:

```bash theme={"theme":"dracula"}
declare -A KEYS=(
  [client-x]="$CLIENT_X_API_KEY"
  [client-y]="$CLIENT_Y_API_KEY"
  [client-z]="$CLIENT_Z_API_KEY"
)

for client in "${!KEYS[@]}"; do
  curl --silent --location 'https://api.lemlist.com/api/campaigns' \
    --user ":${KEYS[$client]}" > "sync/$client.json"
done
```

## The lemlist CLI

The [lemlist CLI](https://www.npmjs.com/package/@lemlist-official/cli) packages
this whole page into one command, with named profiles per account:

```bash theme={"theme":"dracula"}
npm install -g @lemlist-official/cli

lemlist auth login                # OAuth: opens the browser, no key to copy
lemlist auth add client-x <key>   # or store an API key under a profile
lemlist auth list                 # * marks the active profile
```

Switching account becomes explicit instead of key juggling:

```bash theme={"theme":"dracula"}
lemlist auth use client-x                       # set the active account
lemlist --account client-y api GET /campaigns   # one-off override
LEMLIST_PROFILE=client-y lemlist api GET /campaigns
```

Every endpoint of this API is reachable through `lemlist api <METHOD> <path>`
(plus named subcommands like `lemlist campaigns list` — run
`lemlist endpoints` to discover the surface). Output is JSON on stdout with
stable exit codes, so it pipes into `jq`, scripts and AI agents, and transient
failures (`429`, `5xx`) are retried with exponential backoff honoring
[rate limits](/api-reference/getting-started/rate-limits).

OAuth tokens refresh automatically; profiles are stored in
`~/.lemlist/config.json` (file mode `0600`).

***

[give us feedback on this page](https://lemlist.typeform.com/to/mfVlkyGf)


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