---
title: "Update smart notification rule"
method: PUT
path: "/v2/insights/smart_notification_rules/{rule_id}"
tags: ["smart_notification_rules"]
---

# Update smart notification rule

`PUT /v2/insights/smart_notification_rules/{rule_id}`

## Request

- Base URL: `https://api.hubstaff.com`
- URL: `https://api.hubstaff.com/v2/insights/smart_notification_rules/{rule_id}`
- 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/put.ts> (a function with typed inputs; its response is checked against the schema)

Updates a smart notification rule.

Returns the updated smart notification rule.

Only pass in the fields you want to change.

## Path parameters

- `rule_id` integer, required

## Request body

- PutV2InsightsSmartNotificationRulesRuleId: Update smart notification rule
  - `name` string: Rule name
  - `frequency` 'hourly' | 'daily' | 'weekly' | 'monthly': 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': Metric type to be monitored
  - `condition` 'above' | 'below': Rule condition
  - `condition_value` number, float: Rule threshold value (in seconds if metric type is work_timeor time_spent_in_tool)
  - `target` object
    - `all_members` boolean: Monitor all members
    - `team_ids` integer[]: Monitor specific teams
    - `user_ids` integer[]: Monitor specific users
  - `recipients` object: Who will receive the notifications
    - `roles` string[]: The recipient roles (e.g., ["owner"])
    - `user_ids` integer[]: The recipient members
  - `deliver_by` string[]: List of delivery methods for sending notifications
  - `time_unit` 'per_hour' | 'per_day' | 'per_week' | 'per_month': Duration of time over which the rule is evaluated

## 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)
