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

# Purchase credits

> Purchase a number of credits. This action will generate an invoice and charge the customer.



## OpenAPI

````yaml post /v1/customers/{id}/credits/{productId}/purchase
openapi: 3.1.0
info:
  title: Hyperline API
  version: 0.0.0
servers:
  - url: https://api.hyperline.co
  - url: https://sandbox.api.hyperline.co
security: []
paths:
  /v1/customers/{id}/credits/{productId}/purchase:
    post:
      tags:
        - Customers > Credits
      summary: Purchase credits
      description: >-
        Purchase a number of credits. This action will generate an invoice and
        charge the customer.
      operationId: purchaseCustomerCredits
      parameters:
        - schema:
            type: string
          required: true
          name: id
          in: path
        - schema:
            type: string
          required: true
          name: productId
          in: path
      requestBody:
        description: Credit purchase payload
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCreditPurchase'
      responses:
        '201':
          description: Invoice ID and balance after purchase
          content:
            application/json:
              schema:
                type: object
                properties:
                  invoice_id:
                    type: string
                  new_credit_balance:
                    type: number
                required:
                  - invoice_id
                  - new_credit_balance
      security:
        - bearer: []
components:
  schemas:
    CreateCreditPurchase:
      type: object
      properties:
        credit_count:
          type: number
          description: >-
            Value indicating a number of credits to add. If `price_id` is
            defined, this value must correspond to a full credit pack for the
            price.
          example: 32
        amount_excluding_tax:
          type: number
          description: >-
            Custom amount for the added credits. Either `amount_excluding_tax`
            or `price_id` must be defined. Expressed in currency's smallest
            unit.
        price_id:
          type: string
          description: >-
            Price ID used to add credits. The price must be of type `bundle`.
            Either `amount_excluding_tax` or `price_id` must be defined.
        expires_at:
          type: string
          format: date-time
          description: >-
            Expiration date for credits linked to this transaction. UTC date
            time string in the [ISO
            8601](https://en.wikipedia.org/wiki/ISO_8601) format.
          example: '2024-12-20T16:04:11Z'
      required:
        - credit_count
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````