# Delete rule

Delete a rule (soft delete).

#### Path Parameters

**`org_id`** string required

Organization ID (org_ prefixed string) where the rule belongs.

**`rule_id`** string required

Rule ID with `rule_` prefix.

#### Query Parameters

**`force`** boolean optional · Defaults to `false`

Force delete even if attachments exist. When true, also deletes all attachments and access rights.

## Returns

Returns `204 No Content` on successful deletion.

## Access Control

Requires `owner` access to the rule.

## Behavior

Performs a soft delete (sets `is_deleted=true`). Fails if attachments exist unless `force=true` is specified.

Basic Delete

```bash
curl -X DELETE https://api.aitronos.com/v1/organizations/org_abc123def456/rules/rule_abc123 \
  -H "X-API-Key: $FREDDY_API_KEY"
```


```python Python SDK
from aitronos import Aitronos

client = Aitronos(api_key="your-api-key")

client.rule_operations.delete_rule("org_abc123", "rule_abc123")
print("Rule deleted successfully")
```


```python
import requests
import os

api_key = os.environ["FREDDY_API_KEY"]

response = requests.delete(
    "https://api.aitronos.com/v1/organizations/org_abc123def456/rules/rule_abc123",
    headers={"X-API-Key": api_key}
)

result = response.json()
print(result)
```


```javascript
const response = await fetch('https://api.aitronos.com/v1/organizations/org_abc123def456/rules/rule_abc123', {
  method: 'DELETE',
  headers: {
    'X-API-Key': process.env.FREDDY_API_KEY
  }
});

const result = await response.json();
console.log(result);
```

Force Delete

```bash
curl -X DELETE "https://api.aitronos.com/v1/organizations/org_abc123def456/rules/rule_abc123?force=true" \
  -H "X-API-Key: $FREDDY_API_KEY"
```


```python Python SDK
from aitronos import Aitronos

client = Aitronos(api_key="your-api-key")

client.rule_operations.delete_rule("org_abc123", "rule_abc123", force=True)
print("Rule force-deleted successfully")
```


```python
import requests
import os

api_key = os.environ["FREDDY_API_KEY"]

response = requests.delete(
    "https://api.aitronos.com/v1/organizations/org_abc123def456/rules/rule_abc123",
    headers={"X-API-Key": api_key},
    params={"force": True}
)

result = response.json()
```


```javascript
const response = await fetch('https://api.aitronos.com/v1/organizations/org_abc123def456/rules/rule_abc123?force=true', {
  method: 'DELETE',
  headers: {
    'X-API-Key': process.env.FREDDY_API_KEY
  }
});

const result = await response.json();
```

**Response:**

200 OK

```json
{
  "success": true,
  "message": "Rule deleted successfully",
  "data": {
    "id": "rule_abc123",
    "deleted": true
  }
}
```

403 Forbidden

```json
{
  "success": false,
  "error": {
    "code": "ACCESS_DENIED",
    "message": "You need owner access to delete this rule.",
    "system_message": "You need owner access to delete this rule.",
    "type": "authorization_error",
    "status": 403,
    "details": {},
    "trace_id": "req_abc123xyz",
    "timestamp": "2025-12-22T15:30:00Z"
  }
}
```

409 Conflict

```json
{
  "success": false,
  "error": {
    "code": "RULE_HAS_ATTACHMENTS",
    "message": "Cannot delete rule with attachments. Use force=true to delete anyway.",
    "system_message": "Cannot delete rule with attachments. Use force=true to delete anyway.",
    "type": "client_error",
    "status": 409,
    "details": {
      "attachment_count": 3
    },
    "trace_id": "req_abc123xyz",
    "timestamp": "2025-12-22T15:30:00Z"
  }
}
```

## Related Resources

- [Create Rule](/docs/api-reference/rules/create)
- [List Rules](/docs/api-reference/rules/list)