openapi: 3.0.1
security:
- accountSid_authToken: []
info:
  title: Twilio - Alarms
  description: Manages Twilio Alarms
  contact:
    name: Twilio Support
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.0
servers:
- url: https://monitor.twilio.com
paths:
  /v2/Alarms:
    get:
      summary: Fetch list of Alarms
      operationId: ListAlarms
      parameters:
      - name: PageSize
        in: query
        description: How many resources to return in each list page. The default is
          50, and the maximum is 1000.
        schema:
          type: integer
          minimum: 1
          maximum: 1000
      - name: Page
        in: query
        description: The page index. This value is simply for client state.
        schema:
          type: integer
          minimum: 0
      - name: PageToken
        in: query
        description: The page token. This is provided by the API.
        schema:
          type: string
      - name: SortOrder
        in: query
        required: false
        schema:
          type: string
          enum:
          - asc
          - desc
      responses:
        '200':
          description: List of Alarms
          content:
            application/json:
              schema:
                type: object
                title: ListAlarms
                properties:
                  alarms:
                    type: array
                    description: List of basic parameters defined for alarms for an
                      account.
                    items:
                      $ref: '#/components/schemas/monitor.v2.alarm_body'
                  meta:
                    properties:
                      first_page_url:
                        format: uri
                        type: string
                      key:
                        type: string
                      next_page_url:
                        format: uri
                        nullable: true
                        type: string
                      page:
                        type: integer
                      page_size:
                        type: integer
                      previous_page_url:
                        format: uri
                        nullable: true
                        type: string
                      url:
                        format: uri
                        type: string
                    type: object
          headers:
            Access-Control-Allow-Origin:
              description: Specify the origin(s) allowed to access the resource
              schema:
                type: string
              example: '*'
            Access-Control-Allow-Methods:
              description: Specify the HTTP methods allowed when accessing the resource
              schema:
                type: string
              example: POST, OPTIONS
            Access-Control-Allow-Headers:
              description: Specify the headers allowed when accessing the resource
              schema:
                type: string
              example: Content-Type, Authorization
            Access-Control-Allow-Credentials:
              description: Indicates whether the browser should include credentials
              schema:
                type: boolean
            Access-Control-Expose-Headers:
              description: Headers exposed to the client
              schema:
                type: string
                example: X-Custom-Header1, X-Custom-Header2
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalServerError'
    post:
      summary: Create an alarm
      operationId: CreateAlarm
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/monitor.v2.alarm_create_object'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/monitor.v2.alarm.sid_repsonse'
          headers:
            Access-Control-Allow-Origin:
              description: Specify the origin(s) allowed to access the resource
              schema:
                type: string
              example: '*'
            Access-Control-Allow-Methods:
              description: Specify the HTTP methods allowed when accessing the resource
              schema:
                type: string
              example: POST, OPTIONS
            Access-Control-Allow-Headers:
              description: Specify the headers allowed when accessing the resource
              schema:
                type: string
              example: Content-Type, Authorization
            Access-Control-Allow-Credentials:
              description: Indicates whether the browser should include credentials
              schema:
                type: boolean
            Access-Control-Expose-Headers:
              description: Headers exposed to the client
              schema:
                type: string
                example: X-Custom-Header1, X-Custom-Header2
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /v2/Alarms/{Sid}:
    get:
      summary: Get alarm
      operationId: FetchAlarm
      parameters:
      - $ref: '#/components/parameters/Sid'
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/monitor.v2.alarm_body'
          headers:
            Access-Control-Allow-Origin:
              description: Specify the origin(s) allowed to access the resource
              schema:
                type: string
              example: '*'
            Access-Control-Allow-Methods:
              description: Specify the HTTP methods allowed when accessing the resource
              schema:
                type: string
              example: POST, OPTIONS
            Access-Control-Allow-Headers:
              description: Specify the headers allowed when accessing the resource
              schema:
                type: string
              example: Content-Type, Authorization
            Access-Control-Allow-Credentials:
              description: Indicates whether the browser should include credentials
              schema:
                type: boolean
            Access-Control-Expose-Headers:
              description: Headers exposed to the client
              schema:
                type: string
                example: X-Custom-Header1, X-Custom-Header2
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
    put:
      summary: Update alarm
      operationId: UpdateAlarm
      parameters:
      - $ref: '#/components/parameters/Sid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/monitor.v2.alarm_create_object'
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/monitor.v2.alarm.sid_repsonse'
          headers:
            Access-Control-Allow-Origin:
              description: Specify the origin(s) allowed to access the resource
              schema:
                type: string
              example: '*'
            Access-Control-Allow-Methods:
              description: Specify the HTTP methods allowed when accessing the resource
              schema:
                type: string
              example: POST, OPTIONS
            Access-Control-Allow-Headers:
              description: Specify the headers allowed when accessing the resource
              schema:
                type: string
              example: Content-Type, Authorization
            Access-Control-Allow-Credentials:
              description: Indicates whether the browser should include credentials
              schema:
                type: boolean
            Access-Control-Expose-Headers:
              description: Headers exposed to the client
              schema:
                type: string
                example: X-Custom-Header1, X-Custom-Header2
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
    delete:
      summary: Delete alarm
      operationId: DeleteAlarm
      parameters:
      - $ref: '#/components/parameters/Sid'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
  /v2/Alarms/{Sid}/status:
    put:
      summary: Update status of alarm between enabled and disabled
      operationId: UpdateAlarmStatus
      parameters:
      - $ref: '#/components/parameters/Sid'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/monitor.v2.alarm_status'
      responses:
        '204':
          $ref: '#/components/responses/NoContent'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    TwilioServiceErrorResponse:
      description: Twilio error response
      type: object
      properties:
        message:
          type: string
          description: Error message
        code:
          type: integer
          description: Twilio error code
        user_error:
          type: boolean
          description: Indicates if it was a user error
        http_status_code:
          type: integer
          description: Http error code returned
        params:
          type: object
          additionalProperties:
            type: string
        more_info:
          type: string
          description: More information link
        status:
          type: integer
          description: HTTP status code
    alarm:
      type: object
      description: Basic user friendly view representation of an alarm.
      required:
      - alertConfigSid
      - datasetName
      - dateUpdatedEpochMilli
      - enabled
      - product
      properties:
        friendlyName:
          $ref: '#/components/schemas/friendly_name'
        description:
          type: string
          description: Description for the alarm.
        datasetName:
          type: string
          description: Dataset for the alarm.
        alertConfigSid:
          type: string
          description: Sid for the alarm.
        enabled:
          type: boolean
          description: Is alarm enbled? Default is true.
          default: true
        dateUpdatedEpochMilli:
          type: integer
          format: int64
          description: Date Updated epoch for the alarm.
        product:
          type: string
          description: Product the alarm is related to
    monitor.v2.alarm_body:
      type: object
      description: Alarm response body
      required:
      - alertConfigSid
      - dateUpdated
      - dateCreated
      - enabled
      - product
      - friendlyName
      - queryType
      - triggerValue
      - timeWindow
      - description
      properties:
        friendlyName:
          $ref: '#/components/schemas/friendly_name'
        queryType:
          $ref: '#/components/schemas/query_type'
        query:
          type: string
          description: Value to query for
        triggerValue:
          type: integer
          description: Threshold to send customer alarm notification
        timeWindow:
          $ref: '#/components/schemas/time_window'
        email:
          type: array
          items:
            type: string
            format: email
          description: Email notifications to send
        webhook:
          type: string
          format: uri
          description: Webhook notification to send
        consoleIndicator:
          type: boolean
          description: Whether to send console notifications
        description:
          type: string
          description: Description for the alarm.
        enabled:
          type: boolean
          description: Is alarm enbled? Default is true.
          default: true
        product:
          type: string
          description: Product the alarm is related to.
        alertConfigSid:
          type: string
          description: Sid for the alarm
        dateUpdated:
          type: string
          format: date-time
          description: The date and time in UTC when the alarm was last updated specified
            in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format
        dateCreated:
          type: string
          format: date-time
          description: The date and time in UTC when the alarm was created specified
            in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.
    monitor.v2.alarm_create_object:
      type: object
      description: Alarm object
      required:
      - friendlyName
      - queryType
      - triggerValue
      - timeWindow
      - description
      - enabled
      properties:
        friendlyName:
          $ref: '#/components/schemas/friendly_name'
        queryType:
          $ref: '#/components/schemas/query_type'
        query:
          type: string
          description: Value to query for
        triggerValue:
          type: integer
          description: Threshold to send customer alarm notification
        timeWindow:
          $ref: '#/components/schemas/time_window'
        email:
          type: array
          items:
            type: string
          description: Email notifications to send
        webhook:
          type: string
          description: Webhook notification to send
        consoleIndicator:
          type: boolean
          description: Whether to send console notifications
        description:
          type: string
          description: Description for the alarm.
        enabled:
          type: boolean
          description: Is alarm enbled? Default is true.
          default: true
    monitor.v2.alarm_status:
      type: object
      description: Enable or disable alarm
      required:
      - enabled
      properties:
        enabled:
          description: status of alarm
          type: boolean
    query_type:
      type: string
      description: Type of query
      enum:
      - ERROR_CODE
      - LOG_LEVEL
      - ALL
    time_window:
      type: string
      description: Time window for alarm to trigger
      enum:
      - FIVE_MINS
      - FIFTEEN_MINS
      - ONE_HOUR
      - TWELVE_HOURS
      - ONE_DAY
    friendly_name:
      type: string
      description: Friendly name for alarm
    monitor.v2.alarm.sid_repsonse:
      type: object
      description: Alarm sid
      properties:
        sid:
          type: string
          minLength: 34
          maxLength: 34
          pattern: ^AK[0-9a-fA-F]{32}$
  securitySchemes:
    accountSid_authToken:
      scheme: basic
      type: http
  parameters:
    Sid:
      name: Sid
      in: path
      description: Sid
      required: true
      schema:
        type: string
    DatasetName:
      name: DatasetName
      in: query
      description: Dataset Name
      required: false
      schema:
        type: string
        default: ReportCenter.DebugEvents
  responses:
    NoContent:
      description: NO CONTENT
      headers:
        Access-Control-Allow-Origin:
          description: Specify the origin(s) allowed to access the resource
          schema:
            type: string
          example: '*'
        Access-Control-Allow-Methods:
          description: Specify the HTTP methods allowed when accessing the resource
          schema:
            type: string
          example: POST, OPTIONS
        Access-Control-Allow-Headers:
          description: Specify the headers allowed when accessing the resource
          schema:
            type: string
          example: Content-Type, Authorization
        Access-Control-Allow-Credentials:
          description: Indicates whether the browser should include credentials
          schema:
            type: boolean
        Access-Control-Expose-Headers:
          description: Headers exposed to the client
          schema:
            type: string
            example: X-Custom-Header1, X-Custom-Header2
    BadRequest:
      description: BAD REQUEST
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TwilioServiceErrorResponse'
      headers:
        Access-Control-Allow-Origin:
          description: Specify the origin(s) allowed to access the resource
          schema:
            type: string
          example: '*'
        Access-Control-Allow-Methods:
          description: Specify the HTTP methods allowed when accessing the resource
          schema:
            type: string
          example: POST, OPTIONS
        Access-Control-Allow-Headers:
          description: Specify the headers allowed when accessing the resource
          schema:
            type: string
          example: Content-Type, Authorization
        Access-Control-Allow-Credentials:
          description: Indicates whether the browser should include credentials
          schema:
            type: boolean
        Access-Control-Expose-Headers:
          description: Headers exposed to the client
          schema:
            type: string
            example: X-Custom-Header1, X-Custom-Header2
    Unauthorized:
      description: UNAUTHORIZED
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TwilioServiceErrorResponse'
      headers:
        Access-Control-Allow-Origin:
          description: Specify the origin(s) allowed to access the resource
          schema:
            type: string
          example: '*'
        Access-Control-Allow-Methods:
          description: Specify the HTTP methods allowed when accessing the resource
          schema:
            type: string
          example: POST, OPTIONS
        Access-Control-Allow-Headers:
          description: Specify the headers allowed when accessing the resource
          schema:
            type: string
          example: Content-Type, Authorization
        Access-Control-Allow-Credentials:
          description: Indicates whether the browser should include credentials
          schema:
            type: boolean
        Access-Control-Expose-Headers:
          description: Headers exposed to the client
          schema:
            type: string
            example: X-Custom-Header1, X-Custom-Header2
    NotFound:
      description: NOT FOUND
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TwilioServiceErrorResponse'
      headers:
        Access-Control-Allow-Origin:
          description: Specify the origin(s) allowed to access the resource
          schema:
            type: string
          example: '*'
        Access-Control-Allow-Methods:
          description: Specify the HTTP methods allowed when accessing the resource
          schema:
            type: string
          example: POST, OPTIONS
        Access-Control-Allow-Headers:
          description: Specify the headers allowed when accessing the resource
          schema:
            type: string
          example: Content-Type, Authorization
        Access-Control-Allow-Credentials:
          description: Indicates whether the browser should include credentials
          schema:
            type: boolean
        Access-Control-Expose-Headers:
          description: Headers exposed to the client
          schema:
            type: string
            example: X-Custom-Header1, X-Custom-Header2
    InternalServerError:
      description: INTERNAL SERVER ERROR
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TwilioServiceErrorResponse'
      headers:
        Access-Control-Allow-Origin:
          description: Specify the origin(s) allowed to access the resource
          schema:
            type: string
          example: '*'
        Access-Control-Allow-Methods:
          description: Specify the HTTP methods allowed when accessing the resource
          schema:
            type: string
          example: POST, OPTIONS
        Access-Control-Allow-Headers:
          description: Specify the headers allowed when accessing the resource
          schema:
            type: string
          example: Content-Type, Authorization
        Access-Control-Allow-Credentials:
          description: Indicates whether the browser should include credentials
          schema:
            type: boolean
        Access-Control-Expose-Headers:
          description: Headers exposed to the client
          schema:
            type: string
            example: X-Custom-Header1, X-Custom-Header2
    TooManyRequests:
      description: TOO MANY REQUEST
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TwilioServiceErrorResponse'
      headers:
        Access-Control-Allow-Origin:
          description: Specify the origin(s) allowed to access the resource
          schema:
            type: string
          example: '*'
        Access-Control-Allow-Methods:
          description: Specify the HTTP methods allowed when accessing the resource
          schema:
            type: string
          example: POST, OPTIONS
        Access-Control-Allow-Headers:
          description: Specify the headers allowed when accessing the resource
          schema:
            type: string
          example: Content-Type, Authorization
        Access-Control-Allow-Credentials:
          description: Indicates whether the browser should include credentials
          schema:
            type: boolean
        Access-Control-Expose-Headers:
          description: Headers exposed to the client
          schema:
            type: string
            example: X-Custom-Header1, X-Custom-Header2
    Conflict:
      description: CONFLICT
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TwilioServiceErrorResponse'
      headers:
        Access-Control-Allow-Origin:
          description: Specify the origin(s) allowed to access the resource
          schema:
            type: string
          example: '*'
        Access-Control-Allow-Methods:
          description: Specify the HTTP methods allowed when accessing the resource
          schema:
            type: string
          example: POST, OPTIONS
        Access-Control-Allow-Headers:
          description: Specify the headers allowed when accessing the resource
          schema:
            type: string
          example: Content-Type, Authorization
        Access-Control-Allow-Credentials:
          description: Indicates whether the browser should include credentials
          schema:
            type: boolean
        Access-Control-Expose-Headers:
          description: Headers exposed to the client
          schema:
            type: string
            example: X-Custom-Header1, X-Custom-Header2
