# System policies

System policies are admin-managed policies that are visible to every user on the platform. They contain rules just like user policies but are managed centrally.

## How Users See System Policies

Regular users see system policies marked with a **lock icon** and a **"System" badge**. Users can:

* **View** the policy and its rules.
* **Assign** the policy directly to one or more of their projects.
* **Set as default** — make it the default policy for new projects.
* **Copy** — duplicate the policy to create their own editable version.

Users **cannot** edit, delete, or add rules to system policies.

## Managing System Policies

Admins manage system policies from **Admin > Policies** (`/app/admin/policies`). The page uses a split-panel layout.

### Left Panel — Policy List

* **Create** button to add a new system policy.
* **Delete** button to remove a policy (see deletion behavior below).
* Each entry shows the policy name, **rules count**, and **enforcement mode**.

### Right Panel — Rules Management

Select a policy on the left to manage its rules. From this panel you can:

* **Add** new rules to the policy.
* **Edit** existing rules — change conditions, actions, and configuration.
* **Delete** rules you no longer need.
* **Toggle direction** — control whether a rule applies to input, output, or both.
* **Toggle decision** — set whether the rule blocks, flags, or allows matching content.
* **Toggle enabled** — activate or deactivate individual rules without deleting them.

## Deleting a System Policy

When you delete a system policy, CollieAI automatically cleans up all references:

* Any project using the policy as its **active policy** is unlinked (set to none).
* Any user who set the policy as their **default policy** is unlinked (set to none).

This prevents broken references. Affected users and projects will simply have no policy selected until a new one is assigned.

## API Reference

All endpoints require admin authentication. Non-admins receive a `403 Forbidden` response.

### Policies

| Method   | Endpoint                      | Description                           |
| -------- | ----------------------------- | ------------------------------------- |
| `GET`    | `/api/v1/admin/policies`      | List all system policies              |
| `POST`   | `/api/v1/admin/policies`      | Create a new system policy            |
| `PATCH`  | `/api/v1/admin/policies/{id}` | Update a system policy                |
| `DELETE` | `/api/v1/admin/policies/{id}` | Delete a system policy (auto-cleanup) |

Create request body:

```json
{
  "name": "Content Safety",
  "description": "Organization-wide content safety rules",
  "enforcement_mode": "block"
}
```

### Rules

| Method   | Endpoint                                      | Description             |
| -------- | --------------------------------------------- | ----------------------- |
| `GET`    | `/api/v1/admin/policies/{id}/rules`           | List rules for a policy |
| `POST`   | `/api/v1/admin/policies/{id}/rules`           | Add a rule to a policy  |
| `PATCH`  | `/api/v1/admin/policies/{id}/rules/{rule_id}` | Update a rule           |
| `DELETE` | `/api/v1/admin/policies/{id}/rules/{rule_id}` | Delete a rule           |


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.collieai.io/admin-panel/system-policies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
