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

# Consume Credits

> Consume credits with given parameters



## OpenAPI

````yaml https://api.getmeasure.com/api/v1/docs/api_spec.json post /companies/{company_id}/credits/consume
openapi: 3.1.0
info:
  title: Measure API
  description: APIs to communicate with Measure
  version: 1.0.0
servers:
  - url: https://api.getmeasure.com/api/v1
security: []
paths:
  /companies/{company_id}/credits/consume:
    post:
      tags:
        - Credits
      summary: Consume Credits
      description: Consume credits with given parameters
      operationId: Consume_Credits
      parameters:
        - name: company_id
          in: path
          description: 'The company ID with the prefix ''cmp_''. '
          required: true
          schema:
            description: 'The company ID with the prefix ''cmp_''. '
            type: string
        - name: Idempotency-Key
          in: header
          description: >-
            The idempotency key that will be used to ensure the request is only
            performed once
          schema:
            description: >-
              The idempotency key that will be used to ensure the request is
              only performed once
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RequestConsumeCreditsRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResponseCreditBalanceResponse'
      deprecated: false
      security:
        - apiKey:
            - ''
components:
  schemas:
    RequestConsumeCreditsRequest:
      properties:
        amount:
          $ref: '#/components/schemas/ModelAmount'
          description: The amount to be consumed
        credit_id:
          description: The specific credit ID to consume
          type:
            - 'null'
            - string
        customer_id:
          description: The customer ID to consume credits
          type: string
        item_id:
          description: The billable item ID whose units are to be consumed
          type:
            - 'null'
            - string
        note:
          description: Add any notes attached to the credit consumption
          type:
            - 'null'
            - string
        subscription_id:
          description: The specific subscription to consume credits from
          type:
            - 'null'
            - string
        type:
          description: The type of the credit to be consumed, can be one of AMOUNT or UNITS
          type: string
        units:
          description: The units to consume
          minimum: 0
          type:
            - 'null'
            - number
      required:
        - customer_id
        - type
      type: object
    ResponseCreditBalanceResponse:
      properties:
        total_amount:
          additionalProperties:
            $ref: '#/components/schemas/ModelAmount'
          type:
            - object
            - 'null'
        total_units:
          additionalProperties:
            format: double
            type: number
          type:
            - object
            - 'null'
        total_units_with_meta:
          additionalProperties:
            $ref: >-
              #/components/schemas/ResponseCreditBalanceBillableItemRepresentation
          type:
            - object
            - 'null'
      type: object
    ModelAmount:
      description: The amount which has value in cents and a currency
      properties:
        currency:
          type: string
        value_in_cents:
          format: int64
          type: integer
      type: object
    ResponseCreditBalanceBillableItemRepresentation:
      properties:
        company_id:
          description: The company ID for the billable item
          type: string
        created_at:
          description: The date the billable item was created
          format: date-time
          type: string
        description:
          description: Any description attached to the billable item
          type: string
        display_type:
          description: >-
            The display type of the billable item which can be one of UNITS,
            AMOUNT, THOUSAND_UNITS, MILLION_UNITS
          type: string
        editable:
          description: Whether the billable item can be further edited
          type: boolean
        external_name:
          description: The public name of the billable item
          type: string
        id:
          description: The ID of the billable item in Measure
          type: string
        name:
          description: The name of the billable item
          type: string
        standard:
          description: >-
            Whether this is a standard billable item in Measure or a custom
            billable item
          type: boolean
        total_units:
          format: double
          type: number
        type:
          description: >-
            The type of the billable item which can be one of CUSTOM_USAGE or
            CUSTOM_OBJ, based on usage-based item or object-based item
          type: string
        updated_at:
          description: The date the billable item was last updated
          format: date-time
          type: string
      type: object
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````