---
title: "Toggle smart notification rule"
method: PATCH
path: "/v2/insights/smart_notification_rules/{rule_id}/toggle_status"
tags: ["smart_notification_rules"]
---

# Toggle smart notification rule

`PATCH /v2/insights/smart_notification_rules/{rule_id}/toggle_status`

## Request

- Base URL: `https://api.hubstaff.com`
- URL: `https://api.hubstaff.com/v2/insights/smart_notification_rules/{rule_id}/toggle_status`
- Auth: OAuth 2
  - Authorization code: `https://account.hubstaff.com/authorizations/new`
  - Token URL: `https://account.hubstaff.com/access_tokens` scopes: `hubstaff:read`, `hubstaff:write`
- TypeScript: <https://skmtc.dev/hubstaff/apis/hubstaff-v2-api/docs/v2/insights/smart_notification_rules/:rule_id/toggle_status/patch.ts> (a function with typed inputs; its response is checked against the schema)

Sets the status of a smart notification rule to either enabled or disabled.
The 'enabled' parameter determines the new status of the rule.

## Path parameters

- `rule_id` integer, required

## Request body

- PatchV2InsightsSmartNotificationRulesRuleIdToggleStatus: Toggle smart notification rule
  - `enabled` boolean, required: Specifies the new status of the smart notification rule (true for enabled, false for disabled)

## Response `200`

A smart notification rule

- object
  - `smart_notification_rule` SmartNotificationRule: SmartNotificationRule model
    - `id` integer, required: Smart notification rule ID
    - `name` string, required: Smart notification rule name
    - `enabled` boolean, required: Indicates whether the smart notification rule is enabled
    - `frequency` 'hourly' | 'daily' | 'weekly' | 'monthly', required: Determines how often the conditions for notifications are checked
    - `metric_type` 'work_time' | 'core_time' | 'non_core_time' | 'unproductive_time' | 'activity' | 'suspicious_activity' | 'unusual_activity' | 'time_spent_in_tool' | 'idle_time' | 'idle_time_percent' | 'manual_time' | 'manual_time_percent' | 'geo_ip_changes' | 'users_per_ip' | 'geo_ip_list_match', required: Metric type to be monitored
    - `condition` 'above' | 'below', required: Comparison condition for triggering the notification
    - `condition_value` number, float, required: Rule threshold value (in seconds if metric type is work_time or time_spent_in_tool)
    - `time_unit` 'per_hour' | 'per_day' | 'per_week' | 'per_month': Duration of time over which the rule is evaluated. It specifies the length of the observation period
    - `target` object, required: Who will be monitored by the rule
    - `recipients` object, required: Who will receive the notifications when the rule conditions are met
    - `deliver_by` string[], required: List of delivery methods for sending notifications. By default, `insights` is always included
    - `created_at` string, date-time, required: When the record was created
    - `updated_at` string, date-time, required: When the record was last updated

## Other responses

- `400`: Invalid parameters
- `401`: Unauthorized
- `403`: API access is only for organizations on an active plan
- `404`: Could not find record
- `429`: Rate limit exceeded

---

[API](https://skmtc.dev/hubstaff/apis/hubstaff-v2-api.md) - [All operations](https://skmtc.dev/hubstaff/apis/hubstaff-v2-api/llms.txt) - [OpenAPI document](https://skmtc.dev/hubstaff/apis/hubstaff-v2-api/revisions/c6b90e4e4bdc?raw)
