> ## 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 new event

> Endpoint to create a new event from the internal API.



## OpenAPI

````yaml /api-reference/openapi.json post /events
openapi: 3.0.0
info:
  title: Costory
  version: '1.0'
  description: API Documentation
servers:
  - url: https://app-api.costory.io
security: []
paths:
  /events:
    post:
      tags:
        - Events
      summary: Create a new event
      description: Endpoint to create a new event from the internal API.
      requestBody:
        content:
          application/json:
            schema:
              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
                metricId:
                  type: string
                  description: >-
                    Legacy event-level metric context. Usually omit it: when a
                    chart is provided in widgetEvents, the backend derives this
                    from its first cost query.
                groupBy:
                  type: string
                  description: >-
                    Legacy event-level group-by dimension. Usually omit it: when
                    a chart is provided in widgetEvents, the backend derives
                    this from its first cost query.
                datePreset:
                  type: string
                  enum:
                    - TRAILING_90_DAYS
                    - TRAILING_30_DAYS
                    - TRAILING_45_DAYS
                    - TRAILING_7_DAYS
                    - TRAILING_3_DAYS
                    - TRAILING_14_WEEKS
                    - MTD
                    - QTD
                    - YTD
                    - LAST_WEEK
                    - LAST_MONTH
                    - LAST_6_MONTHS
                    - LAST_12_MONTHS
                    - LAST_4_YEARS
                    - LAST_3_MONTHS
                    - LAST_INVOICE_MONTH
                  description: >-
                    Legacy event-level chart period preset. Usually omit it: the
                    backend derives the period from widgetEvents.
                startDate:
                  type: string
                  description: >-
                    Legacy event-level custom period start date. Usually omit
                    it: the backend derives the period from widgetEvents.
                endDate:
                  type: string
                  description: >-
                    Legacy event-level custom period end date. Usually omit it:
                    the backend derives the period from widgetEvents.
                conditions:
                  type: object
                  nullable: true
                  properties: {}
                  additionalProperties: {}
                  description: >-
                    Legacy event-level query-builder filter. Usually omit it:
                    the backend derives conditions from the first cost query's
                    whereClause in widgetEvents.
                currency:
                  type: string
                  enum:
                    - EUR
                    - USD
                    - GBP
                    - CNY
                  default: USD
                  description: >-
                    Legacy event-level chart currency. Usually omit it: the
                    backend derives currency from widgetEvents.
                widgetEvents:
                  type: array
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                      x:
                        type: number
                      'y':
                        type: number
                      w:
                        type: number
                      h:
                        type: number
                      createdAt:
                        type: string
                        nullable: true
                        format: date-time
                      updatedAt:
                        type: string
                        nullable: true
                        format: date-time
                      title:
                        type: string
                        default: ''
                      description:
                        type: string
                        default: ''
                      request:
                        type: object
                        properties:
                          period:
                            type: object
                            properties:
                              startDate:
                                type: string
                                nullable: true
                                format: date-time
                              endDate:
                                type: string
                                nullable: true
                                format: date-time
                              datePreset:
                                type: string
                                nullable: true
                                enum:
                                  - TRAILING_90_DAYS
                                  - TRAILING_30_DAYS
                                  - TRAILING_45_DAYS
                                  - TRAILING_7_DAYS
                                  - TRAILING_3_DAYS
                                  - TRAILING_14_WEEKS
                                  - MTD
                                  - QTD
                                  - YTD
                                  - LAST_WEEK
                                  - LAST_MONTH
                                  - LAST_6_MONTHS
                                  - LAST_12_MONTHS
                                  - LAST_4_YEARS
                                  - LAST_3_MONTHS
                                  - LAST_INVOICE_MONTH
                                  - null
                              aggBy:
                                type: string
                                enum:
                                  - Hour
                                  - Day
                                  - Week
                                  - Month
                                  - Period
                              forecastDays:
                                type: integer
                                minimum: 0
                              comparisonPeriod:
                                type: object
                                properties:
                                  startDate:
                                    type: string
                                    nullable: true
                                    format: date-time
                                  endDate:
                                    type: string
                                    nullable: true
                                    format: date-time
                                  enabled:
                                    type: boolean
                                  chartType:
                                    type: string
                                    enum:
                                      - WATERFALL
                                      - TABLE
                                      - KPI_BREAKDOWN
                                required:
                                  - startDate
                                  - endDate
                                  - enabled
                                  - chartType
                            required:
                              - aggBy
                          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
                                    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
                          eventsFilter:
                            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
                          bookmarkedEvents:
                            type: array
                            items:
                              type: string
                          scopeId:
                            type: string
                            nullable: true
                          limitOverride:
                            type: integer
                            minimum: 1
                            maximum: 1000
                        required:
                          - period
                          - queries
                          - eventsFilter
                          - bookmarkedEvents
                    required:
                      - x
                      - 'y'
                      - w
                      - h
                      - request
                  maxItems: 1
                  description: >-
                    Chart annotation associated with the event. Send an empty
                    array for an event without a chart, or one item containing
                    its grid layout, title, description, and Advanced Explorer
                    request. POST /events accepts at most one item.
                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
                - widgetEvents
            example:
              name: Migrated checkout service to Graviton
              date: '2026-07-20'
              description: >-
                Deployed ARM64 instances for the checkout service, reducing its
                EC2 compute cost by approximately 20%.
              category: TECHNICAL
              metadata:
                source: custom
                link: https://github.com/acme/checkout/pull/4821
              tags:
                - key: service
                  value: checkout
                - key: change
                  value: graviton-migration
              labels:
                - production
                - aws
              currency: USD
              widgetEvents: []
      responses:
        '201':
          description: Event created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EventIdResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Unauthorized'
      security:
        - bearerAuth: []
components:
  schemas:
    EventIdResponse:
      type: string
    BadRequest:
      type: object
      properties:
        error:
          type: string
          description: Error code
        reason:
          type: string
          description: Human-readable reason
        details:
          description: Additional details
        summary:
          type: string
          description: Optional short summary
      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.

````