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

# Create aggregator

> Create a new aggregator.



## OpenAPI

````yaml post /v1/aggregators
openapi: 3.1.0
info:
  title: Hyperline API
  version: 0.0.0
servers:
  - url: https://api.hyperline.co
  - url: https://sandbox.api.hyperline.co
security: []
paths:
  /v1/aggregators:
    post:
      tags:
        - Aggregators
      summary: Create aggregator
      description: Create a new aggregator.
      operationId: createAggregator
      requestBody:
        description: Create aggregator payload
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/CreateAggregator'
                - oneOf:
                    - allOf:
                        - $ref: '#/components/schemas/CreateCountAggregator'
                        - properties:
                            entity:
                              type: string
                              description: The billable event entity to aggregate.
                              example: api_calls
                            type:
                              type: string
                              enum:
                                - metered
                                - licensed
                              default: metered
                              description: The type of aggregator.
                            where:
                              type:
                                - object
                                - 'null'
                              properties:
                                conditional:
                                  type: string
                                  enum:
                                    - and
                                    - or
                                fields:
                                  type: array
                                  items:
                                    allOf:
                                      - type: object
                                        properties:
                                          property:
                                            type: string
                                        required:
                                          - property
                                      - oneOf:
                                          - type: object
                                            properties:
                                              operator:
                                                type: string
                                                enum:
                                                  - isNull
                                                  - isNotNull
                                            required:
                                              - operator
                                          - type: object
                                            properties:
                                              operator:
                                                type: string
                                                enum:
                                                  - in
                                                  - notIn
                                              value:
                                                type: string
                                            required:
                                              - operator
                                              - value
                                          - type: object
                                            properties:
                                              operator:
                                                type: string
                                                enum:
                                                  - gte
                                                  - gt
                                                  - lt
                                                  - lte
                                              value:
                                                type: number
                                            required:
                                              - operator
                                              - value
                                          - type: object
                                            properties:
                                              operator:
                                                type: string
                                                enum:
                                                  - equals
                                                  - notEqual
                                              value:
                                                anyOf:
                                                  - type: string
                                                  - type: number
                                                  - type: boolean
                                            required:
                                              - operator
                                              - value
                              required:
                                - conditional
                                - fields
                              description: Filter conditions for the aggregation.
                            name:
                              type: string
                              description: Name of the aggregator.
                            description:
                              type:
                                - string
                                - 'null'
                              description: Description of the aggregator.
                            allow_negative_values:
                              type: boolean
                              default: false
                              description: >-
                                Whether the aggregator can produce negative
                                values.
                            aggregate_on_customers_enabled:
                              type: boolean
                              default: false
                              description: >-
                                Whether the aggregator should aggregate on
                                customers.
                            custom_event_name:
                              type: string
                              description: Custom event name for the aggregator.
                            exposed_event_keys:
                              type: array
                              items:
                                type: string
                              description: Event keys exposed by the aggregator.
                            unit_name:
                              type:
                                - string
                                - 'null'
                              description: >-
                                Display name of the unit being measured (e.g.
                                'user', 'request'). Used as fallback for
                                products attached to this aggregator.
                              example: user
                            default_interval_count:
                              type: integer
                              description: Default interval count for usage periods.
                            default_interval_period:
                              type: string
                              enum:
                                - days
                                - weeks
                                - months
                                - years
                              description: Default interval period for usage periods.
                            thresholds:
                              type: array
                              items:
                                type: object
                                properties:
                                  name:
                                    type: string
                                    description: Name of the threshold.
                                  threshold_value:
                                    type: number
                                    description: The threshold value.
                                  comparison_operator:
                                    type: string
                                    enum:
                                      - gte
                                      - lte
                                    default: gte
                                    description: The comparison operator for the threshold.
                                required:
                                  - threshold_value
                              description: Thresholds for the aggregator.
                            operation:
                              type: string
                              enum:
                                - count
                              description: The aggregation operation to perform.
                    - $ref: '#/components/schemas/CreateSumAggregator'
                  discriminator:
                    propertyName: operation
                    mapping:
                      count:
                        $ref: '#/components/schemas/CreateCountAggregator'
                      sum:
                        $ref: '#/components/schemas/CreateSumAggregator'
      responses:
        '201':
          description: The newly created aggregator
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Aggregator'
                  - type: object
      security:
        - bearer: []
