> ## 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.

# Preview a credit note



## OpenAPI

````yaml openapi-billing.json POST /v1/credit_notes/preview
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_notes/preview:
    post:
      tags:
        - Credit Notes
      summary: Preview a credit note
      operationId: credit_notes_preview
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                invoice:
                  type: string
                  pattern: ^[a-zA-Z0-9_]+$
                  description: The ID of the invoice the credit note is for.
                credit_amount:
                  type: integer
                  description: >-
                    The integer amount in cents representing the amount to
                    credit the customer’s balance, which will be automatically
                    applied to their next invoice.
                memo:
                  type:
                    - string
                    - 'null'
                  description: The credit note’s memo appears on the credit note PDF.
                metadata:
                  type:
                    - object
                    - 'null'
                  additionalProperties:
                    type: string
                  description: The metadata for the credit note.
                new_invoice_data:
                  type: object
                  properties:
                    account:
                      type: string
                      pattern: ^[a-zA-Z0-9_]+$
                      description: The ID of the account the new invoice is for.
                    application:
                      type: string
                      pattern: ^[a-zA-Z0-9_]+$
                      description: The ID of the application the new invoice is for.
                    period_end:
                      type:
                        - integer
                        - 'null'
                      description: The end date of the period for the new invoice.
                    period_start:
                      type: integer
                      description: The start date of the period for the new invoice.
                  required:
                    - account
                    - application
                    - period_end
                    - period_start
                  description: The data for the new invoice.
                out_of_band_amount:
                  type: integer
                  description: The credit note amount that was paid out of band.
                reason:
                  type: string
                  enum:
                    - duplicate
                    - fraudulent
                    - order_change
                    - product_unsatisfactory
                    - other
                  description: The reason for issuing the credit note.
                lines:
                  type: array
                  items:
                    type: object
                    properties:
                      amount:
                        type: integer
                        description: The amount of the credit note line item.
                      invoice_item:
                        type: string
                        pattern: ^[a-zA-Z0-9_]+$
                        description: >-
                          The ID of the invoice item the credit note line item
                          is for.
                      type:
                        type: string
                        enum:
                          - invoice_item
                        description: The type of the credit note line item.
                    required:
                      - amount
                      - invoice_item
                      - type
                  minItems: 1
                  maxItems: 10
                  description: A list of up to 10 line items to issue credit for.
              required:
                - invoice
                - lines
      responses:
        '200':
          description: Returns a credit note preview object if successful.
          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_note
                  amount:
                    type: number
                    description: The amount of the credit note.
                  credit_amount:
                    type: number
                    default: 0
                    description: >-
                      The integer amount in cents representing the amount to
                      credit the customer’s balance, which will be automatically
                      applied to their next invoice.
                  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:
                    type:
                      - string
                      - 'null'
                    description: The description of the credit note.
                  discount_amount:
                    type: number
                    description: The amount of the discount for the credit note.
                  invoice:
                    anyOf:
                      - type: string
                      - type: object
                        additionalProperties: {}
                  lines:
                    type: object
                    properties:
                      count:
                        type: number
                        description: Total number of items in the list.
                        example: 1
                      has_more:
                        type: boolean
                        description: Whether more items are available.
                        example: false
                      object:
                        type: string
                        enum:
                          - list
                      data:
                        type: array
                        items:
                          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_note_line_item
                            amount:
                              type: number
                              description: The amount of the credit note line item.
                            amount_excluding_tax:
                              type: number
                              description: >-
                                The amount of the credit note line item
                                excluding tax.
                            credit_note:
                              type:
                                - string
                                - 'null'
                              pattern: ^[a-zA-Z0-9_]+$
                              description: >-
                                The ID of the credit note the credit note line
                                item is for. May be null when returned from the
                                preview endpoint, where the parent credit note
                                has not yet been created.
                            currency:
                              type: string
                              enum:
                                - gbp
                                - usd
                                - eur
                                - sek
                              description: >-
                                Three-letter ISO currency code, in lowercase.
                                Must be a supported currency.
                              example: gbp
                            description:
                              type: string
                              description: The description of the credit note line item.
                            invoice_item:
                              type: string
                              pattern: ^[a-zA-Z0-9_]+$
                              description: >-
                                The ID of the invoice item the credit note line
                                item is for.
                            pretax_credit_amounts:
                              type: array
                              items:
                                type: object
                                properties:
                                  amount:
                                    type: number
                                    description: >-
                                      The amount of the pretax credit for the
                                      credit note line item.
                                  credit_grant:
                                    type: string
                                    pattern: ^[a-zA-Z0-9_]+$
                                    description: >-
                                      The ID of the credit grant the pretax
                                      credit is for.
                                  display_name:
                                    type: string
                                    description: >-
                                      The display name of the pretax credit for
                                      the credit note line item.
                                  invoice_item:
                                    type: string
                                    pattern: ^[a-zA-Z0-9_]+$
                                    description: >-
                                      The ID of the invoice item the pretax
                                      credit is for.
                                  type:
                                    type: string
                                    enum:
                                      - credit_grant
                                    description: >-
                                      The type of the pretax credit for the
                                      credit note line item.
                                required:
                                  - amount
                                  - credit_grant
                                  - display_name
                                  - invoice_item
                                  - type
                              description: >-
                                The pretax credit amounts for the credit note
                                line item.
                            tax_amounts:
                              type: array
                              items:
                                type: object
                                properties:
                                  amount:
                                    type: number
                                    description: >-
                                      The amount of the tax for the credit note
                                      line item.
                                  tax_rate:
                                    type: number
                                    description: >-
                                      The rate of the tax for the credit note
                                      line item.
                                  taxable_amount:
                                    type: number
                                    description: >-
                                      The taxable amount of the tax for the
                                      credit note line item.
                                required:
                                  - amount
                                  - tax_rate
                                  - taxable_amount
                              description: The tax amounts for the credit note line item.
                            type:
                              type: string
                              enum:
                                - invoice_item
                              description: The type of the credit note line item.
                          required:
                            - id
                            - created
                            - object
                            - amount
                            - amount_excluding_tax
                            - credit_note
                            - currency
                            - description
                            - invoice_item
                            - pretax_credit_amounts
                            - tax_amounts
                            - type
                    required:
                      - count
                      - has_more
                      - object
                      - data
                  memo:
                    type:
                      - string
                      - 'null'
                    description: The credit note’s memo appears on the credit note PDF.
                  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.
                  number:
                    type:
                      - string
                      - 'null'
                    description: The credit note number.
                  out_of_band_amount:
                    type: number
                    default: 0
                    description: The credit note amount that was paid out of band.
                  reason:
                    type: string
                    enum:
                      - duplicate
                      - fraudulent
                      - order_change
                      - product_unsatisfactory
                      - other
                    description: The reason for issuing the credit note.
                  subtotal:
                    type: number
                    default: 0
                    description: The credit note’s subtotal.
                  subtotal_excluding_tax:
                    type: number
                    default: 0
                    description: The credit note’s subtotal excluding tax.
                  status:
                    type: string
                    enum:
                      - issued
                      - void
                    description: The status of the credit note.
                  tax_amounts:
                    type: array
                    items:
                      type: object
                      properties:
                        amount:
                          type: number
                          default: 0
                          description: The amount of the tax for the credit note.
                        tax_rate:
                          type: number
                          default: 0
                          description: The rate of the tax for the credit note.
                        taxable_amount:
                          type: number
                          default: 0
                          description: The taxable amount of the tax for the credit note.
                    default: []
                    description: The tax amounts for the credit note.
                  tax:
                    type: number
                    default: 0
                    description: The credit note’s tax amount.
                  total:
                    type: number
                    default: 0
                    description: The credit note’s total amount.
                  total_excluding_tax:
                    type: number
                    default: 0
                    description: The credit note’s total amount excluding tax.
                  total_pretax_credit_amounts:
                    type: array
                    items:
                      type: object
                      properties:
                        amount:
                          type: number
                          default: 0
                          description: The amount of the pretax credit for the credit note.
                        credit_grant:
                          type: string
                          pattern: ^[a-zA-Z0-9_]+$
                          default: ''
                          description: The ID of the credit grant the pretax credit is for.
                        display_name:
                          type: string
                          default: ''
                          description: >-
                            The display name of the pretax credit for the credit
                            note.
                        invoice_item:
                          type: string
                          pattern: ^[a-zA-Z0-9_]+$
                          default: ''
                          description: The ID of the invoice item the pretax credit is for.
                        type:
                          type: string
                          enum:
                            - credit_grant
                          default: credit_grant
                          description: The type of the pretax credit for the credit note.
                    default: []
                    description: The pretax credit amounts for the credit note.
                  type:
                    type: string
                    enum:
                      - pre_payment
                      - post_payment
                    description: The type of the credit note.
                  voided_at:
                    type:
                      - number
                      - 'null'
                    description: The date and time the credit note was voided.
                required:
                  - id
                  - created
                  - object
                  - amount
                  - currency
                  - customer
                  - description
                  - discount_amount
                  - invoice
                  - memo
                  - number
                  - reason
                  - status
                  - type
                  - voided_at
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: API Key authentication. Use "Bearer YOUR_API_KEY".

````