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

# Create a new Usage Metric

> Create a new Usage Metric



## OpenAPI

````yaml usage.2024-07-30.product.live POST /usage-metrics
openapi: 3.0.0
info:
  title: Usage
  description: Manage usage events and metrics
  version: '0.1'
servers:
  - url: https://dev.seqhq.io/api
    description: DEV
  - url: https://sandbox.sequencehq.com/api
    description: SANDBOX
  - url: https://eu.sequencehq.com/api
    description: PRODUCTION
security: []
tags: []
paths:
  /usage-metrics:
    servers: []
    parameters: []
    post:
      tags:
        - Usage Metrics
      summary: Create a new Usage Metric
      description: Create a new Usage Metric
      operationId: postUsageMetrics
      parameters:
        - name: Authorization
          in: header
          description: >-
            Your [API credentials](/reference/authentication). Eg. `Basic
            {credentials}`.
          required: true
          schema:
            type: string
        - name: Sequence-Version
          in: header
          description: Use this header to select an API version
          required: false
          schema:
            type: string
            enum:
              - '2024-07-30'
      requestBody:
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/CreateUsageMetricEndpointCreateUsageMetricRequestModel
              example:
                name: Total length of sent messages.
                description: Total length of sent messages.
                metricType: GROUPED
                eventType: message_sent
                aggregationType: COUNT
                aggregationProperty: message_length
                groupingProperty: channel
                unit: bytes
                deletedAt: '2022-06-28T16:47:00Z'
                propertyFilters:
                  channels:
                    - text
                    - email
                caseSensitive: true
                propertiesToNegate:
                  - channels
            examples:
              CreateUsageMetricEndpointCreateUsageMetricRequestModel:
                summary: ''
                value:
                  name: Total length of sent messages.
                  description: Total length of sent messages.
                  metricType: GROUPED
                  eventType: message_sent
                  aggregationType: COUNT
                  aggregationProperty: message_length
                  groupingProperty: channel
                  unit: bytes
                  deletedAt: '2022-06-28T16:47:00Z'
                  propertyFilters:
                    channels:
                      - text
                      - email
                  caseSensitive: true
                  propertiesToNegate:
                    - channels
        required: true
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/CreateUsageMetricEndpointProductCreateUsageMetricResponseModel
                example:
                  id: f092246c-6b90-4106-bcca-304ccf06bf45
                  sequenceAccountId: ec1479a2-6ba1-421f-a7de-0853a20d17a1
                  name: Total length of sent messages.
                  description: Total length of sent messages.
                  metricType: GROUPED
                  eventType: message_sent
                  aggregationType: COUNT
                  aggregationProperty: message_length
                  groupingProperty: channel
                  unit: bytes
                  createdAt: '2022-06-28T16:47:00Z'
                  deletedAt: '2022-06-28T16:47:00Z'
                  propertyFilters:
                    channels:
                      - text
                      - email
                  caseSensitive: true
                  propertiesToNegate:
                    - channels
                  parameters:
                    - id: 2963e49a-c8e0-4673-89f5-7a805c0faf14
                      usageMetricId: f092246c-6b90-4106-bcca-304ccf06bf45
                      name: myParam
                      type: INTEGER
                      description: My parameter
                      defaultValue: '10'
              examples:
                CreateUsageMetricEndpointProductCreateUsageMetricResponseModel:
                  summary: ''
                  value:
                    id: f092246c-6b90-4106-bcca-304ccf06bf45
                    sequenceAccountId: ec1479a2-6ba1-421f-a7de-0853a20d17a1
                    name: Total length of sent messages.
                    description: Total length of sent messages.
                    metricType: GROUPED
                    eventType: message_sent
                    aggregationType: COUNT
                    aggregationProperty: message_length
                    groupingProperty: channel
                    unit: bytes
                    createdAt: '2022-06-28T16:47:00Z'
                    deletedAt: '2022-06-28T16:47:00Z'
                    propertyFilters:
                      channels:
                        - text
                        - email
                    caseSensitive: true
                    propertiesToNegate:
                      - channels
                    parameters:
                      - id: 2963e49a-c8e0-4673-89f5-7a805c0faf14
                        usageMetricId: f092246c-6b90-4106-bcca-304ccf06bf45
                        name: myParam
                        type: INTEGER
                        description: My parameter
                        defaultValue: '10'
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '500':
          description: Internal Server Error
          content: {}
