> ## 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 a credit allocation

> Retrieve a single credit allocation by ID, including its full transaction history.



## OpenAPI

````yaml GET /api/v1/credit_systems/v2/credit-allocations/{id}
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/credit_systems/v2/credit-allocations/{id}:
    get:
      tags:
        - Wallets
      summary: Get a single credit allocation
      description: >
        Retrieves a single credit allocation by ID, including its full
        transaction history.


        Useful when you already know the allocation ID (for example, to render a
        detail view of one specific top-up or subscription grant) and want the
        latest `consumed` amount alongside every individual debit/credit
        transaction recorded against it.
      operationId: getCreditAllocation
      parameters:
        - name: id
          in: path
          required: true
          description: The unique credit allocation identifier
          schema:
            type: string
            format: uuid
          example: a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12
      responses:
        '200':
          description: Credit allocation fetched successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditAllocationResponse'
              examples:
                credit_allocation:
                  summary: Credit Allocation Response
                  value:
                    statusCode: 200
                    message: Credit transactions fetched successfully
                    meta: {}
                    data:
                      id: a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12
                      amount: 100
                      consumed: 35
                      allocation_type: subscription
                      invoice_id: 0d9e5a0e-7de4-48c6-b01a-b1759394578b
                      order_id: null
                      order_number: null
                      valid_until: '2026-04-12T16:55:21.847Z'
                      created_at: '2026-03-12T16:55:22.014Z'
                      transactions:
                        - id: 2e8c1a4f-9b73-4f1a-bd64-58a9d7c83ef0
                          amount: 10
                          quantity: 2
                          event_name: image_generated
                          usage_event_id: ue_01HXYZ123ABC
                          created_at: '2026-03-15T09:22:03.114Z'
                        - id: 9af2e7b1-8c3d-4d52-9b1a-23c7e4f60d21
                          amount: 25
                          quantity: 5
                          event_name: image_generated
                          usage_event_id: ue_01HXYZ456DEF
                          created_at: '2026-03-18T14:08:47.802Z'
                    errors: {}
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Credit allocation not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: >
            from metrifox_sdk import MetrifoxClient


            client = MetrifoxClient(api_key="your_api_key")


            # Get a single credit allocation with transactions

            allocation =
            client.wallets.get_credit_allocation("a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12")

            data = allocation['data']

            print(f"{data['amount']} granted, {data['consumed']} consumed")

            for txn in data['transactions']:
                print(f"  {txn['amount']} via {txn.get('event_name')} at {txn['created_at']}")
        - lang: javascript
          label: Javascript SDK
          source: >
            import { init } from "metrifox-js";


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


            const allocation = await metrifoxClient.wallets.getCreditAllocation(
              "a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12"
            );


            console.log(`${allocation.data.amount} granted,
            ${allocation.data.consumed} consumed`);

            allocation.data.transactions.forEach((t) => {
              console.log(`  ${t.amount} via ${t.event_name} at ${t.created_at}`);
            });
        - lang: ruby
          label: Ruby SDK
          source: >
            require 'metrifox-sdk'


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


            # Get a single credit allocation with transactions

            response =
            METRIFOX_SDK.wallets.get_credit_allocation("a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12")

            data = response["data"]

            puts "#{data['amount']} granted, #{data['consumed']} consumed"

            data["transactions"].each do |txn|
              puts "  #{txn['amount']} via #{txn['event_name']} at #{txn['created_at']}"
            end
components:
  schemas:
    CreditAllocationResponse:
      type: object
      properties:
        statusCode:
          type: integer
          example: 200
        message:
          type: string
          example: Credit transactions fetched successfully
        meta:
          type: object
          additionalProperties: true
        data:
          description: >
            A single credit allocation together with its full transaction
            history. Returned by

            `GET /api/v1/credit_systems/v2/credit-allocations/{id}`. The
            allocation listing endpoint

            does not embed transactions — fetch them via the wallet transactions
            endpoints instead.
          allOf:
            - $ref: '#/components/schemas/CreditAllocationEntity'
            - type: object
              properties:
                transactions:
                  type: array
                  description: >-
                    Individual debit/credit transactions that have drawn against
                    this allocation
                  items:
                    $ref: '#/components/schemas/CreditTransactionEntity'
        errors:
          type: object
          additionalProperties: true
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: Error message
        errors:
          type: object
          additionalProperties: true
          description: Detailed error information
    CreditAllocationEntity:
      type: object
      properties:
        id:
          type: string
          description: Unique allocation identifier
        amount:
          type: number
          description: Total amount of credits granted by this allocation
        consumed:
          type: number
          description: Amount of this allocation that has been used so far
        allocation_type:
          type: string
          description: >-
            Source of the allocation (e.g. subscription grant, one-time top-up,
            manual adjustment)
        invoice_id:
          type: string
          nullable: true
          description: ID of the invoice that generated this allocation, if any
        order_id:
          type: string
          nullable: true
          description: ID of the order that generated this allocation, if any
        order_number:
          type: string
          nullable: true
          description: Human-readable order number associated with this allocation
        valid_until:
          type: string
          format: date-time
          nullable: true
          description: When this allocation expires (null if it never expires)
        created_at:
          type: string
          format: date-time
          description: When the allocation was created
    CreditTransactionEntity:
      type: object
      properties:
        id:
          type: string
          description: Unique transaction identifier
        amount:
          type: number
          description: Amount of credits debited or credited in this transaction
        quantity:
          type: number
          nullable: true
          description: Quantity of the metered event that drove this transaction
        event_name:
          type: string
          nullable: true
          description: Name of the metered event that produced this transaction
        usage_event_id:
          type: string
          nullable: true
          description: ID of the usage event that produced this transaction
        created_at:
          type: string
          format: date-time
          description: When the transaction was recorded
  securitySchemes:
    api_key:
      type: apiKey
      name: x-api-key
      in: header

````