# Update org egress mode

> PUT /v1/network/egress-mode. .

Source: https://legion.ambient.xyz/docs/api/network/update-org-egress-mode

`PUT https://api.legion.ambient.xyz/v1/network/egress-mode`

Authenticate with an API key: `Authorization: Bearer $LEGION_API_KEY`.

. An owner's switch for the organization's egress mode. `require_allowlist: true`
sets the organization's mode to `enforce`: rentals the organization creates from then on
can reach only the allow-list. `false` sets it back to `inherit`: new rentals start in the
platform's default mode (`mode` in the answer says which; today that is `audit`, open). Rentals already running keep the mode they started in, either way: no running rental
changes and no network `revision` moves. A host that requires the allow-list still starts
its rentals in `enforce`.

Turning it on needs an approved host whose agent enforces the allow-list
(`egress_enforce_v1`), else 409 `enforce_unavailable`; turning it off always works unless
Legion staff set the mode. When Legion set the organization's mode
(`org_egress_mode_set_by` `admin` on `getEgressAllowlist`), an owner cannot change it:
409 `egress_mode_set_by_admin`, nothing changed; ask support. Repeating the current value
changes and records nothing.

Each change is recorded in the transaction: a network policy event of the organization
(`org_network_policy.update`, with who acted) and the event `org.egress_mode_changed`
(`org_id`, `user_id`, `old_egress_mode`, `new_egress_mode`, `client`). Needs
`network.manage` (owners). Not an MCP tool: it is a security setting of the organization.

## Request body

- `require_allowlist`, boolean, required: `true`: rentals the organization creates from now on can reach only the allow-list (`enforce`). `false`: they start in the platform's default mode (`inherit`). Running rentals never change.

Example:

```json
{
  "require_allowlist": false
}
```

## Responses

### 200

The allow-list, with the organization's mode and who set it.

- `mode`, EgressMode, required: `audit`: everything public is reachable; what the allow-list would block is recorded. `enforce`: only the allow-list is reachable. `open`: no allow-list (set by Legion for an organization, with a recorded reason). Private networks and email port 25 are blocked in every mode.
- `entries`, array of EgressEntry, required: Sorted by kind, then pattern, then source.
  - `kind`, EgressKind, required: `domain`: a host name (`example.com`) or `*.example.com` for every subdomain, never a public suffix. Lowercase, with internationalized names in their `xn--` form. `cidr`: an IPv4 range in canonical form (`203.0.113.0/24`), never inside private or reserved space.
  - `pattern`, string, required
  - `ports`, EgressPorts, required: TCP ports, at most 8.
  - `source`, string, required: Who granted the destination.
  - `category`, EgressCategory: What the destination is for.
  - `expires_at`, string (date-time): When an approval ends. Absent for the platform's defaults and for approvals without an expiry.
- `pending_requests`, integer: How many egress requests are waiting for review that would add to this list (the organization's, and for a rental also the rental's).
- `enforce_cutover_at`, string (date-time): When rentals that run in `audit` switch to `enforce` (decision D2). Present only while the platform's enforcement of new rentals is on and the date is set; a rental whose `mode` is `audit` shows it as the dated notice.
- `org_egress_mode`, OrgEgressMode: The organization's own egress mode: `enforce` when its new rentals are held to the allow-list, `inherit` when they start in the platform's default. On `getEgressAllowlist` and `updateOrgEgressMode` only, never on a rental's network.
- `org_egress_mode_set_by`, OrgEgressModeSetBy: Who set `org_egress_mode`: `owner` (an owner, with `updateOrgEgressMode`) or `admin` (Legion staff; an owner cannot change it). Absent while the mode is `inherit`.

Example:

```json
{
  "mode": "audit",
  "entries": [
    {
      "kind": "domain",
      "pattern": "string",
      "ports": [
        1
      ],
      "source": "platform",
      "category": "code",
      "expires_at": "2026-10-15T12:00:00Z"
    }
  ],
  "pending_requests": 0,
  "enforce_cutover_at": "2026-10-15T12:00:00Z",
  "org_egress_mode": "inherit",
  "org_egress_mode_set_by": "owner"
}
```

### 400

The request is malformed or fails validation. An image reference that
is not a container image reference answers `invalid_image_reference`.

### 401

Missing, unknown, expired or revoked credentials.

### 403

The caller lacks the permission this operation requires (`forbidden`),
or signed in without having joined an organization yet
(`no_organization`; `getOnboarding` and the invitation and
organization operations under it work), or could not sign in
(`email_unverified`, `account_conflict`, and `domain_not_allowed`). `not_invited` is no longer returned to
session tokens.

`access_not_approved`: a signed-in person who is not approved
for the beta yet. Every operation that takes a credential answers it to
them, except `getMe` and `joinMyWaitlist`; the problem carries
`access` (`waitlisted` or `not_requested`, and the email). Approved
means a member of an organization, holding a pending invitation, or Legion; an API key always belongs to a member.

`oauth_token_mcp_only`: the caller sent an OAuth access token (`lgo_`), which is accepted
only by `mcpMessage` and the tool calls it dispatches. Every other operation answers it, whatever
the token's scope. Use an API key or the Legion web app.

`org_suspended`: the caller's organization is suspended. Every operation that takes a
credential answers it, by session or API key, except `getMe` (which shows `org.suspended_at` and
`org.suspension_reason`) and the support operations under `/v1/support/`.

`terms_not_accepted`: an approved caller who has not accepted
the current version of the Terms of Use and the Acceptable Use Policy. Every operation that takes a credential answers it, except `getMe`,
`acceptLegalDocuments`, `joinMyWaitlist` and the wind-down operations
(`listRentals`, `stopRental`, `deleteRental`, `listHosts`,
`updateListing` with `listed` false, `removeHost`); the problem
carries `legal`. An API key acts for the person who created it, so it
is refused until that person accepts. Terminal
operations also return
`session_required` (called with an API key) and `step_up_required`
(neither a sign-in nor a step-up challenge within the step-up window).

### 409

`require_allowlist` is true and no approved host's agent enforces the allow-list
(`enforce_unavailable`), or Legion set the organization's mode
(`egress_mode_set_by_admin`). Nothing is changed.

### 500

An unexpected server error. Safe to retry.

## Errors

- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)
- 409 [`enforce_unavailable`](https://legion.ambient.xyz/docs/errors#enforce_unavailable)
- 409 [`egress_mode_set_by_admin`](https://legion.ambient.xyz/docs/errors#egress_mode_set_by_admin)

## Example request

```sh
curl -s -X PUT "https://api.legion.ambient.xyz/v1/network/egress-mode" \
  -H "Authorization: Bearer $LEGION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "require_allowlist": false
}'
```
