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

# Set alert rules

> Sets all alert rules for a specific asset and event type.



## OpenAPI

````yaml https://api.notifense.com/openapi/v1.json post /v1/accounts/{accountId}/assets/{assetId}/alertRules/{eventType}
openapi: 3.1.1
info:
  title: Notifense
  version: v1
servers:
  - url: https://api.notifense.com
security:
  - oauth2: []
tags:
  - name: accounts
  - name: assets
  - name: alertRules
  - name: events
  - name: telemetry
  - name: geofences
  - name: auth
paths:
  /v1/accounts/{accountId}/assets/{assetId}/alertRules/{eventType}:
    post:
      tags:
        - alertRules
      summary: Set alert rules
      description: Sets all alert rules for a specific asset and event type.
      parameters:
        - name: accountId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: assetId
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: eventType
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/EventType'
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                $ref: '#/components/schemas/CreateAlertRuleRequest'
        required: true
      responses:
        '204':
          description: No Content
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    EventType:
      enum:
        - 1
        - 2
        - 3
        - 4
        - 5
        - 6
        - 7
        - 8
        - 9
        - 10
        - 11
        - 12
        - 13
        - 14
        - 15
        - 16
        - 17
        - 18
        - 19
        - 20
        - 21
        - 22
        - 23
        - 24
        - 25
        - 26
      type: integer
      x-enumDescriptions:
        - Any
        - InputPowerDisconnected
        - InputVoltageLow
        - BatteryLow
        - Jammed
        - MovementStarted
        - MovementStopped
        - IgnitionTurnedOn
        - IgnitionTurnedOff
        - GeofenceEntered
        - GeofenceExited
        - SpeedLimitExceeded
        - AssetLeftBehind
        - FuelLevelLow
        - AdBlueLevelLow
        - AlarmTriggered
        - LockdownViolated
        - Tampering
        - CountryBorderCrossed
        - TemperatureHigh
        - TemperatureLow
        - PressureHigh
        - PressureLow
        - HardCornering
        - EngineIdling
        - EngineSpeedLimitExceeded
    CreateAlertRuleRequest:
      required:
        - recipient
        - channel
      type: object
      properties:
        recipient:
          $ref: '#/components/schemas/Recipient'
        channel:
          $ref: '#/components/schemas/AlertRuleChannel'
        isDisabled:
          type:
            - 'null'
            - boolean
          description: >-
            Indicates whether this alert rule is disabled, or null to disable
            this filter.
        daysOfWeek:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/DayOfWeek'
          description: >-
            The days of the week on which this alert rule is active, or null to
            disable this filter.
        timeOfDay:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TimeRange'
              description: >-
                The times of the day during which this alert rule is active, or
                null to disable this filter. Range may cross midnight (e.g. from
                22:00 to 06:00).
        dates:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/DateRange'
              description: >-
                The dates between which this alert rule is active, or null to
                disable this filter.
        insideGeofences:
          type:
            - 'null'
            - array
          items:
            type: string
            format: uuid
          description: >-
            The geofences in any of which the asset must be for the alert rule
            to be active, or null to disable this filter.
        outsideGeofences:
          type:
            - 'null'
            - array
          items:
            type: string
            format: uuid
          description: >-
            The geofences outside all of which the asset must be for the alert
            rule to be active, or null to disable this filter.
    Error:
      required:
        - code
        - message
      type: object
      properties:
        code:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - integer
            - string
          format: int32
        message:
          type: string
    Recipient:
      required:
        - culture
        - timeZone
        - phoneNumber
      type: object
      properties:
        culture:
          $ref: '#/components/schemas/CultureInfo'
        timeZone:
          $ref: '#/components/schemas/TimeZoneInfo'
        phoneNumber:
          type: string
          description: >-
            The phone number of the recipient in E.164 format (e.g.
            +1234567890).
        description:
          type:
            - 'null'
            - string
    AlertRuleChannel:
      required:
        - type
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ChannelType'
        call:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/CallChannelOptions'
        sms:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/SmsChannelOptions'
        telegram:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TelegramChannelOptions'
        email:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/EmailChannelOptions'
    DayOfWeek:
      enum:
        - 0
        - 1
        - 2
        - 3
        - 4
        - 5
        - 6
      type: integer
      x-enumDescriptions:
        - Sunday
        - Monday
        - Tuesday
        - Wednesday
        - Thursday
        - Friday
        - Saturday
    TimeRange:
      required:
        - from
        - to
      type: object
      properties:
        from:
          type: string
          description: Start time (00:00:00 - 23:59:59)
          format: time
        to:
          type: string
          description: End time (00:00:00 - 23:59:59)
          format: time
    DateRange:
      required:
        - from
        - to
      type: object
      properties:
        from:
          type: string
          format: date
        to:
          type: string
          format: date
    CultureInfo: {}
    TimeZoneInfo: {}
    ChannelType:
      enum:
        - 1
        - 2
        - 3
        - 4
      type: integer
      x-enumDescriptions:
        - Call
        - Sms
        - Telegram
        - Email
    CallChannelOptions:
      type: object
    SmsChannelOptions:
      type: object
      properties:
        isInteractive:
          type: boolean
          description: >-
            If true, allows the user to resolve the event using a link inside
            the SMS message.
    TelegramChannelOptions:
      required:
        - chatId
        - isInteractive
      type: object
      properties:
        chatId:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - integer
            - string
          description: >-
            The Telegram chat ID between the Notifense Telegram bot and the
            user.
          format: int64
        isInteractive:
          type: boolean
          description: >-
            If true, allows the user to resolve the event using buttons in the
            Telegram message.
    EmailChannelOptions:
      required:
        - emailAddress
      type: object
      properties:
        emailAddress:
          type: string
        isInteractive:
          type: boolean
          description: >-
            If true, allows the user to resolve the event using a link inside
            the email.
  securitySchemes:
    oauth2:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: https://api.notifense.com/v1/auth/token
          scopes: {}

````