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

# Update a device alert rule

> Update the name, description, group, condition, or enabled state of an alert rule.



## OpenAPI

````yaml https://api.itmc.i.moneyforward.com/public-api/docs/v1-json patch /api/v1/organizations/{organizationId}/devices/device-alert-rules/{ruleId}
openapi: 3.0.0
info:
  title: Admina Public API
  description: >-
    Admina API is a RESTfull API providing programmatic access to much of the
    data in the system. It provides predictable URLs for accessing resources,
    and uses built-in HTTP features to receive commands and return responses.
    This makes it easy to communicate with from a wide variety of environments,
    from command-line utilities to gadgets to the browser URL bar itself.
  version: '1.0'
  contact: {}
servers:
  - url: https://api.itmc.i.moneyforward.com
security: []
tags:
  - name: Organizations
    description: ''
  - name: Users
    description: ''
  - name: Directory
    description: ''
  - name: Departments
    description: ''
  - name: Locations
    description: ''
  - name: Companies
    description: ''
  - name: People
    description: ''
  - name: Workspaces
    description: ''
  - name: Custom Service and Workspace
    description: ''
  - name: Custom Services
    description: ''
  - name: Workspace Accounts
    description: ''
  - name: Accounts
    description: ''
  - name: Contracts
    description: ''
  - name: Devices
    description: ''
  - name: Devices (alpha)
    description: ''
  - name: Alerts
    description: ''
  - name: Spends
    description: ''
  - name: Usage Optimization
    description: ''
  - name: Services
    description: ''
  - name: Service Roles
    description: ''
  - name: Service Licenses
    description: ''
  - name: Recommended Services
    description: ''
  - name: Requests
    description: ''
  - name: AuditLogs
    description: ''
  - name: EventLogs
    description: ''
paths:
  /api/v1/organizations/{organizationId}/devices/device-alert-rules/{ruleId}:
    patch:
      tags:
        - Devices
      summary: Update a device alert rule
      description: >-
        Update the name, description, group, condition, or enabled state of an
        alert rule.
      operationId: publicUpdateDeviceAlertRule
      parameters:
        - name: organizationId
          required: true
          in: path
          schema:
            type: number
        - name: ruleId
          required: true
          in: path
          schema:
            type: number
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PublicUpdateDeviceAlertRuleRequestDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicDeviceAlertRuleResponseDto'
        '400':
          description: Invalid request body
        '401':
          description: Invalid or missing API key
        '404':
          description: Device alert rule or referenced device group not found
        '409':
          description: An alert rule with the same name already exists
      security:
        - API-Key: []
components:
  schemas:
    PublicUpdateDeviceAlertRuleRequestDto:
      type: object
      properties:
        name:
          type: string
          example: macOS 4-Year Swap
        description:
          type: string
        deviceGroupId:
          type: number
        condition:
          $ref: '#/components/schemas/DeviceAlertRuleConditionGroupDto'
        urgency:
          type: string
          enum:
            - critical
            - warning
        isEnabled:
          type: boolean
    PublicDeviceAlertRuleResponseDto:
      type: object
      properties:
        id:
          type: number
          example: 42
        alertType:
          type: string
          enum:
            - retired_account
            - inactive_account
            - on_leave_account
            - unknown_account
            - public_files
            - device_unreturned_assigned
            - device_unreturned_leased
            - device_replacement
            - device_inactive
            - device_mdm_compliance
            - device_inventory_shortage
          example: device_replacement
        name:
          type: string
          example: macOS 4-Year Swap
        urgency:
          type: string
          enum:
            - critical
            - warning
          example: warning
        description:
          type: string
          nullable: true
        deviceGroupId:
          type: number
          nullable: true
          example: 7
          description: >-
            Null when the rule targets all devices in the organization — always
            the case for the Standard Rule, and allowed for custom rules. Use
            isStandard to tell the two apart.
        isStandard:
          type: boolean
          description: Standard Rule targets all devices and cannot be deleted
        condition:
          $ref: '#/components/schemas/DeviceAlertRuleConditionGroupDto'
        isEnabled:
          type: boolean
        createdAt:
          format: date-time
          type: string
        updatedAt:
          format: date-time
          type: string
      required:
        - id
        - alertType
        - name
        - urgency
        - description
        - deviceGroupId
        - isStandard
        - condition
        - isEnabled
        - createdAt
        - updatedAt
    DeviceAlertRuleConditionGroupDto:
      type: object
      properties:
        combinator:
          type: string
          enum:
            - and
            - or
          example: and
          description: >-
            How the conditions combine: 'and' = all must match, 'or' = any may
            match
        conditions:
          description: >-
            One or more conditions evaluated against each device and combined by
            `combinator`
          type: array
          items:
            $ref: '#/components/schemas/DeviceAlertRuleConditionDto'
      required:
        - combinator
        - conditions
    DeviceAlertRuleConditionDto:
      type: object
      properties:
        attribute:
          type: string
          example: preset.last_activity_from_mdm
          description: Device attribute path the rule evaluates against
        operator:
          type: string
          enum:
            - lt
            - lte
            - gt
            - gte
            - eq
            - neq
            - stale_for_days
            - contains
            - not_contains
            - starts_with
            - is_empty
            - is_not_empty
            - before
            - after
          example: stale_for_days
        value:
          type: string
          example: '30'
          description: >-
            Comparison value; numeric values are coerced server-side. Omitted
            for blank operators (is_empty / is_not_empty).
      required:
        - attribute
        - operator
  securitySchemes:
    API-Key:
      scheme: bearer
      bearerFormat: JWT
      type: http
      description: >-
        For authenticated requests, set the `Authorization: Bearer your_api_key`
        parameter in the header. <br/>You can create and manage your API Keys by
        visiting the **API Keys** tab in the **Settings** page of your
        organization in <a target='_blank'
        href='https://itmc.i.moneyforward.com/'>Admina</a>

````