# Move Email Accounts Beta

> Move accounts between an agency workspace and its client workspaces.

> Documentation index: https://www.foxreach.io/docs/llms.txt lists every page of these docs. Each page is also served as Markdown: add `.md` to its URL.

`POST` https://api.foxreach.io/api/v1/email-accounts/move

> **Note:** **Beta.** This endpoint is new and may change.

Requires an API key with the `write` and `admin` scopes, from a workspace on an agency plan. `X-Workspace-Id` is ignored: the key's own workspace is the anchor.

Moves up to 100 email accounts, one at a time, between the agency workspace and its client workspaces. The target and every source workspace other than the key's own must have the same owner as the key's workspace, and the key's creator must be a member of them (the same rule `X-Workspace-Id` uses). Otherwise the call is `403`, or the account is reported as `not_found`.

## What happens to an account

- **Campaigns.** The account is removed from every campaign of the old workspace, its queued (not yet sent) emails are cancelled, and the leads it had been sending to fall back to the campaign's other accounts. A campaign left with no account stops sending until you add one.
- **Warmup.** Warmup state, limits and history travel with the account.
- **Tags.** Tags belong to a workspace, so all of the account's tags (including warmup pool tags) are dropped. The names are returned in `tagsDropped` so you can tag the account again in the new workspace.
- **History.** Send history stays with the account. Replies already received belong to the old workspace's leads and campaigns and stay there; new replies land in the new workspace.
- **An audit entry** (`audit.email_account.moved`: actor, time, both workspaces, counts, tag names) is written for each moved account in the old workspace and is visible through `GET /api/v1/events`.

An account is refused, and left exactly as it was, when:

| `code` | Reason |
|--------|--------|
| `not_found` | The id does not exist, or its workspace is not one this key may use |
| `same_workspace` | The account is already in the target workspace |
| `managed_mailbox` | The mailbox was bought as a managed inbox and is billed to that order |
| `send_in_progress` | An email is being sent from the account right now. Try again in a minute |
| `email_exists_in_target` | The target workspace already has an account with this address |
| `warmup_identifier_in_use` | The target workspace already uses this warmup identifier |

The response is `200` even when some accounts fail: read `results`. Accounts moved before a failure stay moved.

## Request Body

- `accountIds` string[] body required: Email account ids, 1 to 100.
- `targetWorkspaceId` string body required: The workspace to move the accounts into: the agency workspace or one of its clients.

## Response

- `data` object

  Move result:

  - `results` array: One entry per id, in request order.
  - `succeeded` integer: Accounts moved.
  - `failed` integer: Accounts refused or failed.

**Request example**

```bash cURL
curl -X POST "https://api.foxreach.io/api/v1/email-accounts/move" \
  -H "X-API-Key: otr_your_key" \
  -H "Content-Type: application/json" \
  -d '{"accountIds": ["cmacc1", "cmacc2"], "targetWorkspaceId": "cmclient1"}'
```

```python Python SDK (beta)
from foxreach import FoxReach

client = FoxReach(api_key="otr_your_key")
result = client.email_accounts.move(["cmacc1", "cmacc2"], "cmclient1")
```

```typescript TypeScript SDK (beta)
import { FoxReach } from "foxreach";

const client = new FoxReach({ apiKey: "otr_your_key" });
const result = await client.emailAccounts.move(["cmacc1", "cmacc2"], "cmclient1");
```

**Response example**

```json
{
  "data": {
    "results": [
      {
        "id": "cmacc1", "ok": true,
        "fromWorkspaceId": "cmagency1", "toWorkspaceId": "cmclient1",
        "campaignsDetached": 2, "queuedCancelled": 14, "tagsDropped": ["batch-1"]
      },
      { "id": "cmacc2", "ok": false, "code": "managed_mailbox", "error": "This mailbox is billed to its managed inbox order and cannot be moved." }
    ],
    "succeeded": 1,
    "failed": 1
  }
}
```

## Errors

| Status | Description |
|--------|-------------|
| `401` | Missing, invalid, revoked or expired API key |
| `403` | The key lacks the `write` or `admin` scope, its workspace is not on an agency plan, or it cannot act as the target workspace |
| `422` | `accountIds` is empty or has more than 100 ids |

## Rate Limit

- **100 requests per minute, shared by every `bulk` call in your workspace.** Fixed 60-second window.
- Every response includes `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset` (unix epoch seconds) and `X-RateLimit-Bucket` (`bulk`).
- A `429` response includes a `Retry-After` header (seconds until the bucket resets).

For client-side patterns, see [Rate Limiting](https://www.foxreach.io/docs/rate-limiting).
