# Withdraw a pending egress request

> POST /v1/egress-requests/{egress_request_id}/withdraw. Withdraws a request that has not been decided.

Source: https://legion.ambient.xyz/docs/api/network/withdraw-egress-request

`POST https://api.legion.ambient.xyz/v1/egress-requests/{egress_request_id}/withdraw`

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

Withdraws a request that has not been decided. Its requester or an owner of the
organization may do it (`rentals.manage`); another member gets `403`. A request of another
organization is `404`.

## Path parameters

- `egress_request_id`, string (uuid), required

## Responses

### 200

The withdrawn request.

- `id`, string (uuid), required
- `scope`, EgressRequestScope, required: The scope in force. Legion may widen a rental request to the organization, so it can differ from `requested_scope`.
- `rental_id`, string (uuid): The rental, when `scope` is `rental`.
- `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: The ports in force. Legion may narrow them, so they can be fewer than `requested_ports`.
- `requested_scope`, EgressRequestScope, required: `rental`: the destination is allowed for one rental and ends with it. `organization`: for every rental of the organization until revoked or `expires_at`.
- `requested_ports`, EgressPorts, required: TCP ports, at most 8.
- `state`, EgressRequestState, required: `pending`: waiting for review. `approved`: on the allow-list. `denied`: refused, with a reason. `withdrawn`: the requester took it back. `expired`: nobody decided within 14 days, the approval's `expires_at` passed, or the rental ended. `revoked`: Legion took the approval away, with a reason.
- `justification`, string, required
- `decision_reason`, string: What the reviewer wrote when denying or revoking (and, optionally, when approving). Never names the reviewer.
- `requested_by`, User, required
  - `id`, string (uuid), required
  - `email`, string (email), required
  - `name`, string, required
- `decided_at`, string (date-time): When Legion approved or denied the request.
- `expires_at`, string (date-time): When the approval ends. Absent until approved, and for an approval without an expiry.
- `created_at`, string (date-time), required

Example:

```json
{
  "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "scope": "rental",
  "rental_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "kind": "domain",
  "pattern": "string",
  "ports": [
    1
  ],
  "requested_scope": "rental",
  "requested_ports": [
    1
  ],
  "state": "pending",
  "justification": "string",
  "decision_reason": "string",
  "requested_by": {
    "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
    "email": "you@example.com",
    "name": "string"
  },
  "decided_at": "2026-10-15T12:00:00Z",
  "expires_at": "2026-10-15T12:00:00Z",
  "created_at": "2026-10-15T12:00:00Z"
}
```

### 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).

### 404

The resource does not exist or belongs to another organization.

### 409

The request is not pending (`egress_request_not_pending`).

### 500

An unexpected server error. Safe to retry.

## Errors

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

## Example request

```sh
curl -s -X POST "https://api.legion.ambient.xyz/v1/egress-requests/$EGRESS_REQUEST_ID/withdraw" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
