> ## 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.

# Aggregate events



## OpenAPI

````yaml /api-reference/openapi.json post /events/aggregate
openapi: 3.0.0
info:
  title: Costory
  version: '1.0'
  description: API Documentation
servers:
  - url: https://app-api.costory.io
security: []
paths:
  /events/aggregate:
    post:
      tags:
        - Events
      summary: Aggregate events
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                searchEvents:
                  type: object
                  properties:
                    githubSourceRepos:
                      type: array
                      items:
                        type: string
                      default: []
                    enableAllGithubRepos:
                      type: boolean
                    customBusinessEvents:
                      type: boolean
                      default: true
                    customTechnicalEvents:
                      type: boolean
                      default: true
                    labels:
                      type: array
                      items:
                        type: string
                      default: []
                    commitments:
                      type: boolean
                      default: false
                    reservations:
                      type: boolean
                      default: false
                    marketplacePurchases:
                      type: boolean
                      default: false
                    skuPriceChanges:
                      type: boolean
                      default: false
                    sources:
                      type: array
                      items:
                        type: string
                        enum:
                          - custom
                          - provider
                          - github
                          - api
                filters:
                  type: object
                  properties:
                    from:
                      type: string
                    to:
                      type: string
                    aggBy:
                      type: string
                      enum:
                        - Hour
                        - Day
                        - Week
                        - Month
                        - Period
                  required:
                    - from
                    - to
                    - aggBy
                bookmarkedEvents:
                  type: array
                  items:
                    type: string
                  default: []
              required:
                - searchEvents
                - filters
      responses:
        '200':
          description: Events aggregated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AggregatedEventsResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
      security:
        - bearerAuth: []
