> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.cail.health/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.cail.health/_mcp/server.

# Toggle an alert rule on or off

PATCH https://staging.cail.health/v1/alert-rules/{id}/toggle
Content-Type: application/json

Enables or disables an alert rule. When inactive, the rule does not fire even if its threshold is breached.

Reference: https://docs.cail.health/api-references/api-reference/configure-access-policy/toggle

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: cail-api
  version: 1.0.0
paths:
  /v1/alert-rules/{id}/toggle:
    patch:
      operationId: toggle
      summary: Toggle an alert rule on or off
      description: >-
        Enables or disables an alert rule. When inactive, the rule does not fire
        even if its threshold is breached.
      tags:
        - subpackage_configureAccessPolicy
      parameters:
        - name: id
          in: path
          description: Stable identifier of the alert rule.
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The updated alert rule.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ToggleAlertRuleResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ToggleAlertRuleRequest'
servers:
  - url: https://staging.cail.health
    description: https://staging.cail.health
components:
  schemas:
    ToggleAlertRuleRequest:
      type: object
      properties:
        isActive:
          type: boolean
          description: New active state for the rule.
      required:
        - isActive
      title: ToggleAlertRuleRequest
    AlertRuleConditionOperator:
      type: string
      enum:
        - <
        - '>'
        - <=
        - '>='
        - '='
      description: Comparison operator.
      title: AlertRuleConditionOperator
    AlertRuleCondition:
      type: object
      properties:
        field:
          type: string
          description: Field name on the alert event the condition evaluates against.
        operator:
          $ref: '#/components/schemas/AlertRuleConditionOperator'
          description: Comparison operator.
        value:
          type: number
          format: double
          description: Numeric threshold the field is compared against.
      required:
        - field
        - operator
        - value
      title: AlertRuleCondition
    AlertRuleResourceChannel:
      type: string
      enum:
        - in-app
        - email
        - both
      description: Delivery channel.
      title: AlertRuleResourceChannel
    AlertRuleResource:
      type: object
      properties:
        id:
          type: string
          description: Stable identifier of the alert rule.
        organizationId:
          type: string
          description: Stable identifier of the operator’s organisation.
        name:
          type: string
          description: Human-readable name for the rule.
        eventType:
          type: string
          description: Event-type code the rule listens for.
        condition:
          oneOf:
            - $ref: '#/components/schemas/AlertRuleCondition'
            - type: 'null'
          description: >-
            Threshold condition. Null when the rule fires on every event of its
            type.
        channel:
          $ref: '#/components/schemas/AlertRuleResourceChannel'
          description: Delivery channel.
        isActive:
          type: boolean
          description: Whether the rule fires when matched.
        createdAt:
          type: string
          description: ISO 8601 timestamp at which the rule was created.
        lastUpdated:
          type: string
          description: ISO 8601 timestamp of the most recent update.
      required:
        - id
        - organizationId
        - name
        - eventType
        - channel
        - isActive
        - createdAt
        - lastUpdated
      title: AlertRuleResource
    ToggleAlertRuleResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/AlertRuleResource'
        message:
          type: string
          description: Human-readable acknowledgement.
      required:
        - data
        - message
      title: ToggleAlertRuleResponse
  securitySchemes:
    auth0Bearer:
      type: http
      scheme: bearer

```

## Examples



**Request**

```json
{
  "isActive": true
}
```

**Response**

```json
{
  "data": {
    "id": "1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e",
    "organizationId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
    "name": "A&E diversion alert",
    "eventType": "a_and_e_diversion_rate",
    "channel": "both",
    "isActive": false,
    "createdAt": "2026-04-19T11:32:00.000Z",
    "lastUpdated": "2026-05-13T14:21:00.000Z",
    "condition": {
      "field": "avoidanceRate",
      "operator": "<",
      "value": 0.6
    }
  },
  "message": "Alert rule updated"
}
```

**SDK Code**

```python A rule disabled for a temporary maintenance window
import requests

url = "https://staging.cail.health/v1/alert-rules/1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e/toggle"

payload = { "isActive": True }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.json())
```

```javascript A rule disabled for a temporary maintenance window
const url = 'https://staging.cail.health/v1/alert-rules/1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e/toggle';
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"isActive":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go A rule disabled for a temporary maintenance window
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://staging.cail.health/v1/alert-rules/1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e/toggle"

	payload := strings.NewReader("{\n  \"isActive\": true\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby A rule disabled for a temporary maintenance window
require 'uri'
require 'net/http'

url = URI("https://staging.cail.health/v1/alert-rules/1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e/toggle")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"isActive\": true\n}"

response = http.request(request)
puts response.read_body
```

```java A rule disabled for a temporary maintenance window
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://staging.cail.health/v1/alert-rules/1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e/toggle")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"isActive\": true\n}")
  .asString();
```

```php A rule disabled for a temporary maintenance window
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://staging.cail.health/v1/alert-rules/1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e/toggle', [
  'body' => '{
  "isActive": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp A rule disabled for a temporary maintenance window
using RestSharp;

var client = new RestClient("https://staging.cail.health/v1/alert-rules/1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e/toggle");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"isActive\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift A rule disabled for a temporary maintenance window
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["isActive": true] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://staging.cail.health/v1/alert-rules/1d7d4e29-3b8e-4a01-a4f1-7e2a5b8c1d6e/toggle")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```