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

# Create a credit

> Create a credit

Creates a credit.

<CodeGroup>
  ```py Python theme={null}
  lotus.create_credit(
      customer_id='cust_0569173ee6654369',
      amount=120.00,
      currency_code='USD',
  )

  lotus.create_credit(
      customer_id='cust_0569173ee6654369',
      amount=1000.00,
      currency_code='USD',
      description="Prepurchased credit",
      expires_at="2024-01-01T00:00:00Z",
      amount_paid=500.00,
      amount_paid_currency_code='USD',
  )
  ```

  ```ts Typescript theme={null}
  await lotus.createCredit({
    customer_id: "cust_0569173ee6654369",
    amount: 120.0,
    currency_code: "USD",
  });

  await lotus.createCredit({
    customer_id: "cust_0569173ee6654369",
    amount: 1000.0,
    currency_code: "USD",
    description: "Prepurchased credit",
    expires_at: "2024-01-01T00:00:00Z",
    amount_paid: 500.0,
    amount_paid_currency_code: "USD",
  });
  ```
</CodeGroup>


## OpenAPI

````yaml POST /api/credits/
openapi: 3.0.3
info:
  title: Lotus API
  version: 0.9.3
  description: >-
    Lotus is an open-core pricing and billing engine. We enable API companies to
    automate and optimize their custom usage-based pricing for any metric.
servers: []
security: []
paths:
  /api/credits/:
    post:
      tags:
        - api
      operationId: api_credits_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CustomerBalanceAdjustmentCreateRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/CustomerBalanceAdjustmentCreateRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CustomerBalanceAdjustmentCreateRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerBalanceAdjustment'
          description: ''
      security:
        - knoxTokenAuth: []
        - OrganizationApiKeyAuth: []
          TokenAuth: []
components:
  schemas:
    CustomerBalanceAdjustmentCreateRequest:
      type: object
      properties:
        customer_id:
          type: string
          nullable: true
          minLength: 1
          description: >-
            The id provided when creating the customer, we suggest matching with
            your internal customer id in your backend
        amount:
          type: number
          format: double
          maximum: 10000000000
          minimum: -10000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          writeOnly: true
        currency_code:
          type: string
          minLength: 1
          writeOnly: true
        description:
          type: string
          writeOnly: true
          nullable: true
        effective_at:
          type: string
          format: date-time
          writeOnly: true
        expires_at:
          type: string
          format: date-time
          writeOnly: true
          nullable: true
        amount_paid:
          type: number
          format: double
          maximum: 10000000000
          minimum: 0
          exclusiveMaximum: true
        amount_paid_currency_code:
          type: string
          minLength: 1
          writeOnly: true
      required:
        - amount
        - currency_code
        - customer_id
    CustomerBalanceAdjustment:
      type: object
      properties:
        credit_id:
          type: string
        customer:
          $ref: '#/components/schemas/LightweightCustomer'
        amount:
          type: number
          format: double
          maximum: 10000000000
          minimum: 0
          exclusiveMaximum: true
        amount_remaining:
          type: number
          format: double
          maximum: 10000000000
          minimum: 0
          exclusiveMaximum: true
          readOnly: true
        currency:
          $ref: '#/components/schemas/PricingUnit'
        description:
          type: string
          nullable: true
          readOnly: true
        effective_at:
          type: string
          format: date-time
          readOnly: true
        expires_at:
          type: string
          format: date-time
          readOnly: true
          nullable: true
        status:
          enum:
            - active
            - inactive
          type: string
          description: |-
            * `active` - Active
            * `inactive` - Inactive
          readOnly: true
        amount_paid:
          type: number
          format: double
          maximum: 10000000000
          minimum: -10000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          readOnly: true
        amount_paid_currency:
          allOf:
            - $ref: '#/components/schemas/PricingUnit'
          nullable: true
        drawdowns:
          type: array
          items:
            $ref: '#/components/schemas/CreditDrawdown'
          readOnly: true
      required:
        - amount
        - amount_paid
        - amount_paid_currency
        - amount_remaining
        - credit_id
        - currency
        - customer
        - description
        - drawdowns
        - effective_at
        - expires_at
        - status
    LightweightCustomer:
      type: object
      properties:
        customer_name:
          type: string
          readOnly: true
          nullable: true
          description: The display name of the customer
        email:
          type: string
          format: email
          readOnly: true
          nullable: true
          description: >-
            The primary email address of the customer, must be the same as the
            email address used to create the customer in the payment provider
        customer_id:
          type: string
          readOnly: true
          nullable: true
          description: >-
            The id provided when creating the customer, we suggest matching with
            your internal customer id in your backend
      required:
        - customer_id
        - customer_name
        - email
    PricingUnit:
      type: object
      properties:
        code:
          type: string
          maxLength: 10
        name:
          type: string
          maxLength: 100
        symbol:
          type: string
          maxLength: 10
      required:
        - code
        - name
        - symbol
    CreditDrawdown:
      type: object
      properties:
        credit_id:
          type: string
        amount:
          type: number
          format: double
          maximum: 0
          minimum: -10000000000
          exclusiveMinimum: true
        description:
          type: string
          nullable: true
        applied_at:
          type: string
          format: date-time
      required:
        - amount
        - applied_at
        - credit_id
  securitySchemes:
    knoxTokenAuth:
      type: apiKey
      in: header
      name: Authorization
      description: Token-based authentication with required prefix "Token"
    OrganizationApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY

````