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

# Create Saved Metric

> Creates and saves a new metric configuration to the database. This does not execute the report, but stores the parameters for future use.



## OpenAPI

````yaml https://production.hifi.com/api/v2/openapi.json post /v2/reporting/metrics
openapi: 3.0.0
info:
  title: Hifi API
  version: 2.0.0
  description: API documentation for Hifi
servers:
  - url: https://production.hifibridge.com
    description: Production server
  - url: https://sandbox.hifibridge.com
    description: Sandbox server
security:
  - bearerAuth: []
tags:
  - name: Common
    description: Common endpoints
  - name: User
    description: User endpoints
  - name: Kyc
    description: Kyc endpoints
  - name: Wallet
    description: Wallet endpoints
  - name: Account
    description: Account endpoints
  - name: External Account
    description: External Account endpoints for managing beneficiary bank accounts
  - name: Fiat Account
    description: Fiat Account endpoints
  - name: Virtual Account
    description: Virtual Account endpoints
  - name: Onramp
    description: Onramp endpoints
  - name: Offramp
    description: Offramp endpoints
  - name: Orchestration Address
    description: >-
      Orchestration Address endpoints — persistent on-chain wallets that
      automatically off-ramp incoming stablecoin deposits to a USD bank account
  - name: Crypto Transfer
    description: Crypto Transfer endpoints
  - name: Cross-Chain Bridge
    description: Cross-Chain Bridge endpoints
  - name: Token Swap
    description: Token Swap endpoints
  - name: Canton Offers
    description: Canton Offers endpoints
  - name: Transfer Rules
    description: Transfer approval rules and configuration
  - name: Transfer Approvals
    description: Transfer approval workflow and admin actions
  - name: File
    description: File endpoints
  - name: Reporting
    description: Reporting and metrics endpoints
paths:
  /v2/reporting/metrics:
    post:
      tags:
        - Reporting
      summary: Create Saved Metric
      description: >-
        Creates and saves a new metric configuration to the database. This does
        not execute the report, but stores the parameters for future use.
      requestBody:
        $ref: '#/components/requestBodies/CreateMetricBody'
      responses:
        '201':
          $ref: '#/components/responses/CreateMetricResponse'
        '400':
          $ref: '#/components/responses/BadRequestResponse'
        '401':
          $ref: '#/components/responses/UnauthorizedResponse'
        '404':
          $ref: '#/components/responses/NotFoundResponse'
        '500':
          $ref: '#/components/responses/InternalServerErrorResponse'
