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

# Create a cost alert

> Creates either a condition-based alert (`condition` plus `dedup`) or a legacy threshold-based alert. The example monitors production AWS compute spend using Costory dimensions.



## OpenAPI

````yaml /api-reference/openapi.json post /alerts-v2/costAlerts
openapi: 3.0.0
info:
  title: Costory
  version: '1.0'
  description: API Documentation
servers:
  - url: ''
    description: Production server
security: []
paths:
  /alerts-v2/costAlerts:
    post:
      tags:
        - Alerts V2
      summary: Create a cost alert
      description: >-
        Creates either a condition-based alert (`condition` plus `dedup`) or a
        legacy threshold-based alert. The example monitors production AWS
        compute spend using Costory dimensions.
      operationId: createCostAlertV2
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    urlState:
                      type: string
                    name:
                      type: string
                      minLength: 1
                    currency:
                      type: string
                      enum:
                        - USD
                        - EUR
                        - GBP
                        - CNY
                    thresholds:
                      type: array
                      items:
                        type: object
                        properties:
                          value:
                            type: number
                          severityLevel:
                            type: string
                            enum:
                              - INFO
                              - WARNING
                              - RED
                          metricMode:
                            type: string
                            nullable: true
                            enum:
                              - ABSOLUTE_SPEND
                              - PERIOD_OVER_PERIOD_CHANGE
                              - null
                          changeBasis:
                            type: string
                            nullable: true
                            enum:
                              - ABSOLUTE_DELTA
                              - PERCENT_CHANGE
                              - null
                        required:
                          - value
                          - severityLevel
                      default: []
                    queries:
                      type: array
                      items:
                        oneOf:
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - condition
                              expression:
                                type: string
                                minLength: 1
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                            required:
                              - type
                              - expression
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - formula
                              formula:
                                type: string
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - formula
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - metric
                              metricId:
                                type: string
                              rawMetric:
                                type: string
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              unitOverride:
                                type: string
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - metricId
                              - aggregator
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - cost
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              currency:
                                type: string
                                enum:
                                  - USD
                                  - EUR
                                  - GBP
                                  - CNY
                              whereClause:
                                type: object
                                properties: {}
                                additionalProperties: {}
                              metricId:
                                type: string
                                enum:
                                  - cost
                                  - effective_cost
                                  - list_cost
                                  - contracted_cost
                                  - unblended_cost
                                  - net_unblended_cost
                                  - amortized_cost
                                  - net_amortized_cost
                              extendDashboardConditions:
                                type: boolean
                                default: true
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - aggregator
                              - whereClause
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - usage
                              whereClause:
                                type: object
                                properties: {}
                                additionalProperties: {}
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              metricId:
                                type: string
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - whereClause
                              - aggregator
                              - metricId
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - budget
                              budgetId:
                                type: string
                              budgetLineId:
                                type: string
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              virtualDimensionValue:
                                type: string
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                                default: SUM
                            required:
                              - type
                              - budgetId
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - externalMetric
                              provider:
                                type: string
                                enum:
                                  - tsuga
                                  - bigquery
                                  - datadog
                                  - cloudwatch
                              integrationId:
                                type: string
                                minLength: 1
                                description: >-
                                  External metric integration ID from
                                  list_metrics(includeExternal: true).
                              metricName:
                                type: string
                                minLength: 1
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              groupByFields:
                                type: array
                                items:
                                  type: string
                                  minLength: 1
                                maxItems: 7
                                default: []
                              conditions:
                                type: string
                              dateColumn:
                                type: string
                                minLength: 1
                              metricColumn:
                                type: string
                                minLength: 1
                              gapFillingMethod:
                                type: string
                                enum:
                                  - ZERO
                                  - FORWARD_FILL
                                  - LINEAR_INTERPOLATION
                                  - SPREAD
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                            required:
                              - type
                              - provider
                              - integrationId
                              - metricName
                              - aggregator
                              - name
                              - colorIndex
                              - chartType
                        discriminator:
                          propertyName: type
                    queryName:
                      type: string
                      default: ''
                    evaluationPeriod:
                      type: string
                      enum:
                        - DAILY
                        - WEEKLY
                        - MONTHLY
                      default: DAILY
                    thresholdType:
                      type: string
                      enum:
                        - ABOVE
                        - UNDER
                      default: ABOVE
                    description:
                      type: string
                      default: ''
                    tagIds:
                      type: array
                      items:
                        anyOf:
                          - type: string
                          - type: object
                            properties:
                              name:
                                type: string
                                minLength: 1
                              color:
                                type: string
                                minLength: 1
                            required:
                              - name
                              - color
                      default: []
                    scopeId:
                      type: string
                      nullable: true
                    condition:
                      type: string
                      nullable: true
                    dedup:
                      oneOf:
                        - type: object
                          properties:
                            kind:
                              type: string
                              enum:
                                - CALENDAR
                            calendarUnit:
                              type: string
                              enum:
                                - WEEK
                                - MONTH
                          required:
                            - kind
                            - calendarUnit
                        - type: object
                          properties:
                            kind:
                              type: string
                              enum:
                                - ROLLING
                            windowDays:
                              type: integer
                              minimum: 0
                              exclusiveMinimum: true
                          required:
                            - kind
                            - windowDays
                        - nullable: true
                          type: string
                          enum:
                            - null
                    notificationChannel:
                      type: string
                      enum:
                        - SLACK
                    slackChannelId:
                      type: string
                      minLength: 1
                  required:
                    - urlState
                    - name
                    - currency
                    - queries
                    - notificationChannel
                    - slackChannelId
                - type: object
                  properties:
                    urlState:
                      type: string
                    name:
                      type: string
                      minLength: 1
                    currency:
                      type: string
                      enum:
                        - USD
                        - EUR
                        - GBP
                        - CNY
                    thresholds:
                      type: array
                      items:
                        type: object
                        properties:
                          value:
                            type: number
                          severityLevel:
                            type: string
                            enum:
                              - INFO
                              - WARNING
                              - RED
                          metricMode:
                            type: string
                            nullable: true
                            enum:
                              - ABSOLUTE_SPEND
                              - PERIOD_OVER_PERIOD_CHANGE
                              - null
                          changeBasis:
                            type: string
                            nullable: true
                            enum:
                              - ABSOLUTE_DELTA
                              - PERCENT_CHANGE
                              - null
                        required:
                          - value
                          - severityLevel
                      default: []
                    queries:
                      type: array
                      items:
                        oneOf:
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - condition
                              expression:
                                type: string
                                minLength: 1
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                            required:
                              - type
                              - expression
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - formula
                              formula:
                                type: string
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - formula
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - metric
                              metricId:
                                type: string
                              rawMetric:
                                type: string
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              unitOverride:
                                type: string
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - metricId
                              - aggregator
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - cost
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              currency:
                                type: string
                                enum:
                                  - USD
                                  - EUR
                                  - GBP
                                  - CNY
                              whereClause:
                                type: object
                                properties: {}
                                additionalProperties: {}
                              metricId:
                                type: string
                                enum:
                                  - cost
                                  - effective_cost
                                  - list_cost
                                  - contracted_cost
                                  - unblended_cost
                                  - net_unblended_cost
                                  - amortized_cost
                                  - net_amortized_cost
                              extendDashboardConditions:
                                type: boolean
                                default: true
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - aggregator
                              - whereClause
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - usage
                              whereClause:
                                type: object
                                properties: {}
                                additionalProperties: {}
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              metricId:
                                type: string
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - whereClause
                              - aggregator
                              - metricId
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - budget
                              budgetId:
                                type: string
                              budgetLineId:
                                type: string
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              virtualDimensionValue:
                                type: string
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                                default: SUM
                            required:
                              - type
                              - budgetId
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - externalMetric
                              provider:
                                type: string
                                enum:
                                  - tsuga
                                  - bigquery
                                  - datadog
                                  - cloudwatch
                              integrationId:
                                type: string
                                minLength: 1
                                description: >-
                                  External metric integration ID from
                                  list_metrics(includeExternal: true).
                              metricName:
                                type: string
                                minLength: 1
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              groupByFields:
                                type: array
                                items:
                                  type: string
                                  minLength: 1
                                maxItems: 7
                                default: []
                              conditions:
                                type: string
                              dateColumn:
                                type: string
                                minLength: 1
                              metricColumn:
                                type: string
                                minLength: 1
                              gapFillingMethod:
                                type: string
                                enum:
                                  - ZERO
                                  - FORWARD_FILL
                                  - LINEAR_INTERPOLATION
                                  - SPREAD
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                            required:
                              - type
                              - provider
                              - integrationId
                              - metricName
                              - aggregator
                              - name
                              - colorIndex
                              - chartType
                        discriminator:
                          propertyName: type
                    queryName:
                      type: string
                      default: ''
                    evaluationPeriod:
                      type: string
                      enum:
                        - DAILY
                        - WEEKLY
                        - MONTHLY
                      default: DAILY
                    thresholdType:
                      type: string
                      enum:
                        - ABOVE
                        - UNDER
                      default: ABOVE
                    description:
                      type: string
                      default: ''
                    tagIds:
                      type: array
                      items:
                        anyOf:
                          - type: string
                          - type: object
                            properties:
                              name:
                                type: string
                                minLength: 1
                              color:
                                type: string
                                minLength: 1
                            required:
                              - name
                              - color
                      default: []
                    scopeId:
                      type: string
                      nullable: true
                    condition:
                      type: string
                      nullable: true
                    dedup:
                      oneOf:
                        - type: object
                          properties:
                            kind:
                              type: string
                              enum:
                                - CALENDAR
                            calendarUnit:
                              type: string
                              enum:
                                - WEEK
                                - MONTH
                          required:
                            - kind
                            - calendarUnit
                        - type: object
                          properties:
                            kind:
                              type: string
                              enum:
                                - ROLLING
                            windowDays:
                              type: integer
                              minimum: 0
                              exclusiveMinimum: true
                          required:
                            - kind
                            - windowDays
                        - nullable: true
                          type: string
                          enum:
                            - null
                    notificationChannel:
                      type: string
                      enum:
                        - TEAMS
                    teamsChannelId:
                      type: string
                      minLength: 1
                  required:
                    - urlState
                    - name
                    - currency
                    - queries
                    - notificationChannel
                    - teamsChannelId
                - type: object
                  properties:
                    urlState:
                      type: string
                    name:
                      type: string
                      minLength: 1
                    currency:
                      type: string
                      enum:
                        - USD
                        - EUR
                        - GBP
                        - CNY
                    thresholds:
                      type: array
                      items:
                        type: object
                        properties:
                          value:
                            type: number
                          severityLevel:
                            type: string
                            enum:
                              - INFO
                              - WARNING
                              - RED
                          metricMode:
                            type: string
                            nullable: true
                            enum:
                              - ABSOLUTE_SPEND
                              - PERIOD_OVER_PERIOD_CHANGE
                              - null
                          changeBasis:
                            type: string
                            nullable: true
                            enum:
                              - ABSOLUTE_DELTA
                              - PERCENT_CHANGE
                              - null
                        required:
                          - value
                          - severityLevel
                      default: []
                    queries:
                      type: array
                      items:
                        oneOf:
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - condition
                              expression:
                                type: string
                                minLength: 1
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                            required:
                              - type
                              - expression
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - formula
                              formula:
                                type: string
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - formula
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - metric
                              metricId:
                                type: string
                              rawMetric:
                                type: string
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              unitOverride:
                                type: string
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - metricId
                              - aggregator
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - cost
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              currency:
                                type: string
                                enum:
                                  - USD
                                  - EUR
                                  - GBP
                                  - CNY
                              whereClause:
                                type: object
                                properties: {}
                                additionalProperties: {}
                              metricId:
                                type: string
                                enum:
                                  - cost
                                  - effective_cost
                                  - list_cost
                                  - contracted_cost
                                  - unblended_cost
                                  - net_unblended_cost
                                  - amortized_cost
                                  - net_amortized_cost
                              extendDashboardConditions:
                                type: boolean
                                default: true
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - aggregator
                              - whereClause
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - usage
                              whereClause:
                                type: object
                                properties: {}
                                additionalProperties: {}
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              metricId:
                                type: string
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              reducer:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              shiftAmount:
                                type: integer
                              shiftUnit:
                                type: string
                                enum:
                                  - DAY
                                  - WEEK
                                  - MONTH
                            required:
                              - type
                              - whereClause
                              - aggregator
                              - metricId
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - budget
                              budgetId:
                                type: string
                              budgetLineId:
                                type: string
                              groupBy:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                                      minLength: 1
                                  - nullable: true
                                    type: string
                                    enum:
                                      - null
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              virtualDimensionValue:
                                type: string
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                                default: SUM
                            required:
                              - type
                              - budgetId
                              - name
                              - colorIndex
                              - chartType
                          - type: object
                            properties:
                              type:
                                type: string
                                enum:
                                  - externalMetric
                              provider:
                                type: string
                                enum:
                                  - tsuga
                                  - bigquery
                                  - datadog
                                  - cloudwatch
                              integrationId:
                                type: string
                                minLength: 1
                                description: >-
                                  External metric integration ID from
                                  list_metrics(includeExternal: true).
                              metricName:
                                type: string
                                minLength: 1
                              aggregator:
                                type: string
                                enum:
                                  - SUM
                                  - AVG
                                  - MAX
                                  - MIN
                              groupByFields:
                                type: array
                                items:
                                  type: string
                                  minLength: 1
                                maxItems: 7
                                default: []
                              conditions:
                                type: string
                              dateColumn:
                                type: string
                                minLength: 1
                              metricColumn:
                                type: string
                                minLength: 1
                              gapFillingMethod:
                                type: string
                                enum:
                                  - ZERO
                                  - FORWARD_FILL
                                  - LINEAR_INTERPOLATION
                                  - SPREAD
                              name:
                                type: string
                              alias:
                                type: string
                                minLength: 1
                                maxLength: 50
                              visible:
                                type: boolean
                                default: true
                              colorIndex:
                                type: number
                              chartType:
                                type: string
                                enum:
                                  - BAR
                                  - LINE
                                  - AREA
                                  - WATERFALL
                                  - TABLE
                              colorPalette:
                                type: string
                                enum:
                                  - DEFAULT
                                  - PIYG
                                  - RDYLBU
                                  - CLASSIC
                                default: DEFAULT
                              rollingAggregation:
                                type: object
                                properties:
                                  aggregator:
                                    type: string
                                    enum:
                                      - SUM
                                      - AVG
                                      - MAX
                                      - MIN
                                  window:
                                    type: object
                                    properties:
                                      preset:
                                        type: string
                                        enum:
                                          - MONTH
                                          - WEEK
                                      relativeDays:
                                        type: integer
                                        minimum: 1
                                required:
                                  - aggregator
                                  - window
                            required:
                              - type
                              - provider
                              - integrationId
                              - metricName
                              - aggregator
                              - name
                              - colorIndex
                              - chartType
                        discriminator:
                          propertyName: type
                    queryName:
                      type: string
                      default: ''
                    evaluationPeriod:
                      type: string
                      enum:
                        - DAILY
                        - WEEKLY
                        - MONTHLY
                      default: DAILY
                    thresholdType:
                      type: string
                      enum:
                        - ABOVE
                        - UNDER
                      default: ABOVE
                    description:
                      type: string
                      default: ''
                    tagIds:
                      type: array
                      items:
                        anyOf:
                          - type: string
                          - type: object
                            properties:
                              name:
                                type: string
                                minLength: 1
                              color:
                                type: string
                                minLength: 1
                            required:
                              - name
                              - color
                      default: []
                    scopeId:
                      type: string
                      nullable: true
                    condition:
                      type: string
                      nullable: true
                    dedup:
                      oneOf:
                        - type: object
                          properties:
                            kind:
                              type: string
                              enum:
                                - CALENDAR
                            calendarUnit:
                              type: string
                              enum:
                                - WEEK
                                - MONTH
                          required:
                            - kind
                            - calendarUnit
                        - type: object
                          properties:
                            kind:
                              type: string
                              enum:
                                - ROLLING
                            windowDays:
                              type: integer
                              minimum: 0
                              exclusiveMinimum: true
                          required:
                            - kind
                            - windowDays
                        - nullable: true
                          type: string
                          enum:
                            - null
                    notificationChannel:
                      type: string
                      enum:
                        - EMAIL
                    emails:
                      type: array
                      items:
                        type: string
                        format: email
                      minItems: 1
                  required:
                    - urlState
                    - name
                    - currency
                    - queries
                    - notificationChannel
                    - emails
            example:
              name: Production compute spend increased 20% week over week
              description: >-
                Notify FinOps when the seven-day AWS compute run rate materially
                increases.
              urlState: >-
                metricId=cost&groupBy=cos_service_name&datePreset=TRAILING_30_DAYS
              currency: USD
              queries:
                - type: cost
                  name: a
                  alias: Production AWS compute
                  aggregator: SUM
                  metricId: cost
                  currency: USD
                  groupBy: cos_service_name
                  whereClause:
                    combinator: and
                    rules:
                      - field: cos_provider
                        operator: in
                        value:
                          - AWS
                      - field: cos_environment
                        operator: in
                        value:
                          - production
                      - field: cos_service_name
                        operator: in
                        value:
                          - AmazonEC2
                          - AmazonRDS
                  visible: true
                  colorIndex: 0
                  chartType: LINE
              condition: >-
                rollingSum(a, 7, DAY) > timeShift(rollingSum(a, 7, DAY), 7, DAY)
                * 1.2 and rollingSum(a, 7, DAY) > 12000
              dedup:
                kind: CALENDAR
                calendarUnit: WEEK
              thresholds: []
              notificationChannel: EMAIL
              emails:
                - finops@acme.com
                - cloud-platform@acme.com
              tagIds: []
      responses:
        '201':
          description: Cost alert created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CostAlert'
        '400':
          description: Invalid alert, condition, query, or scope
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AlertError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
      security:
        - bearerAuth: []
