> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zerodrift.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage Custom Rules Created Through the API

> Where a rule made with POST /api/policies/rules appears in Policy Studio, and how to edit, turn off, or delete it.

There are two ways to get a custom rule:

* **Import a policy.** ZeroDrift extracts rules from your document. Each rule has the policy's `import_id` and shows on that policy's page in Policy Studio. See [Import a Policy](https://docs.zerodrift.com/guides/import-a-policy.md).
* **Create one rule through the API** with [Create Custom Rule](https://docs.zerodrift.com/api-reference/custom-policies/create-rule.md) (`POST /api/policies/rules`). The request has no policy field, so the rule belongs to no policy and has no `import_id`.

This page covers the second kind.

## Where the rule appears

In ZeroDrift Command, open **Policy Studio**. Rules that belong to no policy are listed under **API-created rules**, below **Custom Policies**. They are not listed under any policy.

![Policy Studio API-created rules section with one rule: AI Assisted, Don't send, Created through the API, Active](https://mintcdn.com/zerodrift/E5J9wgilbGRbWSMv/images/policy-studio-api-created-rules.png?fit=max\&auto=format\&n=E5J9wgilbGRbWSMv\&q=85\&s=36f41488c54d7ef0fc681ed18407943d)

The section's help text reads:

> These rules are enforced but don't belong to any policy, so they can't be edited here. You can delete one here, or manage them through the API.

If your role can't delete rules, the second sentence reads "Manage them through the API." instead.

The table has five columns. Policy Studio shows the labels in capitals.

| Column | Shows |
| - | - |
| **Rule** | The rule's `name`, or its `rule_id` when it has no name |
| **Type** | `AI_SIGNAL` shows as **AI Assisted**, `REGEX` as **Keyword**, `REQUIRE_NEAR` as **Disclosure Check** |
| **Severity** | `do_not_send` shows as **Don't send**, `send_with_caution` as **Send with caution** |
| **Source** | Where the rule came from. See below. |
| **Status** | **Active** or **Inactive** |

### Source

| Source | Meaning |
| - | - |
| **Created through the API** | Made with `POST /api/policies/rules`. The rule has no `import_id`. |
| **From an import no policy uses** | Extracted from a policy import that no policy in Policy Studio uses any more, for example after the policy was deleted. The rule still has that `import_id`. |

## Enforcement

An active rule in this section is a custom rule like any other. Untrained custom rules run on **Max** (`anchor_3_0_max`). A Max request with no `validation_scope` checks them all. If you supply a scope, only the selected rules run; naming a custom rule's `rule_id` in `validation_scope.rules` upgrades Flagship to Max. A Flagship request with no scope does not check them. See [Enforce Content](https://docs.zerodrift.com/api-reference/validate/validate-content.md).

## Edit the rule

These rules can't be edited in Policy Studio. Use the API:

| To | Call |
| - | - |
| Change the name, content, severity, or action | `PATCH /api/policies/rules/{rule_id}` ([Edit Custom Rule](https://docs.zerodrift.com/api-reference/custom-policies/edit-rule.md)) |
| Turn the rule off | `POST /api/policies/rules/deactivate` with `rule_ids` ([Deactivate Rules](https://docs.zerodrift.com/api-reference/custom-policies/deactivate-rules.md)) |
| Turn the rule back on | `POST /api/policies/rules/activate` with `rule_ids` ([Reactivate Rules](https://docs.zerodrift.com/api-reference/custom-policies/reactivate-rules.md)) |
| Read the full definition | `GET /api/policies/rules/{rule_id}` ([Get Custom Rule](https://docs.zerodrift.com/api-reference/custom-policies/get-rule.md)) |
| List only the custom rules that run | `GET /api/policies/rules?status=active&source=custom` ([List Rules](https://docs.zerodrift.com/api-reference/custom-policies/list-rules.md)) |

The rule's type can't be changed. To change it, delete the rule and create a new one.

## Delete the rule

Owners, Admins, and Developers see a trash icon at the end of each row. Reviewers and Members don't.

Select the trash icon to open **Delete Rule**. It asks you to confirm: "Are you sure you want to delete the rule "\<name>"? This action cannot be undone." If the rule is active, the dialog adds "It is active, so messages will stop being checked against it." before the last sentence.

The trash icon calls the same endpoint as [Delete Custom Rule](https://docs.zerodrift.com/api-reference/custom-policies/delete-rule.md) (`DELETE /api/policies/rules/{rule_id}`), so the same `409` refusals apply. If the delete is refused, the dialog stays open and the reason appears in a notification.

## When the section is hidden

The **API-created rules** section does not appear when:

* your account has no custom rules outside a policy, or
* Policy Studio can't reach the rules service.

When the rules service can't be reached, policy pages also show this notice: "Couldn't check live rule state. Showing the saved values, which may not include changes made through the API."

## Rules deleted through the API

If you delete a rule that belongs to a policy with `DELETE /api/policies/rules/{rule_id}`, the policy's page in Policy Studio still lists it, greyed out, with a **Deleted via API** badge. The rule no longer runs.

## Next

> [card] [Create Custom Rule](https://docs.zerodrift.com/api-reference/custom-policies/create-rule.md)
>
> Request fields for `AI_SIGNAL`, `REGEX`, and `REQUIRE_NEAR` rules.

> [card] [Import a Policy](https://docs.zerodrift.com/guides/import-a-policy.md)
>
> Turn a policy document into rules that belong to a policy.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.