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

# Activate Rules

> Activate extracted rules from a policy import so they run during validation

Activate rules extracted from a policy import. Once activated, these rules will be enforced during document validation for your account. You can activate all rules or a specific subset.

<Note>
  Activated rules apply **automatically** on every [validation](/api-reference/validation/validate-document)
  made with your API key — there is no per-request flag to select them, and `document_category` /
  `document_metadata` do not control them (those only select ZeroDrift's built-in default rules).
  Use [Deactivate Rules](/api-reference/custom-policies/deactivate-rules) to stop a rule from running.
</Note>

## Path Parameters

<ParamField path="import_id" type="string" required>
  The import ID to activate rules from
</ParamField>

## Request Body

<ParamField body="rule_ids" type="array">
  Optional list of specific rule IDs to activate. If omitted, all extracted rules are activated.
</ParamField>

<ParamField body="overwrite" type="boolean">
  Set to `true` to overwrite rules that have already been activated from a previous import. Defaults to `false`.
</ParamField>

<Note>
  When `overwrite` is `false` (default), if a rule ID already exists the request stops and returns a `409` conflict response. The 409 error body includes an error message that identifies the conflicting rule ID and indicates which rules were successfully activated before the collision. Use `overwrite: true` to replace existing rules unconditionally.
</Note>

## Response

<ResponseField name="import_id" type="string">
  Import identifier
</ResponseField>

<ResponseField name="status" type="string">
  Updated import status: `activated`
</ResponseField>

<ResponseField name="activated_count" type="integer">
  Number of rules successfully activated
</ResponseField>

<ResponseField name="activated_rule_ids" type="array">
  List of activated rule IDs (prefixed with `cust_<customer_id>_`)
</ResponseField>

<ResponseField name="conflicting_rule_id" type="string">
  For `409` responses, the rule ID that caused the conflict.
</ResponseField>

<ResponseExample>
  ```json 200 Activated theme={null}
  {
    "import_id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "activated",
    "activated_count": 5,
    "activated_rule_ids": [
      "cust_abc123_no_misleading_claims",
      "cust_abc123_benchmark_comparison_required",
      "cust_abc123_risk_disclosure_present",
      "cust_abc123_fee_transparency",
      "cust_abc123_past_performance_disclaimer"
    ]
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": "No matching rule_ids found in import"
  }
  ```

  ```json 409 Rule ID Conflict theme={null}
  {
    "error": "Rule 'cust_abc123_no_misleading_claims' was created by a concurrent request",
    "conflicting_rule_id": "cust_abc123_no_misleading_claims",
    "activated_rule_ids": [
      "cust_abc123_benchmark_comparison_required"
    ]
  }
  ```
</ResponseExample>

## Example

<CodeGroup>
  ```bash cURL (activate all) theme={null}
  curl -X POST "https://{api-url}/api/policies/import/550e8400-e29b-41d4-a716-446655440000/activate" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json"
  ```

  ```bash cURL (activate subset) theme={null}
  curl -X POST "https://{api-url}/api/policies/import/550e8400-e29b-41d4-a716-446655440000/activate" \
    -H "x-api-key: YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "rule_ids": ["no_misleading_claims", "risk_disclosure_present"],
      "overwrite": true
    }'
  ```

  ```python Python theme={null}
  import requests

  API_KEY = "YOUR_API_KEY"
  API_BASE = "https://{api-url}"
  IMPORT_ID = "550e8400-e29b-41d4-a716-446655440000"

  # Activate all rules
  response = requests.post(
      f"{API_BASE}/api/policies/import/{IMPORT_ID}/activate",
      headers={
          "x-api-key": API_KEY,
          "Content-Type": "application/json"
      }
  )

  result = response.json()
  print(f"Activated {result['activated_count']} rules")
  for rule_id in result["activated_rule_ids"]:
      print(f"  - {rule_id}")
  ```

  ```javascript JavaScript theme={null}
  const axios = require('axios');

  const API_KEY = 'YOUR_API_KEY';
  const API_BASE = 'https://{api-url}';
  const IMPORT_ID = '550e8400-e29b-41d4-a716-446655440000';

  // Activate specific rules
  const response = await axios.post(
    `${API_BASE}/api/policies/import/${IMPORT_ID}/activate`,
    {
      rule_ids: ['no_misleading_claims', 'risk_disclosure_present'],
      overwrite: true
    },
    {
      headers: {
        'x-api-key': API_KEY,
        'Content-Type': 'application/json'
      }
    }
  );

  console.log(`Activated ${response.data.activated_count} rules`);
  response.data.activated_rule_ids.forEach(id => console.log(`  - ${id}`));
  ```
</CodeGroup>
