# Organizations

> One shared plan and balance for a team — members and invites, the active wallet, shared sandboxes, seats and per-member caps.

An **organization** is a shared wallet: one plan, one balance, and the members who run sandboxes on it. Your personal account is a wallet too. Every sandbox bills exactly one wallet.

| | Who can see / use it |
| - | - |
| Sandboxes the organization pays for | Every member sees them; members can use the ones that hold no personal logins |
| Snapshots, named snapshots, environments | Only the person who created them |
| Plan, balance, invoices | Owners manage; members see usage |

## Create and invite

```bash
sbx org create "Acme Robotics"      # you become the owner
sbx org switch acme                 # bill new sandboxes to it
sbx org invite dana@example.com     # owners only
sbx org members                     # members and pending invites
sbx org transfer dana               # hand ownership to dana
```

On the dashboard: **Organization → Invite**. The invitee follows the emailed link, signs in with any method, and the organization appears in their **Viewing** switcher and in `sbx org list`.

To remove members, change roles or set caps, use the dashboard's **Organization** page. When a member leaves, sandboxes they created go back to their personal wallet.

## Which wallet a sandbox bills

In order of precedence:

1. `org` in the create body (`"org": "acme"` or `"personal"`)
2. the `X-Sandboxer-Org` header or `?org=` on the request
3. your **active wallet**, set with `sbx org switch`, `PATCH /orgs/active`, or the dashboard's **Active wallet → Change**
4. personal

```bash
sbx org switch acme               # sticky: CLI, dashboard and API keys without --org
sbx --org personal new            # one-off override
sbx new --personal                # same
```

```bash title="curl"
curl -sS -X PATCH https://sandboxer.com/api/v1/orgs/active \
  -H "Authorization: Bearer $SANDBOXER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"org":"acme"}'
```

Organizations can be named by id (`team_…`) or by name, case-insensitively. If two of your organizations share a name, use the id (`409 ambiguous_org`).

The organization is a **wallet, not a workspace**: `GET /sandboxes` in an organization's scope lists the sandboxes it pays for, with `createdBy` and `access` telling you whose each one is.

## Shared sandboxes

A sandbox you create may hold your personal logins — your GitHub token, your agent-provider keys, your secrets. While it does, teammates can see it and stop it (`access: "view"`) but not get inside.

To hand it to the team:

```bash
sbx share sb_k3v9x2mq
```

Your logins are wiped at the sandbox's next start (`wipePendingUntilRestart: true` until then); from that point every member can open, exec, prompt, stop and resume it (`access: "use"`). Sandboxes created with `noEnv` are usable by the team from the start.

## Seats, limits and caps

- An organization plan is **per seat**: the plan price × seats. Members are seats; owners can buy extra seats on the dashboard.
- Concurrency and start limits are the plan's limits **multiplied by seats**, shared by all members.
- Owners can cap an individual member's concurrent sandboxes. A member over their cap gets `429 member_limit_reached`.
- Owners can also cap a member's machine time per billing period with the API: `PATCH /orgs/{orgId}/members/{userId}` with `usageCapSeconds` (machine-time seconds, counted from the start of the plan period, or over the last month without a plan). Once a member has used that much, their new sandboxes, resumes and forks get `402 team_member_cap_reached`. Running sandboxes keep running. `clearUsageCap: true` removes the cap; `maxActiveSandboxes` and `clearMaxActive` do the same for the concurrency cap.

## Moving a personal plan in

If you paid personally before creating the organization:

```bash
sbx --org acme billing plan 20 --move-personal
# or, if acme already has a plan:
sbx --org acme org migrate
```

From then on, sandboxes billed to your personal account bill the organization. Your personal plan doesn't change: it keeps renewing, and the time it includes stays on your personal wallet, until you cancel it under **Invoices & card** on your personal billing page. Cancelling takes effect at the end of the current period, with no refund. Time packs you bought also stay on your personal wallet.

## API

| Task | Endpoint |
| - | - |
| List your organizations | `GET /orgs` |
| Set the active wallet | `PATCH /orgs/active` |
| Bill one request elsewhere | `X-Sandboxer-Org` header or `?org=` |
| Share a sandbox with the org | `POST /sandboxes/{id}/share` |
| Limits for a wallet | `GET /limits` with `X-Sandboxer-Org` |