components:
  schemas:
    CreateUsageMetricEndpointCreateUsageMetricRequestModel:
      required:
        - aggregationType
        - eventType
        - metricType
        - name
      type: object
      example:
        name: Total length of sent messages.
        description: Total length of sent messages.
        metricType: GROUPED
        eventType: message_sent
        aggregationType: COUNT
        aggregationProperty: message_length
        groupingProperty: channel
        unit: bytes
        deletedAt: '2022-06-28T16:47:00Z'
        propertyFilters:
          channels:
            - text
            - email
        caseSensitive: true
        propertiesToNegate:
          - channels
      properties:
        name:
          type: string
          description: Human-readable name for this metric, which should be unique
          example: Total length of sent messages.
        description:
          type: string
          description: Description for this metric
          example: Total length of sent messages.
        metricType:
          $ref: '#/components/schemas/MetricType'
          description: Type of metric (simple or grouped)
        eventType:
          type: string
          description: The `eventType` of the Usage Event to be aggregated
          example: message_sent
        aggregationType:
          $ref: '#/components/schemas/AggregationType'
          description: Type of aggregation to perform
        aggregationProperty:
          type: string
          description: Property within the event to aggregate
          example: message_length
        groupingProperty:
          type: string
          description: Property within the event to group results by
          example: channel
        unit:
          type: string
          description: Human-readable unit of the aggregated metric, eg. API calls)
          example: bytes
        deletedAt:
          type: string
          description: Created at
          example: '2022-06-28T16:47:00Z'
        propertyFilters:
          type: object
          description: propertyFilters
          additionalProperties:
            type: object
        caseSensitive:
          type: boolean
          description: caseSensitive
          example: true
        propertiesToNegate:
          type: array
          description: propertiesToNegate
          example:
            - channels
          items:
            type: string
    CreateUsageMetricEndpointProductCreateUsageMetricResponseModel:
      required:
        - aggregationType
        - eventType
        - id
        - metricType
        - name
        - parameters
        - propertyFilters
        - sequenceAccountId
      type: object
      example:
        id: f092246c-6b90-4106-bcca-304ccf06bf45
        sequenceAccountId: ec1479a2-6ba1-421f-a7de-0853a20d17a1
        name: Total length of sent messages.
        description: Total length of sent messages.
        metricType: GROUPED
        eventType: message_sent
        aggregationType: COUNT
        aggregationProperty: message_length
        groupingProperty: channel
        unit: bytes
        createdAt: '2022-06-28T16:47:00Z'
        deletedAt: '2022-06-28T16:47:00Z'
        propertyFilters:
          channels:
            - text
            - email
        caseSensitive: true
        propertiesToNegate:
          - channels
        parameters:
          - id: 2963e49a-c8e0-4673-89f5-7a805c0faf14
            usageMetricId: f092246c-6b90-4106-bcca-304ccf06bf45
            name: myParam
            type: INTEGER
            description: My parameter
            defaultValue: '10'
      properties:
        id:
          type: string
          description: Unique ID
          example: f092246c-6b90-4106-bcca-304ccf06bf45
        sequenceAccountId:
          type: string
          description: Sequence Account ID
          example: ec1479a2-6ba1-421f-a7de-0853a20d17a1
        name:
          type: string
          description: Human-readable name for this metric, which should be unique
          example: Total length of sent messages.
        description:
          type: string
          description: Description for this metric
          example: Total length of sent messages.
        metricType:
          $ref: '#/components/schemas/MetricType'
          description: Type of metric (simple or grouped)
        eventType:
          type: string
          description: The `eventType` of the Usage Event to be aggregated
          example: message_sent
        aggregationType:
          $ref: '#/components/schemas/AggregationType'
          description: Type of aggregation to perform
        aggregationProperty:
          type: string
          description: Property within the event to aggregate
          example: message_length
        groupingProperty:
          type: string
          description: Property within the event to group results by
          example: channel
        unit:
          type: string
          description: Human-readable unit of the aggregated metric, eg. API calls)
          example: bytes
        createdAt:
          type: string
          description: Created at
          example: '2022-06-28T16:47:00Z'
        deletedAt:
          type: string
          description: Created at
          example: '2022-06-28T16:47:00Z'
        propertyFilters:
          type: object
          description: propertyFilters
          additionalProperties:
            type: object
        caseSensitive:
          type: boolean
          description: caseSensitive
          example: true
        propertiesToNegate:
          type: array
          description: propertiesToNegate
          example:
            - channels
          items:
            type: string
        parameters:
          type: array
          description: Required parameters
          example:
            - id: 2963e49a-c8e0-4673-89f5-7a805c0faf14
              usageMetricId: f092246c-6b90-4106-bcca-304ccf06bf45
              name: myParam
              type: INTEGER
              description: My parameter
              defaultValue: '10'
          items:
            $ref: '#/components/schemas/CustomMetricParameter'
    MetricType:
      type: string
      example: GROUPED
      enum:
        - SIMPLE
        - GROUPED
    AggregationType:
      type: string
      example: COUNT
      enum:
        - COUNT
        - UNIQUE
        - SUM
        - CUSTOM
    CustomMetricParameter:
      required:
        - defaultValue
        - description
        - id
        - name
        - type
        - usageMetricId
      type: object
      example:
        id: 2963e49a-c8e0-4673-89f5-7a805c0faf14
        usageMetricId: f092246c-6b90-4106-bcca-304ccf06bf45
        name: myParam
        type: INTEGER
        description: My parameter
        defaultValue: '10'
      properties:
        id:
          type: string
          example: 2963e49a-c8e0-4673-89f5-7a805c0faf14
        usageMetricId:
          type: string
          example: f092246c-6b90-4106-bcca-304ccf06bf45
        name:
          type: string
          example: myParam
        type:
          $ref: '#/components/schemas/CustomParameterType'
        description:
          type: string
          example: My parameter
        defaultValue:
          type: string
          example: '10'
    CustomParameterType:
      type: string
      example: INTEGER
      enum:
        - INTEGER
        - POSITIVE_INTEGER
        - NUMBER
        - POSITIVE_NUMBER

````