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

# Clear rules

> Delete all rules from an index.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="Delete all rules" href="/doc/libraries/sdk/methods/search/clear-rules" />

**Required ACL:** `editSettings`

## Examples

<CodeGroup>
  ```cs C# theme={"system"}
  index.ClearRules(forwardToReplicas: true);

  // Asynchronous
  index.ClearRulesAsync(forwardToReplicas: true);
  ```

  ```go Go theme={"system"}
  forwardToReplicas := opt.ForwardToReplicas(true)
  res, err := index.ClearRules(forwardToReplicas)
  ```

  ```java Java theme={"system"}
  boolean forwardToReplicas = true;

  index.clearRules(forwardToReplicas);

  // Async version
  index.clearRulesAsync(forwardToReplicas);
  ```

  ```js JavaScript theme={"system"}
  // Delete all rules in the index.
  index.clearRules().then(() => {
    // done
  });

  // Delete all rules in the index and all its replicas.
  index.clearRules({ forwardToReplicas: true }).then(() => {
    // done
  });
  ```

  ```kotlin Kotlin theme={"system"}
  index.clearRules(forwardToReplicas = true)
  ```

  ```php PHP theme={"system"}
  // Delete all rules in the index.
  $index->clearRules();

  // Delete all rules in the index and all its replicas.
  $index->clearRules(['forwardToReplicas' => true]);
  ```

  ```python Python theme={"system"}
  # Delete all rules in the index.
  index.clear_rules()
  # Delete all rules in the index and all its replicas.
  index.clear_rules({'forwardToReplicas': True})
  ```

  ```ruby Ruby theme={"system"}
  # Delete all rules in the index.
  index.clear_rules

  # Delete all rules in the index and wait the end of indexing.
  index.clear_rules!

  # Delete all rules in the index and all its replicas.
  index.clear_rules({ forwardToReplicas: true })
  ```

  ```scala Scala theme={"system"}
  client.execute {
    clear rules of index "index_name" and forwardToReplicas
  }
  ```

  ```swift Swift theme={"system"}
  // Delete all rules in the index.
  index.clearRules { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }

  // Delete all rules in the index and all its replicas.
  index.clearRules(forwardToReplicas: true) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="forwardToReplicas" type="boolean" default={false}>
  Whether to forward the operation to the replica indices.
</ParamField>

## Response

<ResponseField name="taskID" type="integer">
  The task ID used with the [`waitTask`](/doc/libraries/sdk/v1/methods/wait-task) method.
</ResponseField>

<ResponseField name="updatedAt" type="string">
  Date at which the job has been created.
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "updatedAt":"2013-01-18T15:33:13.556Z",
  "taskID": 678
}
```
