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

# Preview a credit note

> Preview a credit note for an invoice without creating it. <h3>OAuth</h3>Required scopes: <code>invoices</code>



## OpenAPI

````yaml /assets/openapi.json post /billing/credit_notes/v1/preview
openapi: 3.0.2
info:
  title: Spacebring
  version: 1.0.0
  termsOfService: https://www.spacebring.com/terms
servers:
  - url: https://api.spacebring.com
security: []
paths:
  /billing/credit_notes/v1/preview:
    post:
      tags:
        - Billing
      summary: Preview a credit note
      description: >-
        Preview a credit note for an invoice without creating it.
        <h3>OAuth</h3>Required scopes: <code>invoices</code>
      operationId: previewCreditNote
      parameters:
        - in: header
          name: spacebring-network-id
          schema:
            type: string
            format: uuid
          required: false
          description: >-
            The id of the network. Required when using bearer token
            authentication
      requestBody:
        $ref: '#/components/requestBodies/previewCreditNote'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  creditNote:
                    $ref: '#/components/schemas/creditNote'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
        '403':
          description: Forbidden - User lacks permissions
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
        '404':
          description: Not Found - Invoice or invoice item not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
      security:
        - BasicAuth: []
        - OAuth2:
            - invoices
components:
  requestBodies:
    previewCreditNote:
      content:
        application/json:
          schema:
            type: object
            properties:
              creditNote:
                type: object
                properties:
                  creditAmount:
                    description: Amount to credit to the customer balance in major units.
                    type: number
                    minimum: 0
                    exclusiveMinimum: true
                  effectiveDate:
                    description: Effective date for the credit note.
                    type: string
                    format: date-time
                  internalNote:
                    description: Internal memo.
                    type: string
                  invoiceRef:
                    type: string
                    format: uuid
                    description: ID of the invoice to credit.
                  lines:
                    minItems: 1
                    type: array
                    items:
                      type: object
                      properties:
                        amount:
                          description: >-
                            Share of the invoice item pre-discount total to
                            credit in major units; discounts are prorated and
                            exclusive tax is added on top.
                          type: number
                          minimum: 0
                          exclusiveMinimum: true
                        invoiceItemRef:
                          type: string
                          format: uuid
                          description: ID of the invoice item to credit.
                        quantity:
                          description: Quantity to credit.
                          type: integer
                          minimum: 0
                          exclusiveMinimum: true
                          maximum: 9007199254740991
                      required:
                        - invoiceItemRef
                      additionalProperties: false
                    description: Line items to credit.
                  outOfBandAmount:
                    description: Amount refunded outside the platform in major units.
                    type: number
                    minimum: 0
                    exclusiveMinimum: true
                  refunds:
                    description: Refunds to issue alongside this credit note.
                    type: array
                    items:
                      type: object
                      properties:
                        amount:
                          description: Refund amount in major units.
                          type: number
                          minimum: 0
                          exclusiveMinimum: true
                        id:
                          description: ID of the payment to refund.
                          type: string
                          format: uuid
                        transactionRef:
                          description: ID of the transaction to refund.
                          type: string
                          format: uuid
                      additionalProperties: false
                required:
                  - invoiceRef
                  - lines
                description: Credit note to preview.
            required:
              - creditNote
      required: true
  schemas:
    creditNote:
      type: object
      additionalProperties: false
      properties:
        baseAmounts:
          type: object
          properties:
            currencyCode:
              type: string
              description: ISO currency code.
            grossAmount:
              type: number
              deprecated: true
              description: Deprecated.
            postPaymentAmount:
              type: number
              description: Post-payment credit amount in major units.
            prePaymentAmount:
              type: number
              description: Pre-payment credit amount in major units.
            subtotalAmount:
              type: number
              description: Subtotal in major units.
            subtotalAmountExcludingTax:
              type: number
              description: Subtotal excluding tax in major units.
            taxes:
              type: array
              items:
                type: object
                properties:
                  amount:
                    type: number
                    description: Tax amount in major units.
                  inclusive:
                    type: boolean
                    description: Whether tax is included in the price.
                  rate:
                    type: number
                    description: Tax rate as a decimal.
                  taxableAmount:
                    type: number
                    description: Amount subject to tax in major units.
                required:
                  - amount
                  - inclusive
                  - rate
                  - taxableAmount
                additionalProperties: false
              description: Tax breakdown.
            totalAmount:
              type: number
              description: Total in major units.
            totalExcludingTaxAmount:
              type: number
              description: Total excluding tax in major units.
          required:
            - currencyCode
            - grossAmount
            - postPaymentAmount
            - prePaymentAmount
            - subtotalAmount
            - subtotalAmountExcludingTax
            - taxes
            - totalAmount
            - totalExcludingTaxAmount
          additionalProperties: false
          description: Amounts in the base currency.
        createDate:
          type: string
          format: date-time
          description: ISO timestamp of when the credit note was created.
        creditAmount:
          description: Amount credited to customer balance in major units.
          type: number
        currencyCode:
          type: string
          description: ISO currency code (from base or alt currency).
        customer:
          type: object
          properties:
            id:
              type: string
              format: uuid
              description: ID of the company or membership.
            logo:
              description: Company logo.
              type: object
              properties:
                key:
                  type: string
                url:
                  type: string
              required:
                - key
                - url
              additionalProperties: false
            title:
              description: Company name.
              type: string
            type:
              type: string
              enum:
                - company
                - user
              description: Whether the customer is a company or a user.
            user:
              description: User details for membership customers.
              type: object
              properties:
                about:
                  description: User bio.
                  nullable: true
                  type: string
                email:
                  description: User email address.
                  nullable: true
                  type: string
                id:
                  type: string
                  format: uuid
                  description: User ID.
                name:
                  description: First name.
                  nullable: true
                  type: string
                phoneNumber:
                  description: Phone number.
                  nullable: true
                  type: string
                photoUrl:
                  description: Profile photo URL.
                  nullable: true
                  type: string
                surname:
                  description: Last name.
                  nullable: true
                  type: string
              required:
                - id
              additionalProperties: false
          required:
            - id
            - type
          additionalProperties: false
          description: Customer associated with this credit note.
        effectiveDate:
          description: Effective date in YYYY-MM-DD format.
          type: string
        grossAmount:
          type: number
          deprecated: true
          description: Deprecated.
        id:
          type: string
          format: uuid
          description: Unique identifier of the credit note.
        internalNote:
          description: Internal memo (visible to admins only).
          type: string
        invoiceRef:
          type: string
          format: uuid
          description: ID of the invoice being credited.
        lines:
          type: array
          items:
            type: object
            properties:
              baseAmounts:
                type: object
                properties:
                  currencyCode:
                    type: string
                    description: ISO currency code.
                  discountedAmount:
                    type: number
                    description: Discount deduction in major units.
                  tax:
                    description: Tax details.
                    type: object
                    properties:
                      amount:
                        type: number
                        description: Tax amount in major units.
                      inclusive:
                        type: boolean
                        description: Whether tax is included in the price.
                      rate:
                        type: number
                        description: Tax rate as a decimal.
                      taxableAmount:
                        type: number
                        description: Amount subject to tax in major units.
                    required:
                      - amount
                      - inclusive
                      - rate
                      - taxableAmount
                    additionalProperties: false
                  totalAmount:
                    type: number
                    description: Total in major units.
                  totalExcludingTaxAmount:
                    type: number
                    description: Total excluding tax in major units.
                  unitAmount:
                    type: number
                    description: Unit price in major units.
                  unitExcludingTaxAmount:
                    type: number
                    description: Unit price excluding tax in major units.
                required:
                  - currencyCode
                  - discountedAmount
                  - totalAmount
                  - totalExcludingTaxAmount
                additionalProperties: false
                description: Amounts in the base currency.
              createDate:
                type: string
                format: date-time
                description: ISO timestamp of line item creation.
              currencyCode:
                type: string
                description: ISO currency code.
              discountedAmount:
                type: number
                description: Discount deduction in major units.
              discounts:
                description: Applied discounts.
                type: array
                items:
                  type: object
                  properties:
                    coupon:
                      type: object
                      properties:
                        amountOff:
                          description: Fixed discount amount in major units.
                          type: number
                        currencyCode:
                          description: Currency code for amountOff.
                          type: string
                        duration:
                          description: Discount duration type.
                          type: string
                        durationInMonths:
                          description: Number of months the discount applies.
                          type: number
                        id:
                          description: Coupon ID.
                          type: string
                          format: uuid
                        percentOff:
                          description: Percentage discount.
                          type: number
                        type:
                          description: Coupon type.
                          type: string
                      additionalProperties: false
                      description: Coupon applied.
                    promocode:
                      description: Promocode applied.
                      type: object
                      properties:
                        code:
                          type: string
                        expiration:
                          type: string
                          format: date-time
                        id:
                          type: string
                          format: uuid
                        limitByFirstPurchase:
                          type: boolean
                      required:
                        - code
                        - id
                      additionalProperties: false
                    subscriptionId:
                      description: Associated subscription ID.
                      type: string
                      format: uuid
                  required:
                    - coupon
                  additionalProperties: false
              id:
                type: string
                format: uuid
                description: Unique identifier of the line item.
              invoiceItemRef:
                type: string
                format: uuid
                description: ID of the original invoice item.
              invoiceRef:
                type: string
                format: uuid
                description: ID of the invoice.
              locationRef:
                type: string
                format: uuid
                description: ID of the organization (location).
              networkRef:
                type: string
                format: uuid
                description: ID of the network.
              quantity:
                description: Quantity refunded.
                type: number
              tax:
                description: Tax details.
                type: object
                properties:
                  amount:
                    type: number
                    description: Tax amount in major units.
                  inclusive:
                    type: boolean
                    description: Whether tax is included in the price.
                  rate:
                    type: number
                    description: Tax rate as a decimal.
                  taxableAmount:
                    type: number
                    description: Amount subject to tax in major units.
                required:
                  - amount
                  - inclusive
                  - rate
                  - taxableAmount
                additionalProperties: false
              totalAmount:
                type: number
                description: Total in major units.
              totalExcludingTaxAmount:
                type: number
                description: Total excluding tax in major units.
              unitAmount:
                type: number
                description: Unit price in major units.
              unitExcludingTaxAmount:
                type: number
                description: Unit price excluding tax in major units.
              updateDate:
                type: string
                format: date-time
                description: ISO timestamp of last update.
            required:
              - baseAmounts
              - createDate
              - currencyCode
              - discountedAmount
              - id
              - invoiceItemRef
              - invoiceRef
              - locationRef
              - networkRef
              - totalAmount
              - totalExcludingTaxAmount
              - updateDate
            additionalProperties: false
          description: Credit note line items.
        locationRef:
          type: string
          format: uuid
          description: ID of the organization (location).
        networkRef:
          type: string
          format: uuid
          description: ID of the network.
        number:
          description: Credit note number.
          type: number
        outOfBandAmount:
          description: Out-of-band refund amount in major units.
          type: number
        pdfUrl:
          type: string
          description: URL to download the credit note PDF.
        postPaymentAmount:
          type: number
          description: Post-payment credit amount in major units.
        prePaymentAmount:
          type: number
          description: Pre-payment credit amount in major units.
        reason:
          type: string
          enum:
            - duplicate
            - orderChange
            - productUnsatisfactory
            - fraudulent
            - other
          description: Reason for the credit note.
        refunds:
          description: Refunds associated with this credit note.
          type: array
          items:
            type: object
            properties:
              amount:
                type: number
                description: Refund amount in major units.
              currencyCode:
                type: string
                description: ISO currency code.
              id:
                type: string
                format: uuid
                description: Unique identifier of the refund.
              method:
                description: Refund payment method.
                type: object
                properties:
                  label:
                    description: Payment method label.
                    type: string
                  type:
                    type: string
                    enum:
                      - external
                      - paymentGateway
                    description: Payment method type.
                required:
                  - type
                additionalProperties: false
              transactionRef:
                type: string
                format: uuid
                description: ID of the transaction being refunded.
            required:
              - amount
              - currencyCode
              - id
              - transactionRef
            additionalProperties: false
        status:
          type: string
          enum:
            - issued
            - voided
          description: Credit note status.
        subtotalAmount:
          type: number
          description: Subtotal in major units.
        subtotalAmountExcludingTax:
          type: number
          description: Subtotal excluding tax in major units.
        taxes:
          type: array
          items:
            type: object
            properties:
              amount:
                type: number
                description: Tax amount in major units.
              inclusive:
                type: boolean
                description: Whether tax is included in the price.
              rate:
                type: number
                description: Tax rate as a decimal.
              taxableAmount:
                type: number
                description: Amount subject to tax in major units.
            required:
              - amount
              - inclusive
              - rate
              - taxableAmount
            additionalProperties: false
          description: Tax breakdown.
        title:
          type: string
          description: Credit note title.
        totalAmount:
          type: number
          description: Total in major units.
        totalExcludingTaxAmount:
          type: number
          description: Total excluding tax in major units.
        type:
          type: string
          enum:
            - prePayment
            - postPayment
            - mixed
          description: Credit note type.
        updateDate:
          type: string
          format: date-time
          description: ISO timestamp of last update.
        voidDate:
          description: ISO timestamp of when the credit note was voided.
          type: string
          format: date-time
      required:
        - baseAmounts
        - createDate
        - currencyCode
        - customer
        - grossAmount
        - id
        - invoiceRef
        - lines
        - locationRef
        - networkRef
        - pdfUrl
        - postPaymentAmount
        - prePaymentAmount
        - reason
        - status
        - subtotalAmount
        - subtotalAmountExcludingTax
        - taxes
        - title
        - totalAmount
        - totalExcludingTaxAmount
        - type
        - updateDate
    responseError:
      type: object
      properties:
        message:
          type: string
        type:
          type: string
  securitySchemes:
    BasicAuth:
      type: http
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/api-reference/authentication#basic-authentication)
        for how to authorize your requests
      scheme: basic
    OAuth2:
      type: oauth2
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/api-reference/authentication#oauth2)
        for how to authorize your requests
      flows:
        authorizationCode:
          authorizationUrl: https://api.spacebring.com/oauth2/authorize
          tokenUrl: https://api.spacebring.com/oauth2/token
          refreshUrl: https://api.spacebring.com/oauth2/token
          scopes:
            benefits.readonly: Read benefits and applications
            benefits: Read and write benefits and applications
            community.readonly: Read community companies and memberships
            community: Read and write community companies and memberships
            events.readonly: Read events and tickets
            events: Read and write events and tickets
            feed.readonly: Read feed posts
            feed: Read and write feed posts
            invoices.readonly: Read contracts, credit notes, discounts and invoices
            invoices: Read and write contract, credit notes, discounts and invoices
            locations.readonly: Read locations
            locations: Read and write locations
            plans.readonly: Read plans
            plans: Read and write plans
            resources.readonly: Read resources and bookings
            resources: Read and write resources and bookings
            subscriptions.readonly: Read subscriptions
            subscriptions: Read and write subscriptions
            shop.readonly: Read products and orders
            shop: Read and write products and orders
            support.readonly: Read support tickets
            support: Read and write support tickets
            transactions.readonly: Read transactions
            transactions: Read and write transactions
            visitors.readonly: Read visitors
            visitors: Read and write visitors

````