components:
  schemas:
    AggregatedEventsResponse:
      type: object
      properties:
        technicalEvents:
          type: array
          items:
            type: object
            properties:
              date:
                type: string
              events:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    metadata:
                      type: object
                      properties:
                        link:
                          type: string
                        source:
                          type: string
                          enum:
                            - github
                            - custom
                            - provider
                            - api
                    name:
                      type: string
                      minLength: 5
                    date:
                      type: string
                      nullable: true
                      format: date-time
                    description:
                      type: string
                    tags:
                      type: array
                      items:
                        type: object
                        properties:
                          key:
                            type: string
                          value:
                            type: string
                        required:
                          - key
                          - value
                    category:
                      type: string
                      enum:
                        - BUSINESS
                        - TECHNICAL
                        - PROVIDER
                    labels:
                      type: array
                      items:
                        type: string
                    viewUsedForCreation:
                      type: object
                      nullable: true
                      properties:
                        metricId:
                          type: string
                        currency:
                          type: string
                          enum:
                            - EUR
                            - USD
                            - GBP
                            - CNY
                          default: USD
                        limit:
                          type: number
                          nullable: true
                        threshold:
                          anyOf:
                            - type: number
                              nullable: true
                            - nullable: true
                              type: string
                              enum:
                                - null
                        aggBy:
                          type: string
                          enum:
                            - Hour
                            - Day
                            - Week
                            - Month
                            - Period
                        groupBy:
                          type: string
                        from:
                          type: string
                        to:
                          type: string
                        datePreset:
                          type: string
                          nullable: true
                          enum:
                            - TRAILING_30_DAYS
                            - TRAILING_90_DAYS
                            - TRAILING_45_DAYS
                            - TRAILING_3_DAYS
                            - TRAILING_7_DAYS
                            - TRAILING_14_WEEKS
                            - MTD
                            - QTD
                            - YTD
                            - LAST_WEEK
                            - LAST_MONTH
                            - LAST_3_MONTHS
                            - LAST_6_MONTHS
                            - LAST_12_MONTHS
                            - LAST_4_YEARS
                            - LAST_INVOICE_MONTH
                            - null
                        previousFrom:
                          type: string
                        previousTo:
                          type: string
                        explorerChartType:
                          type: string
                          enum:
                            - BAR
                            - LINE
                            - AREA
                            - WATERFALL
                            - TABLE
                          default: BAR
                        whereClause:
                          type: object
                          properties: {}
                          additionalProperties: {}
                        bookmarkedEvents:
                          type: array
                          items:
                            type: string
                        eventsFilter:
                          type: object
                          nullable: true
                          properties:
                            githubSourceRepos:
                              type: array
                              items:
                                type: string
                              default: []
                            enableAllGithubRepos:
                              type: boolean
                            customBusinessEvents:
                              type: boolean
                              default: true
                            customTechnicalEvents:
                              type: boolean
                              default: true
                            labels:
                              type: array
                              items:
                                type: string
                              default: []
                            commitments:
                              type: boolean
                              default: false
                            reservations:
                              type: boolean
                              default: false
                            marketplacePurchases:
                              type: boolean
                              default: false
                            skuPriceChanges:
                              type: boolean
                              default: false
                            sources:
                              type: array
                              items:
                                type: string
                                enum:
                                  - custom
                                  - provider
                                  - github
                                  - api
                        scopeId:
                          type: string
                          nullable: true
                      required:
                        - metricId
                        - limit
                        - aggBy
                        - groupBy
                        - from
                        - to
                        - datePreset
                        - previousFrom
                        - previousTo
                        - whereClause
                    createdBy:
                      type: object
                      nullable: true
                      properties:
                        id:
                          type: string
                        firstName:
                          type: string
                        lastName:
                          type: string
                      required:
                        - id
                        - firstName
                        - lastName
                  required:
                    - metadata
                    - name
                    - date
                    - description
                    - tags
                    - category
                    - labels
                    - viewUsedForCreation
            required:
              - date
              - events
        businessEvents:
          type: array
          items:
            type: object
            properties:
              date:
                type: string
              events:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    metadata:
                      type: object
                      properties:
                        link:
                          type: string
                        source:
                          type: string
                          enum:
                            - github
                            - custom
                            - provider
                            - api
                    name:
                      type: string
                      minLength: 5
                    date:
                      type: string
                      nullable: true
                      format: date-time
                    description:
                      type: string
                    tags:
                      type: array
                      items:
                        type: object
                        properties:
                          key:
                            type: string
                          value:
                            type: string
                        required:
                          - key
                          - value
                    category:
                      type: string
                      enum:
                        - BUSINESS
                        - TECHNICAL
                        - PROVIDER
                    labels:
                      type: array
                      items:
                        type: string
                    viewUsedForCreation:
                      type: object
                      nullable: true
                      properties:
                        metricId:
                          type: string
                        currency:
                          type: string
                          enum:
                            - EUR
                            - USD
                            - GBP
                            - CNY
                          default: USD
                        limit:
                          type: number
                          nullable: true
                        threshold:
                          anyOf:
                            - type: number
                              nullable: true
                            - nullable: true
                              type: string
                              enum:
                                - null
                        aggBy:
                          type: string
                          enum:
                            - Hour
                            - Day
                            - Week
                            - Month
                            - Period
                        groupBy:
                          type: string
                        from:
                          type: string
                        to:
                          type: string
                        datePreset:
                          type: string
                          nullable: true
                          enum:
                            - TRAILING_30_DAYS
                            - TRAILING_90_DAYS
                            - TRAILING_45_DAYS
                            - TRAILING_3_DAYS
                            - TRAILING_7_DAYS
                            - TRAILING_14_WEEKS
                            - MTD
                            - QTD
                            - YTD
                            - LAST_WEEK
                            - LAST_MONTH
                            - LAST_3_MONTHS
                            - LAST_6_MONTHS
                            - LAST_12_MONTHS
                            - LAST_4_YEARS
                            - LAST_INVOICE_MONTH
                            - null
                        previousFrom:
                          type: string
                        previousTo:
                          type: string
                        explorerChartType:
                          type: string
                          enum:
                            - BAR
                            - LINE
                            - AREA
                            - WATERFALL
                            - TABLE
                          default: BAR
                        whereClause:
                          type: object
                          properties: {}
                          additionalProperties: {}
                        bookmarkedEvents:
                          type: array
                          items:
                            type: string
                        eventsFilter:
                          type: object
                          nullable: true
                          properties:
                            githubSourceRepos:
                              type: array
                              items:
                                type: string
                              default: []
                            enableAllGithubRepos:
                              type: boolean
                            customBusinessEvents:
                              type: boolean
                              default: true
                            customTechnicalEvents:
                              type: boolean
                              default: true
                            labels:
                              type: array
                              items:
                                type: string
                              default: []
                            commitments:
                              type: boolean
                              default: false
                            reservations:
                              type: boolean
                              default: false
                            marketplacePurchases:
                              type: boolean
                              default: false
                            skuPriceChanges:
                              type: boolean
                              default: false
                            sources:
                              type: array
                              items:
                                type: string
                                enum:
                                  - custom
                                  - provider
                                  - github
                                  - api
                        scopeId:
                          type: string
                          nullable: true
                      required:
                        - metricId
                        - limit
                        - aggBy
                        - groupBy
                        - from
                        - to
                        - datePreset
                        - previousFrom
                        - previousTo
                        - whereClause
                    createdBy:
                      type: object
                      nullable: true
                      properties:
                        id:
                          type: string
                        firstName:
                          type: string
                        lastName:
                          type: string
                      required:
                        - id
                        - firstName
                        - lastName
                  required:
                    - metadata
                    - name
                    - date
                    - description
                    - tags
                    - category
                    - labels
                    - viewUsedForCreation
            required:
              - date
              - events
        providerEvents:
          type: array
          items:
            type: object
            properties:
              date:
                type: string
              events:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                    metadata:
                      type: object
                      properties:
                        link:
                          type: string
                        source:
                          type: string
                          enum:
                            - github
                            - custom
                            - provider
                            - api
                    name:
                      type: string
                      minLength: 5
                    date:
                      type: string
                      nullable: true
                      format: date-time
                    description:
                      type: string
                    tags:
                      type: array
                      items:
                        type: object
                        properties:
                          key:
                            type: string
                          value:
                            type: string
                        required:
                          - key
                          - value
                    category:
                      type: string
                      enum:
                        - BUSINESS
                        - TECHNICAL
                        - PROVIDER
                    labels:
                      type: array
                      items:
                        type: string
                    viewUsedForCreation:
                      type: object
                      nullable: true
                      properties:
                        metricId:
                          type: string
                        currency:
                          type: string
                          enum:
                            - EUR
                            - USD
                            - GBP
                            - CNY
                          default: USD
                        limit:
                          type: number
                          nullable: true
                        threshold:
                          anyOf:
                            - type: number
                              nullable: true
                            - nullable: true
                              type: string
                              enum:
                                - null
                        aggBy:
                          type: string
                          enum:
                            - Hour
                            - Day
                            - Week
                            - Month
                            - Period
                        groupBy:
                          type: string
                        from:
                          type: string
                        to:
                          type: string
                        datePreset:
                          type: string
                          nullable: true
                          enum:
                            - TRAILING_30_DAYS
                            - TRAILING_90_DAYS
                            - TRAILING_45_DAYS
                            - TRAILING_3_DAYS
                            - TRAILING_7_DAYS
                            - TRAILING_14_WEEKS
                            - MTD
                            - QTD
                            - YTD
                            - LAST_WEEK
                            - LAST_MONTH
                            - LAST_3_MONTHS
                            - LAST_6_MONTHS
                            - LAST_12_MONTHS
                            - LAST_4_YEARS
                            - LAST_INVOICE_MONTH
                            - null
                        previousFrom:
                          type: string
                        previousTo:
                          type: string
                        explorerChartType:
                          type: string
                          enum:
                            - BAR
                            - LINE
                            - AREA
                            - WATERFALL
                            - TABLE
                          default: BAR
                        whereClause:
                          type: object
                          properties: {}
                          additionalProperties: {}
                        bookmarkedEvents:
                          type: array
                          items:
                            type: string
                        eventsFilter:
                          type: object
                          nullable: true
                          properties:
                            githubSourceRepos:
                              type: array
                              items:
                                type: string
                              default: []
                            enableAllGithubRepos:
                              type: boolean
                            customBusinessEvents:
                              type: boolean
                              default: true
                            customTechnicalEvents:
                              type: boolean
                              default: true
                            labels:
                              type: array
                              items:
                                type: string
                              default: []
                            commitments:
                              type: boolean
                              default: false
                            reservations:
                              type: boolean
                              default: false
                            marketplacePurchases:
                              type: boolean
                              default: false
                            skuPriceChanges:
                              type: boolean
                              default: false
                            sources:
                              type: array
                              items:
                                type: string
                                enum:
                                  - custom
                                  - provider
                                  - github
                                  - api
                        scopeId:
                          type: string
                          nullable: true
                      required:
                        - metricId
                        - limit
                        - aggBy
                        - groupBy
                        - from
                        - to
                        - datePreset
                        - previousFrom
                        - previousTo
                        - whereClause
                    createdBy:
                      type: object
                      nullable: true
                      properties:
                        id:
                          type: string
                        firstName:
                          type: string
                        lastName:
                          type: string
                      required:
                        - id
                        - firstName
                        - lastName
                  required:
                    - metadata
                    - name
                    - date
                    - description
                    - tags
                    - category
                    - labels
                    - viewUsedForCreation
            required:
              - date
              - events
        bookmarkedSearchEvents:
          type: object
          properties:
            githubSourceRepos:
              type: array
              items:
                type: string
              default: []
            enableAllGithubRepos:
              type: boolean
            customBusinessEvents:
              type: boolean
              default: true
            customTechnicalEvents:
              type: boolean
              default: true
            labels:
              type: array
              items:
                type: string
              default: []
            commitments:
              type: boolean
              default: false
            reservations:
              type: boolean
              default: false
            marketplacePurchases:
              type: boolean
              default: false
            skuPriceChanges:
              type: boolean
              default: false
            sources:
              type: array
              items:
                type: string
                enum:
                  - custom
                  - provider
                  - github
                  - api
      required:
        - technicalEvents
        - businessEvents
        - providerEvents
        - bookmarkedSearchEvents
    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.

````