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

# Dry-run a destructive change

> Preview what a delete changes with dry_run, then run it with an idempotency key. The example deletes a detection rule pack.

A dry run runs the same request as the real one and stops before it saves anything. The response
shows what would change. An agent should preview every change that it cannot undo, show the
preview to the person, and run the real request only after the person agrees.

This recipe previews and then deletes a custom detection rule pack. Deleting a pack stops its rules
within about 60 seconds. The findings it already made stay. Both steps need `findings:write`.

## Operations that support dry runs

Add `dry_run=true` to the query of these operations. Each one returns a preview and changes
nothing. The OpenAPI contract lists the parameter on each of them.

| Operation | What the real request does |
| - | - |
| `detections.create` | Adds a custom detection rule pack. |
| `detections.update` | Changes the name, description, or rule files of a pack. |
| `detections.delete` | Removes a custom pack. The preview lists what stops. |
| `security.pii.updateSettings` | Turns redaction of secrets and PII at ingest on or off. |
| `security.findings.import` | Imports scanner findings as security findings. |
| `connections.create` | Connects a connector and starts polling. |
| `connections.delete` | Disconnects a connector and deletes its stored secrets. |
| `actions.propose`, `actions.undo` | Proposes a response action, or the undo of one. |

## Preview the delete

Find the pack ID with `squasher detections list`. The built-in pack cannot be deleted.

> [tab] CLI
>
> ```bash theme={null}
> squasher detections delete PACK_ID --project "$SQUASHER_PROJECT_ID" --dry-run --json
> ```

> [tab] MCP
>
> The MCP server hides `detections.delete`, because deleting a pack cannot be undone. Agents turn
> a pack off instead, or ask the person to delete it with the CLI or REST API tab.
>
> `detections.create` is exposed, so an agent can preview a new pack in the same way. This write
> needs **Full access**:
>
> ```javascript theme={null}
> const projectId = "YOUR_PROJECT_ID";
> return await squasher.request({
>   method: "POST",
>   path: `/v1/projects/${projectId}/detections`,
>   query: { dry_run: "true" },
>   body: {
>     name: "Okta admin tokens",
>     enabled: false,
>     rules: [{ name: "okta_admin_token.yml", format: "sigma", yaml: "title: ..." }],
>   },
> });
> ```

> [tab] REST API
>
> ```bash theme={null}
> curl -X DELETE \
>   "https://api.squasher.ai/v1/projects/$SQUASHER_PROJECT_ID/detections/PACK_ID?dry_run=true" \
>   -H "x-squasher-key: $SQUASHER_API_KEY"
> ```

The status is `200`, and nothing is deleted. The response is the pack that would be deleted, with
the rules that would stop running:

```json theme={null}
{
  "id": "<pack uuid>",
  "name": "<pack name>",
  "builtin": false,
  "enabled": true,
  "version": 3,
  "created_at": "<ISO time>",
  "updated_at": "<ISO time>",
  "rules": [
    {
      "id": "<rule id>",
      "title": "<rule title>",
      "level": "high",
      "source": "okta",
      "path": "<rule file>"
    }
  ]
}
```

Check `enabled` and `rules`. A pack with `enabled: true` is running now, so a delete removes live
detection. If you want to keep the rules, turn the pack off instead with `detections.disable`.

## Run the delete

The real delete needs an `Idempotency-Key`, so that a retry after a network error deletes once and
returns the first response. Use a new key for each change. A request without a key returns `400`
with `This operation needs an Idempotency-Key header`. The CLI sends a new key for you. Pass
`--idempotency-key` to choose it.

> [tab] CLI
>
> ```bash theme={null}
> squasher detections delete PACK_ID --project "$SQUASHER_PROJECT_ID" --yes
> ```
>
> Without `--yes`, the command asks you to confirm. In a script, an agent, or CI, it fails with
> exit code `2` and the code `confirmation_required` instead of asking.

> [tab] MCP
>
> Not available for this operation. See above.

> [tab] REST API
>
> ```bash theme={null}
> curl -X DELETE \
>   "https://api.squasher.ai/v1/projects/$SQUASHER_PROJECT_ID/detections/PACK_ID" \
>   -H "x-squasher-key: $SQUASHER_API_KEY" \
>   -H "Idempotency-Key: $(uuidgen)"
> ```
>
> The status is `204` with no body.

Check the result with `squasher detections list`. The pack is gone. A repeat of the same request with
the same key returns the first response. The same key with a different request returns `422`.

> [!WARNING]
>
> Deleting a pack cannot be undone. The rules stop at ingest within about 60 seconds. To restore
> them, create the pack again from your rule files.

## Next steps

> [card] [Detections API](https://docs.squasher.ai/api-reference/detections.md)
>
> Every pack operation, with its access and idempotency rules.

> [card] [Detection rules](https://docs.squasher.ai/features/detection-rules.md)
>
> Keep rule packs as code and test them with a backtest.


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