components:
  schemas:
    CostAlert:
      type: object
      properties:
        id:
          type: string
        organizationId:
          type: string
        createdAt:
          type: string
          nullable: true
          format: date-time
        createdById:
          type: string
        archivedAt:
          type: string
          nullable: true
          format: date-time
        scopeId:
          type: string
          nullable: true
        urlState:
          type: string
        name:
          type: string
        currency:
          type: string
          enum:
            - USD
            - EUR
            - GBP
            - CNY
        queryName:
          type: string
        queries:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - condition
                  expression:
                    type: string
                    minLength: 1
                  name:
                    type: string
                  alias:
                    type: string
                    minLength: 1
                    maxLength: 50
                  visible:
                    type: boolean
                    default: true
                  colorIndex:
                    type: number
                  chartType:
                    type: string
                    enum:
                      - BAR
                      - LINE
                      - AREA
                      - WATERFALL
                      - TABLE
                required:
                  - type
                  - expression
                  - name
                  - colorIndex
                  - chartType
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - formula
                  formula:
                    type: string
                  name:
                    type: string
                  alias:
                    type: string
                    minLength: 1
                    maxLength: 50
                  visible:
                    type: boolean
                    default: true
                  colorIndex:
                    type: number
                  chartType:
                    type: string
                    enum:
                      - BAR
                      - LINE
                      - AREA
                      - WATERFALL
                      - TABLE
                  rollingAggregation:
                    type: object
                    properties:
                      aggregator:
                        type: string
                        enum:
                          - SUM
                          - AVG
                          - MAX
                          - MIN
                      window:
                        type: object
                        properties:
                          preset:
                            type: string
                            enum:
                              - MONTH
                              - WEEK
                          relativeDays:
                            type: integer
                            minimum: 1
                    required:
                      - aggregator
                      - window
                  shiftAmount:
                    type: integer
                  shiftUnit:
                    type: string
                    enum:
                      - DAY
                      - WEEK
                      - MONTH
                required:
                  - type
                  - formula
                  - name
                  - colorIndex
                  - chartType
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - metric
                  metricId:
                    type: string
                  rawMetric:
                    type: string
                  groupBy:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                          minLength: 1
                      - nullable: true
                        type: string
                        enum:
                          - null
                  unitOverride:
                    type: string
                  aggregator:
                    type: string
                    enum:
                      - SUM
                      - AVG
                      - MAX
                      - MIN
                  reducer:
                    type: string
                    enum:
                      - SUM
                      - AVG
                      - MAX
                      - MIN
                  name:
                    type: string
                  alias:
                    type: string
                    minLength: 1
                    maxLength: 50
                  visible:
                    type: boolean
                    default: true
                  colorIndex:
                    type: number
                  chartType:
                    type: string
                    enum:
                      - BAR
                      - LINE
                      - AREA
                      - WATERFALL
                      - TABLE
                  colorPalette:
                    type: string
                    enum:
                      - DEFAULT
                      - PIYG
                      - RDYLBU
                      - CLASSIC
                    default: DEFAULT
                  rollingAggregation:
                    type: object
                    properties:
                      aggregator:
                        type: string
                        enum:
                          - SUM
                          - AVG
                          - MAX
                          - MIN
                      window:
                        type: object
                        properties:
                          preset:
                            type: string
                            enum:
                              - MONTH
                              - WEEK
                          relativeDays:
                            type: integer
                            minimum: 1
                    required:
                      - aggregator
                      - window
                  shiftAmount:
                    type: integer
                  shiftUnit:
                    type: string
                    enum:
                      - DAY
                      - WEEK
                      - MONTH
                required:
                  - type
                  - metricId
                  - aggregator
                  - name
                  - colorIndex
                  - chartType
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - cost
                  groupBy:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                          minLength: 1
                      - nullable: true
                        type: string
                        enum:
                          - null
                  aggregator:
                    type: string
                    enum:
                      - SUM
                      - AVG
                      - MAX
                      - MIN
                  currency:
                    type: string
                    enum:
                      - USD
                      - EUR
                      - GBP
                      - CNY
                  whereClause:
                    type: object
                    properties: {}
                    additionalProperties: {}
                  metricId:
                    type: string
                    enum:
                      - cost
                      - effective_cost
                      - list_cost
                      - contracted_cost
                      - unblended_cost
                      - net_unblended_cost
                      - amortized_cost
                      - net_amortized_cost
                  extendDashboardConditions:
                    type: boolean
                    default: true
                  name:
                    type: string
                  alias:
                    type: string
                    minLength: 1
                    maxLength: 50
                  reducer:
                    type: string
                    enum:
                      - SUM
                      - AVG
                      - MAX
                      - MIN
                  visible:
                    type: boolean
                    default: true
                  colorIndex:
                    type: number
                  chartType:
                    type: string
                    enum:
                      - BAR
                      - LINE
                      - AREA
                      - WATERFALL
                      - TABLE
                  colorPalette:
                    type: string
                    enum:
                      - DEFAULT
                      - PIYG
                      - RDYLBU
                      - CLASSIC
                    default: DEFAULT
                  rollingAggregation:
                    type: object
                    properties:
                      aggregator:
                        type: string
                        enum:
                          - SUM
                          - AVG
                          - MAX
                          - MIN
                      window:
                        type: object
                        properties:
                          preset:
                            type: string
                            enum:
                              - MONTH
                              - WEEK
                          relativeDays:
                            type: integer
                            minimum: 1
                    required:
                      - aggregator
                      - window
                  shiftAmount:
                    type: integer
                  shiftUnit:
                    type: string
                    enum:
                      - DAY
                      - WEEK
                      - MONTH
                required:
                  - type
                  - aggregator
                  - whereClause
                  - name
                  - colorIndex
                  - chartType
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - usage
                  whereClause:
                    type: object
                    properties: {}
                    additionalProperties: {}
                  aggregator:
                    type: string
                    enum:
                      - SUM
                      - AVG
                      - MAX
                      - MIN
                  groupBy:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                          minLength: 1
                      - nullable: true
                        type: string
                        enum:
                          - null
                  metricId:
                    type: string
                  name:
                    type: string
                  alias:
                    type: string
                    minLength: 1
                    maxLength: 50
                  reducer:
                    type: string
                    enum:
                      - SUM
                      - AVG
                      - MAX
                      - MIN
                  visible:
                    type: boolean
                    default: true
                  colorIndex:
                    type: number
                  chartType:
                    type: string
                    enum:
                      - BAR
                      - LINE
                      - AREA
                      - WATERFALL
                      - TABLE
                  colorPalette:
                    type: string
                    enum:
                      - DEFAULT
                      - PIYG
                      - RDYLBU
                      - CLASSIC
                    default: DEFAULT
                  rollingAggregation:
                    type: object
                    properties:
                      aggregator:
                        type: string
                        enum:
                          - SUM
                          - AVG
                          - MAX
                          - MIN
                      window:
                        type: object
                        properties:
                          preset:
                            type: string
                            enum:
                              - MONTH
                              - WEEK
                          relativeDays:
                            type: integer
                            minimum: 1
                    required:
                      - aggregator
                      - window
                  shiftAmount:
                    type: integer
                  shiftUnit:
                    type: string
                    enum:
                      - DAY
                      - WEEK
                      - MONTH
                required:
                  - type
                  - whereClause
                  - aggregator
                  - metricId
                  - name
                  - colorIndex
                  - chartType
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - budget
                  budgetId:
                    type: string
                  budgetLineId:
                    type: string
                  groupBy:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                          minLength: 1
                      - nullable: true
                        type: string
                        enum:
                          - null
                  name:
                    type: string
                  alias:
                    type: string
                    minLength: 1
                    maxLength: 50
                  virtualDimensionValue:
                    type: string
                  visible:
                    type: boolean
                    default: true
                  colorIndex:
                    type: number
                  chartType:
                    type: string
                    enum:
                      - BAR
                      - LINE
                      - AREA
                      - WATERFALL
                      - TABLE
                  colorPalette:
                    type: string
                    enum:
                      - DEFAULT
                      - PIYG
                      - RDYLBU
                      - CLASSIC
                    default: DEFAULT
                  rollingAggregation:
                    type: object
                    properties:
                      aggregator:
                        type: string
                        enum:
                          - SUM
                          - AVG
                          - MAX
                          - MIN
                      window:
                        type: object
                        properties:
                          preset:
                            type: string
                            enum:
                              - MONTH
                              - WEEK
                          relativeDays:
                            type: integer
                            minimum: 1
                    required:
                      - aggregator
                      - window
                  aggregator:
                    type: string
                    enum:
                      - SUM
                      - AVG
                      - MAX
                      - MIN
                    default: SUM
                required:
                  - type
                  - budgetId
                  - name
                  - colorIndex
                  - chartType
              - type: object
                properties:
                  type:
                    type: string
                    enum:
                      - externalMetric
                  provider:
                    type: string
                    enum:
                      - tsuga
                      - bigquery
                      - datadog
                      - cloudwatch
                  integrationId:
                    type: string
                    minLength: 1
                    description: >-
                      External metric integration ID from
                      list_metrics(includeExternal: true).
                  metricName:
                    type: string
                    minLength: 1
                  aggregator:
                    type: string
                    enum:
                      - SUM
                      - AVG
                      - MAX
                      - MIN
                  groupByFields:
                    type: array
                    items:
                      type: string
                      minLength: 1
                    maxItems: 7
                    default: []
                  conditions:
                    type: string
                  dateColumn:
                    type: string
                    minLength: 1
                  metricColumn:
                    type: string
                    minLength: 1
                  gapFillingMethod:
                    type: string
                    enum:
                      - ZERO
                      - FORWARD_FILL
                      - LINEAR_INTERPOLATION
                      - SPREAD
                  name:
                    type: string
                  alias:
                    type: string
                    minLength: 1
                    maxLength: 50
                  visible:
                    type: boolean
                    default: true
                  colorIndex:
                    type: number
                  chartType:
                    type: string
                    enum:
                      - BAR
                      - LINE
                      - AREA
                      - WATERFALL
                      - TABLE
                  colorPalette:
                    type: string
                    enum:
                      - DEFAULT
                      - PIYG
                      - RDYLBU
                      - CLASSIC
                    default: DEFAULT
                  rollingAggregation:
                    type: object
                    properties:
                      aggregator:
                        type: string
                        enum:
                          - SUM
                          - AVG
                          - MAX
                          - MIN
                      window:
                        type: object
                        properties:
                          preset:
                            type: string
                            enum:
                              - MONTH
                              - WEEK
                          relativeDays:
                            type: integer
                            minimum: 1
                    required:
                      - aggregator
                      - window
                required:
                  - type
                  - provider
                  - integrationId
                  - metricName
                  - aggregator
                  - name
                  - colorIndex
                  - chartType
            discriminator:
              propertyName: type
        evaluationPeriod:
          type: string
          enum:
            - DAILY
            - WEEKLY
            - MONTHLY
        thresholdType:
          type: string
          enum:
            - ABOVE
            - UNDER
        snoozedUntil:
          type: string
          nullable: true
          format: date-time
        condition:
          type: string
          nullable: true
        conditionAdvancedExplorerQuery:
          type: object
          nullable: true
          properties: {}
          additionalProperties: {}
        dedupKind:
          type: string
          nullable: true
          enum:
            - CALENDAR
            - ROLLING
            - null
        dedupCalendarUnit:
          type: string
          nullable: true
          enum:
            - WEEK
            - MONTH
            - null
        dedupWindowDays:
          type: integer
          nullable: true
        notificationChannel:
          type: string
          enum:
            - EMAIL
            - SLACK
            - TEAMS
        emails:
          type: array
          items:
            type: string
            format: email
        slackChannelId:
          type: string
          nullable: true
        teamsChannelId:
          type: string
          nullable: true
        description:
          type: string
      required:
        - id
        - organizationId
        - createdAt
        - createdById
        - archivedAt
        - scopeId
        - urlState
        - name
        - currency
        - queryName
        - queries
        - evaluationPeriod
        - thresholdType
        - snoozedUntil
        - condition
        - conditionAdvancedExplorerQuery
        - dedupKind
        - dedupCalendarUnit
        - dedupWindowDays
        - notificationChannel
        - emails
        - slackChannelId
        - teamsChannelId
        - description
    AlertError:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    Unauthorized:
      type: object
      properties:
        error:
          type: string
          description: Unauthorized error message
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT or Clerk ak_* API key
      description: >-
        Send `Authorization: Bearer <credential>` using either a Clerk session
        JWT or a Clerk API key (`ak_*`). API keys may identify a user (`user_*`)
        or organization (`org_*`) principal and are generated in the Clerk
        Dashboard under API keys.

````