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

# Create a credit grant

> Create a credit grant



## OpenAPI

````yaml openapi-billing.json POST /v1/credit_grants
openapi: 3.1.0
info:
  title: Yorlet Billing API
  description: APIs for managing invoices, coupons, credit grants, and subscription items.
  version: 1.0.0
servers:
  - url: https://api.yorlet.com
    description: Production
  - url: https://api.yorlet.io
    description: Sandbox
security: []
paths:
  /v1/credit_grants:
    post:
      tags:
        - Credit Grants
      summary: Create a credit grant
      description: Create a credit grant
      operationId: credit_grants_create
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                amount:
                  type: integer
                  description: >-
                    The amount to be charged, represented as a whole integer if
                    possible.
                applicability_config:
                  type: object
                  properties:
                    limits:
                      type: object
                      properties:
                        max_credit_per_invoice_item:
                          type: integer
                          minimum: 1
                          description: The maximum amount of credit per invoice item.
                      description: The limits that apply to the credit grant.
                    scope:
                      type: object
                      properties:
                        application:
                          type: string
                          description: >-
                            The application ID that must match the invoice
                            application ID.
                        invoice_item_type:
                          type: string
                          enum:
                            - rent
                          description: >-
                            The type of invoice item that the credit grant can
                            be applied to.
                      description: The scope that the credit grant can be applied to.
                  description: >-
                    Configuration that controls when and how the credit grant
                    can be applied.
                currency:
                  type: string
                  description: >-
                    Three-letter ISO currency code, in lowercase. Must be a
                    supported currency.
                customer:
                  type: string
                  description: The ID of the customer the credit grant is for.
                metadata:
                  type:
                    - object
                    - 'null'
                  additionalProperties:
                    type: string
                  description: >-
                    Set of key-value pairs that you can attach to an object.
                    This can be useful for storing additional information about
                    the object in a structured format.
                name:
                  type: string
                  description: >-
                    The name of the credit grant. This will be displayed to the
                    customer.
              required:
                - amount
                - currency
                - customer
                - name
      responses:
        '200':
          description: Create a credit grant
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Unique identifier for the object.
                  created:
                    type: number
                    description: >-
                      Time at which the object was created. Measured in seconds
                      since the Unix epoch.
                  account:
                    type: string
                    description: >-
                      The account that the object belongs to. Only returned if
                      the request is made with a valid Yorlet-Context header.
                  deleted:
                    type: boolean
                    default: false
                    description: Only returned if the object has been deleted.
                  object:
                    type: string
                    enum:
                      - credit_grant
                  amount:
                    type: integer
                    description: The total amount of the credit grant.
                  amount_remaining:
                    type: integer
                    description: >-
                      The remaining amount of the credit grant that has not yet
                      been used.
                  amount_used:
                    type: integer
                    description: The amount of the credit grant that has been used.
                  applicability_config:
                    type:
                      - object
                      - 'null'
                    properties:
                      limits:
                        type: object
                        properties:
                          max_credit_per_invoice_item:
                            type: integer
                            minimum: 1
                            description: The maximum amount of credit per invoice item.
                        description: The limits that apply to the credit grant.
                      scope:
                        type: object
                        properties:
                          application:
                            type: string
                            description: >-
                              The application ID that must match the invoice
                              application ID.
                          invoice_item_type:
                            type: string
                            enum:
                              - rent
                            description: >-
                              The type of invoice item that the credit grant can
                              be applied to.
                        description: The scope that the credit grant can be applied to.
                    description: >-
                      Configuration that controls when and how the credit grant
                      can be applied.
                  currency:
                    type: string
                    enum:
                      - gbp
                      - usd
                      - eur
                      - sek
                    description: >-
                      Three-letter ISO currency code, in lowercase. Must be a
                      supported currency.
                    example: gbp
                  customer:
                    anyOf:
                      - type: string
                      - type: object
                        additionalProperties: {}
                    description: The ID of the customer the credit grant is for.
                  metadata:
                    type:
                      - object
                      - 'null'
                    additionalProperties:
                      type: string
                    description: >-
                      Set of key-value pairs that you can attach to an object.
                      This can be useful for storing additional information
                      about the object in a structured format.
                  name:
                    type:
                      - string
                      - 'null'
                    description: >-
                      The name of the credit grant. This will be displayed to
                      the customer.
                  status:
                    type: string
                    enum:
                      - active
                      - voided
                    description: The status of the credit grant.
                  voided_at:
                    type:
                      - integer
                      - 'null'
                    description: The date and time the credit grant was voided.
                required:
                  - id
                  - created
                  - object
                  - amount
                  - amount_remaining
                  - amount_used
                  - applicability_config
                  - currency
                  - customer
                  - name
                  - status
                  - voided_at
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: API Key authentication. Use "Bearer YOUR_API_KEY".

````