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

# Get Quantity Price

> Computes the price of a feature quantity for a customer based on their plan. This endpoint is only available to users with the finance api feature on their plan.



## OpenAPI

````yaml GET /api/v1/usage/quantity-price
openapi: 3.0.1
info:
  title: Metrifox API Documentation
  version: v1
  description: >-
    Welcome to Metrifox Platform's API documentation. This comprehensive API
    suite enables seamless integration with our platform, providing secure and
    efficient access to our services.
servers:
  - url: https://{defaultHost}
    variables:
      defaultHost:
        default: api.metrifox.com
security:
  - api_key: []
paths:
  /api/v1/usage/quantity-price:
    get:
      tags:
        - Usage
      summary: Compute the price of a usage quantity for a feature
      description: >-
        Computes the price of a feature quantity for a customer based on their
        plan. This endpoint is only available to users with the finance api
        feature on their plan.
      parameters:
        - name: customer_key
          in: query
          required: true
          description: The customer key to compute the price for
          schema:
            type: string
        - name: feature_key
          in: query
          required: true
          description: The feature key to compute the price for
          schema:
            type: string
        - name: quantity
          in: query
          required: true
          description: The quantity you want to price
          schema:
            type: number
            minimum: 0
      responses:
        '200':
          description: Quantity price computed
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: Quantity price fetched
                  data:
                    type: object
                    properties:
                      customer_key:
                        type: string
                      feature_key:
                        type: string
                      quantity:
                        type: number
                      price:
                        type: number
                        description: Computed price for the specified quantity
                      unit:
                        type: string
                        description: Currency code (This could also be credits)
                      applied_tiers:
                        type: array
                        description: >
                          For usage-based features with tiered pricing, a
                          breakdown of each tier band the requested quantity
                          crossed.

                          Empty for non-tiered pricing (e.g. pre-paid credit
                          features). Each entry is flat — tier definition fields

                          (`first_unit`, `last_unit`, `unit_price`, …) sit
                          alongside the per-band applied result
                          (`units_consumed`,

                          `tier_price`).
                        items:
                          type: object
                          properties:
                            first_unit:
                              type: integer
                              description: First unit covered by this tier band (inclusive)
                            last_unit:
                              type: integer
                              description: Last unit covered by this tier band (inclusive)
                            pricing_model:
                              type: string
                              description: >-
                                Pricing model for the tier (e.g. `per_unit`,
                                `package`, `flat_fee`, `percentage`)
                            unit_price:
                              type: number
                              nullable: true
                              description: >-
                                Price per unit (when `pricing_model` is
                                `per_unit`)
                            package_price:
                              type: number
                              nullable: true
                              description: >-
                                Price per package (when `pricing_model` is
                                `package`)
                            package_size:
                              type: integer
                              nullable: true
                              description: Number of units per package
                            flat_fee:
                              type: number
                              nullable: true
                              description: Flat fee for this tier band
                            min_price:
                              type: number
                              nullable: true
                              description: Minimum price for this tier band
                            max_price:
                              type: number
                              nullable: true
                              description: Maximum price for this tier band
                            percentage:
                              type: number
                              nullable: true
                              description: >-
                                Percentage rate (when `pricing_model` is
                                `percentage`)
                            total_unit_quantity:
                              type: integer
                              nullable: true
                              description: >-
                                Configured total unit quantity for the tier
                                (when applicable)
                            units_consumed:
                              type: number
                              description: >-
                                How many of the requested units fell into this
                                tier band
                            tier_price:
                              type: string
                              description: >-
                                Price contributed by this tier band (decimal
                                string)
              examples:
                sample:
                  summary: Example response
                  value:
                    message: Quantity price fetched
                    data:
                      customer_key: cust-6d11ca90
                      feature_key: feature_interview_booking
                      quantity: 500
                      price: 3000
                      unit: USD
                      applied_tiers:
                        - first_unit: 0
                          last_unit: 100
                          pricing_model: per_unit
                          unit_price: 10
                          package_price: null
                          package_size: null
                          flat_fee: null
                          min_price: null
                          max_price: null
                          percentage: null
                          total_unit_quantity: null
                          units_consumed: 100
                          tier_price: '1000.0'
                        - first_unit: 101
                          last_unit: 1000
                          pricing_model: per_unit
                          unit_price: 5
                          package_price: null
                          package_size: null
                          flat_fee: null
                          min_price: null
                          max_price: null
                          percentage: null
                          total_unit_quantity: null
                          units_consumed: 400
                          tier_price: '2000.0'
        '400':
          description: Bad request - Missing or invalid parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Validation failed
                errors:
                  customer_key:
                    - is required
                  feature_key:
                    - is required
                  quantity:
                    - must be a non-negative number
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Unauthorized
        '404':
          description: Customer or feature not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: Not found
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: |
            from metrifox_sdk import MetrifoxClient

            client = MetrifoxClient(api_key="your_api_key")

            # Compute the price of 500 units of a feature for a customer
            price = client.usages.quantity_price(
                customer_key="cust-6d11ca90",
                feature_key="feature_interview_booking",
                quantity=500,
            )

            print(f"{price['data']['price']} {price['data']['unit']}")

            # For tiered pricing, inspect the per-tier breakdown
            for tier in price['data'].get('applied_tiers', []):
                print(
                    f"  Tier {tier['first_unit']}-{tier['last_unit']}: "
                    f"{tier['units_consumed']} units -> {tier['tier_price']}"
                )
        - lang: javascript
          label: Javascript SDK
          source: |
            import { init } from "metrifox-js";

            const metrifoxClient = init({
              apiKey: process.env.METRIFOX_API_KEY
            });

            const price = await metrifoxClient.usages.quantityPrice({
              customerKey: "cust-6d11ca90",
              featureKey: "feature_interview_booking",
              quantity: 500,
            });

            console.log(`${price.data.price} ${price.data.unit}`);

            price.data.applied_tiers.forEach((tier) => {
              console.log(
                `  Tier ${tier.first_unit}-${tier.last_unit}: ` +
                `${tier.units_consumed} units -> ${tier.tier_price}`
              );
            });
        - lang: ruby
          label: Ruby SDK
          source: |
            require 'metrifox-sdk'

            METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })

            response = METRIFOX_SDK.usages.quantity_price(
              customer_key: "cust-6d11ca90",
              feature_key: "feature_interview_booking",
              quantity: 500
            )

            puts "#{response['data']['price']} #{response['data']['unit']}"

            response["data"]["applied_tiers"].each do |tier|
              puts "  Tier #{tier['first_unit']}-#{tier['last_unit']}: #{tier['units_consumed']} units -> #{tier['tier_price']}"
            end
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: Error message
        errors:
          type: object
          additionalProperties: true
          description: Detailed error information
  securitySchemes:
    api_key:
      type: apiKey
      name: x-api-key
      in: header

````