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

# Delete rule

> Delete a rule by its ID.

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 a rule" href="/doc/libraries/sdk/methods/search/delete-rule" />

**Required ACL:** `editSettings`

To find the `objectID` for rules, use the [`searchRules`](/doc/libraries/sdk/v1/methods/search-rules) method.

## Examples

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

  // Asynchronous
  await index.DeleteRuleAsync("ruleID", forwardToReplicas: true);
  ```

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

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

  index.deleteRule("ruleID", forwardToReplicas);

  // Async version
  index.deleteRuleAsync("ruleID", forwardToReplicas);
  ```

  ```js JavaScript theme={"system"}
  index.deleteRule('ruleID', { forwardToReplicas: true }).then(() => {
    // done
  });
  ```

  ```kotlin Kotlin theme={"system"}
  index.deleteRule(ObjectID("ruleID"), forwardToReplicas = true)
  ```

  ```php PHP theme={"system"}
  $index->deleteRule('ruleID', ['forwardToReplicas' => true]);
  ```

  ```python Python theme={"system"}
  index.delete_rule('ruleID', {'forwardToReplicas': True})

  ```

  ```ruby Ruby theme={"system"}
  index.delete_rule('ruleID', { forwardToReplicas: true })

  # Delete a rule and wait until the operation is complete
  index.delete_rule!('ruleID')
  ```

  ```scala Scala theme={"system"}
  client.execute {
    delete rule "ruleID" from "index_name"
  }
  ```

  ```swift Swift theme={"system"}
  index.deleteRule(withID: "ruleID",
                   forwardToReplicas: true) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="objectID" type="string" required>
  Unique identifier of a rule object.
</ParamField>

<ParamField body="forwardToReplicas" type="boolean">
  Whether to delete the rule also from all replica indices.
</ParamField>

<ParamField body="requestOptions" type="object">
  A mapping of request options to send along with the request.
</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 delete Rule 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
}
```
