> For the complete documentation index, see [llms.txt](https://developer.celigo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.celigo.com/cli/commands/network-policies.md).

# network-policies

Network policies are named IP allow and deny lists that restrict where API tokens, MCP servers, listeners, and workspace-user or end-user sign-in may connect from. A policy restricts nothing until it is assigned: an MCP server's `_networkPolicyId` (`celigo mcp-servers set <id> _networkPolicyId=<policyId>`), a webhook or real-time listener export's (`celigo exports set <id> _networkPolicyId=<policyId>`; `=null` clears it), an API token's (set in the UI), or the account's sign-in settings. Each environment keeps its own policies. Network policies must be enabled for the account, and only the account owner and administrators can manage them.

Entries are IPv4 or IPv6 addresses or CIDR ranges, at most 200 per list. The server stores a bare address as `/32` or `/128` and compresses IPv6, so compare against what `get` returns, not against what you sent. Deny always wins over allow, and an empty `ipAllowList` permits every address that `ipDenyList` does not block.

This command group manages the policies: the standard verbs, `audit`, and `dependencies`, which lists where a policy is assigned.

> Added in celigo-cli 2026.10.1.

> ⚠️ **A policy can lock the CLI out.** In the words of `celigo network-policies --help`: "LOCKOUT: a policy assigned to the API token this profile uses applies to the CLI itself. An allow list that leaves out the address this machine connects from locks the CLI — and every script using that token — out until someone repairs the policy from the UI or with another token. Check `dependencies <id>` before editing a policy, and keep your own egress address on its allow list."

**REST API**: [Network Policies](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies)

```
celigo network-policies <subcommand> [args] [flags]
```

Supports all [global flags](https://developer.celigo.com/cli/getting-started/global-flags.md).

***

## Subcommands

| Subcommand                            | Purpose                                                                                                                                                        |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `list`                                | List the environment's network policies, sorted by `lastModified` or `name`.                                                                                   |
| `get <id>`                            | Fetch one network policy by ID.                                                                                                                                |
| `create`                              | Create a network policy from a JSON body (`--file <path>` or stdin).                                                                                           |
| `update <id>`                         | Full-replace PUT from a JSON body (`--file <path>` or stdin). A list the body leaves out is emptied.                                                           |
| `set <id> key=value …`                | Edit `name`, `description`, `ipAllowList`, and `ipDenyList` as one atomic JSON Patch; any other path through GET + modify + PUT. Supports `key=file://<path>`. |
| `audit <id>`                          | Show the audit log (change history) for one network policy.                                                                                                    |
| `dependencies <id>` (alias `used-by`) | List where the policy is assigned: MCP servers, API tokens, listener exports, and sign-in settings.                                                            |
| `delete <id>`                         | Delete a network policy. `--force` deletes one that is still assigned, clearing every assignment first.                                                        |

***

## `celigo network-policies list`

List the network policies of the profile's environment. `--sort-by` orders them server-side: `lastModified`, the default, lists the most recently changed policy first; `name` lists them alphabetically. Policies in the recycle bin are not listed.

The endpoint refuses the `include`/`exclude` field projection, so rows are trimmed client-side: `--fields` changes what is printed, not what is transferred.

**Signature**

```bash
celigo network-policies list [flags]
```

**Arguments**

None.

**Flags**

| Flag                | Type                   | Default        | Description                                                                                                                                                                                                                                                                         |
| ------------------- | ---------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--sort-by <field>` | `lastModified \| name` | `lastModified` | Sort order. Sent as `sort_by`; any other value is rejected locally.                                                                                                                                                                                                                 |
| `--fields <spec>`   | string                 | `default`      | Fields to return per row. `default` returns `_id`, `name`, and the table columns; `all` returns complete documents; a comma-separated list selects specific fields. Applied client-side — see [field projection](https://developer.celigo.com/cli/getting-started/global-flags.md). |
| `--limit <n>`       | integer                | —              | Return at most `<n>` rows, fetching a single page.                                                                                                                                                                                                                                  |

Default table columns: `_id`, `name`, `ipAllowList`, `ipDenyList`, `lastModified`.

**Example**

```bash
celigo network-policies list --format table

celigo network-policies list --sort-by name --jq '.[] | {_id, name, ipAllowList}'
```

**Corresponds to**: [`GET /v1/networkpolicies`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies) — with `sort_by` and `limit` as query parameters.

***

## `celigo network-policies get`

Fetch one network policy by ID. Its lists hold the stored form of each entry: a bare address carries `/32` or `/128`, and IPv6 is compressed.

**Signature**

```bash
celigo network-policies get <id>
```

**Arguments**

| Argument | Type   | Required | Description           |
| -------- | ------ | -------- | --------------------- |
| `<id>`   | string | Yes      | Network policy `_id`. |

**Flags**

Uses [global flags](https://developer.celigo.com/cli/getting-started/global-flags.md) only.

**Example**

```bash
celigo network-policies get 5f83a9b2c7d3e8f1a2b3c4d5 --jq '{name, ipAllowList, ipDenyList}'
```

**Corresponds to**: [`GET /v1/networkpolicies/{_id}`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies)

***

## `celigo network-policies create`

Create a network policy from a JSON body. Read the body from a file with `-f, --file` (recommended), or pipe it on stdin. The new policy restricts nothing until you assign it — for an MCP server, with `celigo mcp-servers set <id> _networkPolicyId=<policyId>`; for a webhook or real-time listener export, since celigo-cli 2026.11.2, with `celigo exports set <id> _networkPolicyId=<policyId>`. Requires `full` mode.

**Signature**

```bash
celigo network-policies create --file <path>
celigo network-policies create < policy.json     # or pipe on stdin
```

**Arguments**

None.

**Flags**

| Flag                | Type   | Default | Description                                                                    |
| ------------------- | ------ | ------- | ------------------------------------------------------------------------------ |
| `-f, --file <path>` | string | —       | Read the JSON body from a file instead of stdin (`--file -` also means stdin). |

**Request body**

| Field         | Required | Description                                                                                                                   |
| ------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `name`        | Yes      | Display name. Another policy in the environment that is not in the recycle bin may not hold the same name.                    |
| `description` | No       | What the policy is for.                                                                                                       |
| `ipAllowList` | No       | Addresses or CIDR ranges permitted to connect, at most 200. Empty or omitted: every address that `ipDenyList` does not block. |
| `ipDenyList`  | No       | Addresses or CIDR ranges refused even when `ipAllowList` permits them, at most 200.                                           |

**Example**

```bash
cat > policy.json <<'EOF'
{
  "name": "Corporate VPN egress",
  "description": "Office and VPN egress ranges",
  "ipAllowList": ["10.0.0.0/8", "203.0.113.5", "2001:db8::/32"],
  "ipDenyList": ["198.51.100.0/24"]
}
EOF
celigo network-policies create --file policy.json
```

**Corresponds to**: [`POST /v1/networkpolicies`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies)

***

## `celigo network-policies update`

Full-replace PUT from a JSON body (`--file <path>` or stdin). The change applies at once to every API token, MCP server, listener export, and sign-in setting the policy is assigned to. Requires `full` mode.

> ⚠️ **`update` replaces the whole policy.** A list the body leaves out is emptied, which lifts every restriction it imposed, and an omitted `description` is removed. Send the complete policy, or use `set`, which changes only the fields you name.

**Signature**

```bash
celigo network-policies update <id> --file <path>
celigo network-policies update <id> < policy.json     # or pipe on stdin
```

**Arguments**

| Argument | Type   | Required | Description           |
| -------- | ------ | -------- | --------------------- |
| `<id>`   | string | Yes      | Network policy `_id`. |

**Flags**

| Flag                | Type    | Default | Description                                                                               |
| ------------------- | ------- | ------- | ----------------------------------------------------------------------------------------- |
| `-f, --file <path>` | string  | —       | Read the JSON body from a file instead of stdin (`--file -` also means stdin).            |
| `--force`           | boolean | `false` | Submit even if the body contains masked credential values (`"******"`) copied from a GET. |

**Example**

```bash
celigo network-policies update 5f83a9b2c7d3e8f1a2b3c4d5 --file policy.json
```

**Corresponds to**: [`PUT /v1/networkpolicies/{_id}`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies)

***

## `celigo network-policies set`

Edit fields with `key=value` assignments. `name`, `description`, `ipAllowList`, and `ipDenyList` are the server's PATCH whitelist: an assignment that touches only those is sent as one atomic JSON Patch. A list assignment replaces the whole list, so pass the complete list as a JSON array (`ipAllowList='["10.0.0.0/8","203.0.113.5"]'`). `description=null` removes the description.

Any other path goes through GET → modify → PUT with the complete document: a single list entry by index (`ipAllowList[0]=…`), and a list assigned `null` (`ipAllowList=null`), which clears the list.

`set` is blocked in `read` mode, and the group has no field that `operate` mode may set, so `set` needs `full` mode. See [Profiles & regions](https://developer.celigo.com/cli/getting-started/profiles.md#permission-modes).

**Signature**

```bash
celigo network-policies set <id> <key=value> [key=value ...]
```

**Arguments**

| Argument      | Type   | Required | Description                                                                                         |
| ------------- | ------ | -------- | --------------------------------------------------------------------------------------------------- |
| `<id>`        | string | Yes      | Network policy `_id`.                                                                               |
| `<key=value>` | string | Yes (≥1) | Field assignments, for example `name="Corporate VPN egress"` or `ipDenyList='["198.51.100.0/24"]'`. |

**Flags**

Uses [global flags](https://developer.celigo.com/cli/getting-started/global-flags.md) only.

**Example**

```bash
# Replace the allow list — one atomic JSON Patch
celigo network-policies set 5f83a9b2c7d3e8f1a2b3c4d5 \
  ipAllowList='["10.0.0.0/8","203.0.113.5","2001:db8::/32"]'

# Rename the policy and drop its description
celigo network-policies set 5f83a9b2c7d3e8f1a2b3c4d5 name="VPN egress (2026)" description=null
```

**Corresponds to**: [`PATCH /v1/networkpolicies/{_id}`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies) for the four whitelisted fields; otherwise [`GET /v1/networkpolicies/{_id}`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies) then [`PUT /v1/networkpolicies/{_id}`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies).

***

## `celigo network-policies audit`

Show the audit log (change history) for one network policy. The CLI reads every page.

**Signature**

```bash
celigo network-policies audit <id>
```

**Arguments**

| Argument | Type   | Required | Description           |
| -------- | ------ | -------- | --------------------- |
| `<id>`   | string | Yes      | Network policy `_id`. |

**Flags**

Uses [global flags](https://developer.celigo.com/cli/getting-started/global-flags.md) only.

**Example**

```bash
celigo network-policies audit 5f83a9b2c7d3e8f1a2b3c4d5 --format table
```

**Corresponds to**: [`GET /v1/networkpolicies/{_id}/audit`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies)

***

## `celigo network-policies dependencies`

List where the policy is assigned: MCP servers, API tokens, listener exports (webhook and real-time), and workspace-user or end-user sign-in per environment. Aliased as `used-by`. Run it before you edit or delete a policy — the result is what an edit affects, and what `delete --force` would clear.

The API answers a fixed object — `mcpservers`, `accesstokens`, `exports`, and `account` — rather than the map the other groups' `dependencies` return, and JSON output prints it as returned. `--format table` lists one row per assignment, with the columns `assignedTo` (`mcpServer`, `apiToken`, `listenerExport`, `workspaceUserSignIn`, or `endUserSignIn`), `_id`, and `name`, and prints `Not assigned anywhere.` when there is none. An unassigned policy restricts nothing, and `delete` needs no `--force`.

Since celigo-cli 2026.11.2, the table lists the listener exports under `exports` as `listenerExport` rows, and a `--jq` expression reads the API's object under `--format table` too. Earlier releases left those rows out of the table and ran the expression on the table's rows.

**Signature**

```bash
celigo network-policies dependencies <id>
celigo network-policies used-by <id>     # alias
```

**Arguments**

| Argument | Type   | Required | Description           |
| -------- | ------ | -------- | --------------------- |
| `<id>`   | string | Yes      | Network policy `_id`. |

**Flags**

Uses [global flags](https://developer.celigo.com/cli/getting-started/global-flags.md) only.

**Example**

```bash
celigo network-policies dependencies 5f83a9b2c7d3e8f1a2b3c4d5 --format table

# Just the MCP servers the policy restricts
celigo network-policies dependencies 5f83a9b2c7d3e8f1a2b3c4d5 --jq '.mcpservers'

# The listener exports the policy restricts
celigo network-policies dependencies 5f83a9b2c7d3e8f1a2b3c4d5 --jq '.exports'
```

**Corresponds to**: [`GET /v1/networkpolicies/{_id}/dependencies`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies)

***

## `celigo network-policies delete`

Delete a network policy. A policy that is still assigned is refused with `409 network_policy_in_use` and nothing changes; the error names the two ways forward:

```
Hint: List the assignments with: celigo network-policies dependencies 5f83a9b2c7d3e8f1a2b3c4d5. To clear them all and delete the policy anyway (every assignee loses the restriction): celigo network-policies delete 5f83a9b2c7d3e8f1a2b3c4d5 --force
```

`--force` clears the policy from every API token, MCP server, listener export, and sign-in setting it is assigned to, then deletes it, so each former assignee loses the restriction. Prompts for confirmation unless `-y` is supplied; with `--force` the question names what is cleared. Requires `full` mode.

> ⚠️ **Do not rely on restoring a deleted policy.** The API documents 30 days in the recycle bin for a deleted policy, but a deleted policy can be missing from the bin. Keep a copy of the policy's lists before you delete it, and check `celigo recycle-bin get <id>` afterward.

**Signature**

```bash
celigo network-policies delete <id> [--force] [-y]
```

**Arguments**

| Argument | Type   | Required | Description           |
| -------- | ------ | -------- | --------------------- |
| `<id>`   | string | Yes      | Network policy `_id`. |

**Flags**

| Flag        | Type    | Default | Description                                                                               |
| ----------- | ------- | ------- | ----------------------------------------------------------------------------------------- |
| `--force`   | boolean | `false` | Clear the policy from everything it is assigned to, then delete it. Sent as `force=true`. |
| `-y, --yes` | boolean | `false` | Skip the confirmation prompt.                                                             |

**Example**

```bash
celigo network-policies dependencies 5f83a9b2c7d3e8f1a2b3c4d5
celigo network-policies delete 5f83a9b2c7d3e8f1a2b3c4d5 -y
```

**Corresponds to**: [`DELETE /v1/networkpolicies/{_id}`](https://developer.celigo.com/api/api-reference/account-and-admin/network-policies) — with `force=true` under `--force`. [`recycle-bin get <id>`](https://developer.celigo.com/cli/commands/recycle-bin.md#celigo-recycle-bin-get) shows whether the deleted policy is in the bin to restore.

***

## Gotchas

* **A policy on your own token applies to the CLI.** Before you narrow an allow list, check `dependencies <id>` for the API token your profile uses, and keep the address this machine connects from on the list. Until someone repairs the policy from the UI or with another token, the CLI and every script using that token stay locked out.
* **`update` empties what it does not carry.** A list the body leaves out becomes empty — lifting every restriction it imposed — and an omitted `description` is removed. Prefer `set`.
* **A list assignment replaces the whole list.** `set ipAllowList='[…]'` sends the complete list as one PATCH. To add one entry, read the list with `get`, then assign the full list back.
* **The server normalizes entries.** A bare address is stored as `/32` (IPv4) or `/128` (IPv6), and IPv6 is compressed. A script that compares what it sent with what `get` returns must compare the stored form.
* **An assigned policy cannot be deleted without `--force`.** The plain `delete` answers `409 network_policy_in_use` and changes nothing. `--force` clears every assignment first, which leaves every former assignee unrestricted.
* **A deleted policy may not be restorable.** The API documents 30 days in the recycle bin for a deleted policy, but a deleted policy can be missing from the bin. Keep a copy of the lists before you delete, and check `celigo recycle-bin get <id>` afterward.
* **Other groups take the group name for the type.** `recycle-bin list --type network-policies` and `audit list --resource-type network-policies` reach the API's own spellings — `networkpolicies` in the recycle bin, `networkpolicy` in the audit log — and `recycle-bin restore <id>` routes a deleted policy correctly. Once a policy is purged from the recycle bin, its `audit` route answers `404`; `celigo audit list --resource-type network-policies` still lists the entries.
* **Permission modes.** `list`, `get`, `audit`, and `dependencies` work in `read` mode. `create`, `update`, `set`, and `delete` need `full` — `set` included, because no network-policy field is an operational one. See [Profiles & regions](https://developer.celigo.com/cli/getting-started/profiles.md#permission-modes).

## Related

* [mcp-servers](https://developer.celigo.com/cli/commands/mcp-servers.md) — assign a policy to an MCP server with `set <id> _networkPolicyId=<policyId>`.
* [exports](https://developer.celigo.com/cli/commands/exports.md) — assign a policy to a webhook or real-time listener export with [`set <id> _networkPolicyId=<policyId>`](https://developer.celigo.com/cli/commands/exports.md#celigo-exports-set-less-than-id-greater-than-assignments).
* [recycle-bin](https://developer.celigo.com/cli/commands/recycle-bin.md) — `recycle-bin get <id>` shows whether a deleted policy is in the bin to restore or purge.
* [audit](https://developer.celigo.com/cli/commands/audit.md) — the account-wide audit log, which keeps a purged policy's history.
* [environments](https://developer.celigo.com/cli/commands/environments.md) — each environment keeps its own network policies.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.celigo.com/cli/commands/network-policies.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