components:
  schemas:
    CreateAggregator:
      oneOf:
        - $ref: '#/components/schemas/CreateCountAggregator'
        - type: object
          properties:
            entity:
              type: string
              description: The billable event entity to aggregate.
              example: api_calls
            operation:
              type: string
              enum:
                - sum
              description: The aggregation operation to perform.
            property:
              type: string
              description: The property to sum.
              example: amount
            type:
              type: string
              enum:
                - metered
                - licensed
              default: metered
              description: The type of aggregator.
            where:
              type:
                - object
                - 'null'
              properties:
                conditional:
                  type: string
                  enum:
                    - and
                    - or
                fields:
                  type: array
                  items:
                    allOf:
                      - type: object
                        properties:
                          property:
                            type: string
                        required:
                          - property
                      - oneOf:
                          - type: object
                            properties:
                              operator:
                                type: string
                                enum:
                                  - isNull
                                  - isNotNull
                            required:
                              - operator
                          - type: object
                            properties:
                              operator:
                                type: string
                                enum:
                                  - in
                                  - notIn
                              value:
                                type: string
                            required:
                              - operator
                              - value
                          - type: object
                            properties:
                              operator:
                                type: string
                                enum:
                                  - gte
                                  - gt
                                  - lt
                                  - lte
                              value:
                                type: number
                            required:
                              - operator
                              - value
                          - type: object
                            properties:
                              operator:
                                type: string
                                enum:
                                  - equals
                                  - notEqual
                              value:
                                anyOf:
                                  - type: string
                                  - type: number
                                  - type: boolean
                            required:
                              - operator
                              - value
              required:
                - conditional
                - fields
              description: Filter conditions for the aggregation.
          required:
            - entity
            - operation
            - property
      description: >-
        Aggregator configuration to compute usage from billable events. Either
        aggregator or aggregator_id is required.
    CreateCountAggregator:
      type: object
      properties:
        entity:
          type: string
          description: The billable event entity to aggregate.
          example: api_calls
        operation:
          type: string
          enum:
            - count
          description: The aggregation operation to perform.
        type:
          type: string
          enum:
            - metered
            - licensed
          default: metered
          description: The type of aggregator.
        where:
          type:
            - object
            - 'null'
          properties:
            conditional:
              type: string
              enum:
                - and
                - or
            fields:
              type: array
              items:
                allOf:
                  - type: object
                    properties:
                      property:
                        type: string
                    required:
                      - property
                  - oneOf:
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - isNull
                              - isNotNull
                        required:
                          - operator
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - in
                              - notIn
                          value:
                            type: string
                        required:
                          - operator
                          - value
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - gte
                              - gt
                              - lt
                              - lte
                          value:
                            type: number
                        required:
                          - operator
                          - value
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - equals
                              - notEqual
                          value:
                            anyOf:
                              - type: string
                              - type: number
                              - type: boolean
                        required:
                          - operator
                          - value
          required:
            - conditional
            - fields
          description: Filter conditions for the aggregation.
      required:
        - entity
        - operation
      description: >-
        Aggregator configuration to automatically count seats from billable
        events. Only count aggregators are supported for seat products.
    CreateSumAggregator:
      type: object
      properties:
        entity:
          type: string
          description: The billable event entity to aggregate.
          example: api_calls
        type:
          type: string
          enum:
            - metered
            - licensed
          default: metered
          description: The type of aggregator.
        where:
          type:
            - object
            - 'null'
          properties:
            conditional:
              type: string
              enum:
                - and
                - or
            fields:
              type: array
              items:
                allOf:
                  - type: object
                    properties:
                      property:
                        type: string
                    required:
                      - property
                  - oneOf:
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - isNull
                              - isNotNull
                        required:
                          - operator
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - in
                              - notIn
                          value:
                            type: string
                        required:
                          - operator
                          - value
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - gte
                              - gt
                              - lt
                              - lte
                          value:
                            type: number
                        required:
                          - operator
                          - value
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - equals
                              - notEqual
                          value:
                            anyOf:
                              - type: string
                              - type: number
                              - type: boolean
                        required:
                          - operator
                          - value
          required:
            - conditional
            - fields
          description: Filter conditions for the aggregation.
        name:
          type: string
          description: Name of the aggregator.
        description:
          type:
            - string
            - 'null'
          description: Description of the aggregator.
        allow_negative_values:
          type: boolean
          default: false
          description: Whether the aggregator can produce negative values.
        aggregate_on_customers_enabled:
          type: boolean
          default: false
          description: Whether the aggregator should aggregate on customers.
        custom_event_name:
          type: string
          description: Custom event name for the aggregator.
        exposed_event_keys:
          type: array
          items:
            type: string
          description: Event keys exposed by the aggregator.
        unit_name:
          type:
            - string
            - 'null'
          description: >-
            Display name of the unit being measured (e.g. 'user', 'request').
            Used as fallback for products attached to this aggregator.
          example: user
        default_interval_count:
          type: integer
          description: Default interval count for usage periods.
        default_interval_period:
          type: string
          enum:
            - days
            - weeks
            - months
            - years
          description: Default interval period for usage periods.
        thresholds:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
                description: Name of the threshold.
              threshold_value:
                type: number
                description: The threshold value.
              comparison_operator:
                type: string
                enum:
                  - gte
                  - lte
                default: gte
                description: The comparison operator for the threshold.
            required:
              - threshold_value
          description: Thresholds for the aggregator.
        operation:
          type: string
          enum:
            - sum
          description: The aggregation operation to perform.
        property:
          type: string
          description: The property to sum.
          example: amount
      required:
        - entity
        - operation
        - property
    Aggregator:
      type:
        - object
        - 'null'
      properties:
        id:
          type: string
        entity:
          type: string
        operation:
          type: string
          enum:
            - count
            - sum
        property:
          type:
            - string
            - 'null'
        where:
          type:
            - object
            - 'null'
          properties:
            conditional:
              type: string
              enum:
                - and
                - or
            fields:
              type: array
              items:
                allOf:
                  - type: object
                    properties:
                      property:
                        type: string
                    required:
                      - property
                  - oneOf:
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - isNull
                              - isNotNull
                        required:
                          - operator
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - in
                              - notIn
                          value:
                            type: string
                        required:
                          - operator
                          - value
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - gte
                              - gt
                              - lt
                              - lte
                          value:
                            type: number
                        required:
                          - operator
                          - value
                      - type: object
                        properties:
                          operator:
                            type: string
                            enum:
                              - equals
                              - notEqual
                          value:
                            anyOf:
                              - type: string
                              - type: number
                              - type: boolean
                        required:
                          - operator
                          - value
          required:
            - conditional
            - fields
        type:
          type: string
          enum:
            - metered
            - licensed
        name:
          type:
            - string
            - 'null'
        description:
          type:
            - string
            - 'null'
        allow_negative_values:
          type: boolean
        aggregate_on_customers_enabled:
          type: boolean
        default_interval_count:
          type:
            - integer
            - 'null'
        default_interval_period:
          type:
            - string
            - 'null'
          enum:
            - days
            - weeks
            - months
            - years
        custom_event_name:
          type:
            - string
            - 'null'
        exposed_event_keys:
          type: array
          items:
            type: string
        unit_name:
          type:
            - string
            - 'null'
        thresholds:
          type: array
          items:
            $ref: '#/components/schemas/AggregatorThreshold'
        created_at:
          type: string
          format: date
        updated_at:
          type: string
          format: date
      required:
        - id
        - entity
        - operation
        - property
        - where
        - type
        - name
        - description
        - allow_negative_values
        - aggregate_on_customers_enabled
        - default_interval_count
        - default_interval_period
        - custom_event_name
        - exposed_event_keys
        - unit_name
        - thresholds
        - created_at
        - updated_at
    AggregatorThreshold:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        threshold_value:
          type: number
        comparison_operator:
          type: string
          enum:
            - gte
            - lte
      required:
        - id
        - name
        - threshold_value
        - comparison_operator
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````