components:
  requestBodies:
    CreateMetricBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CreateMetricRequest'
          examples:
            CreateMetricRequestExample:
              $ref: '#/components/examples/CreateMetricRequestExample'
            CreateMetricRequestWithBreakdownsExample:
              $ref: '#/components/examples/CreateMetricRequestWithBreakdownsExample'
  responses:
    CreateMetricResponse:
      description: Metric created successfully
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MetricResponse'
          examples:
            CreateMetricResponseExample:
              $ref: '#/components/examples/CreateMetricResponseExample'
    BadRequestResponse:
      description: Bad request - validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              error:
                type: object
                properties:
                  code:
                    type: string
                  message:
                    type: string
                  details:
                    type: object
                    description: Field-specific validation errors
    UnauthorizedResponse:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Unauthorized'
    NotFoundResponse:
      description: Resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              error:
                type: object
                properties:
                  code:
                    type: string
                  message:
                    type: string
    InternalServerErrorResponse:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InternalServerError'
  schemas:
    CreateMetricRequest:
      type: object
      description: Request to create a new saved metric
      properties:
        template:
          type: string
          enum:
            - GROSS_VOLUME
            - TRANSACTION_COUNT
            - NEW_USERS
          description: Metric template name
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: User-defined metric name
        params:
          $ref: '#/components/schemas/MetricParams'
        description:
          type: string
          nullable: true
          maxLength: 500
          description: Optional description for the metric
      required:
        - template
        - name
        - params
    MetricResponse:
      type: object
      description: Single metric response
      properties:
        status:
          type: string
          enum:
            - success
        data:
          $ref: '#/components/schemas/Metric'
        metadata:
          type: object
    Unauthorized:
      type: object
      properties:
        code:
          type: integer
          description: Error code
        error:
          type: string
          description: Error type
        errorDetails:
          type: string
          description: Detailed error message
    InternalServerError:
      type: object
      properties:
        code:
          type: integer
          description: Error code
        error:
          type: string
          description: Error type
        errorDetails:
          type: string
          description: Detailed error message
    MetricParams:
      type: object
      description: >
        Metric parameters. Structure varies by template, but common fields
        include:

        - Date range filters

        - Calculation interval

        - Breakdown dimensions

        - Template-specific filters


        Additional properties may be present based on the metric template.

        Each template may define template-specific parameters.
      properties:
        createdAfter:
          type: string
          format: date
          description: Filter transactions created after this date (ISO 8601)
        createdBefore:
          type: string
          format: date
          description: Filter transactions created before this date (ISO 8601)
        calculationInterval:
          type: string
          enum:
            - day
            - week
            - month
          description: Time interval for aggregation
        userIds:
          type: array
          items:
            type: string
            format: uuid
          description: Filter by specific user IDs
        transactionTypes:
          type: array
          items:
            type: string
            enum:
              - onramp
              - offramp
              - transfer
          description: Filter by transaction types
        transactionStatuses:
          type: array
          items:
            type: string
            enum:
              - AWAITING_FUNDS
              - COMPLETED
              - CRYPTO_FAILED
              - CRYPTO_INITIATED
              - CRYPTO_PENDING
              - FAILED
              - FIAT_FAILED
              - FIAT_INITIATED
              - FIAT_PENDING
              - FIAT_PROCESSED
              - FIAT_RETURNED
              - INITIATED
              - NOT_INITIATED
              - PENDING
              - QUOTE_FAILED
              - REJECTED
          description: Filter by transaction statuses
        breakdowns:
          type: array
          items:
            type: string
            enum:
              - transactionType
              - transactionStatus
              - userId
          maxItems: 2
          description: |
            Dimensions to group results by. Maximum 2 breakdowns allowed.
            Field names in response data will match these dimension names.
        limit:
          type: integer
          minimum: 1
          maximum: 10000
          default: 500
          description: Maximum number of records to return
      additionalProperties: true
    Metric:
      type: object
      description: A saved metric definition
      properties:
        id:
          type: string
          format: uuid
          description: Unique metric identifier
        profileId:
          type: string
          format: uuid
          description: Profile ID that owns this metric
        template:
          type: string
          enum:
            - GROSS_VOLUME
            - TRANSACTION_COUNT
            - NEW_USERS
          description: Metric template name
        name:
          type: string
          description: User-defined metric name
        params:
          $ref: '#/components/schemas/MetricParams'
        description:
          type: string
          nullable: true
          description: Optional description for the metric
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
      required:
        - id
        - profileId
        - template
        - name
        - params
        - createdAt
        - updatedAt
  examples:
    CreateMetricRequestExample:
      summary: Create metric request (GROSS_VOLUME)
      value:
        template: GROSS_VOLUME
        name: Daily Revenue Report
        params:
          createdAfter: '2025-11-01'
          createdBefore: '2025-11-07'
          calculationInterval: day
          transactionTypes:
            - onramp
            - offramp
    CreateMetricRequestWithBreakdownsExample:
      summary: Create metric request (TRANSACTION_COUNT with breakdowns)
      value:
        template: TRANSACTION_COUNT
        name: Monthly Transfer Analysis
        params:
          createdAfter: '2025-01-01'
          createdBefore: '2025-12-01'
          calculationInterval: month
          transactionTypes:
            - onramp
            - offramp
          transactionStatuses:
            - COMPLETED
          breakdowns:
            - transactionType
    CreateMetricResponseExample:
      summary: Created metric response
      value:
        status: success
        data:
          id: 9106f8e2-188f-4854-99fc-cb21ef6b998d
          profileId: e4c758d7-5475-4505-ba15-e129db0a441f
          template: GROSS_VOLUME
          name: Daily Revenue Report
          params:
            createdAfter: '2025-11-01'
            createdBefore: '2025-11-07'
            calculationInterval: day
            transactionTypes:
              - onramp
              - offramp
          createdAt: '2025-12-08T22:26:13.659Z'
          updatedAt: '2025-12-08T22:26:13.659Z'
        metadata: {}
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````