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

# List invoice previews

> Lists the invoices a change would bill, before the change is made, in the order they would be issued. Send exactly one of these in the body:

- `contractId`: the invoices the contract will bill from the start of its draft amendment, once that amendment is agreed. Refused when the contract has no draft amendment or is deleted. If the draft amendment is a cancellation, the list is empty; send `cancellation` instead.
- `terms`: the invoices that terms would bill before they are saved, such as a new contract's. Refused when the terms cannot be billed, such as terms with no line items; the error says why.
- `cancellation`: the invoice that would still be billed if the contract were cancelled from `cancelAt`, for its last charges billed in arrears (`IN_ARREARS`). Empty when there are none.

Every invoice comes back on one page, so `hasMore` is always false. Needs a key holding `contracts:read` and `invoices:read`.



## OpenAPI

````yaml https://app.synthetic.ai/api/v1/openapi.json query /invoice-previews
openapi: 3.2.0
info:
  title: Synthetic API
  description: Read access to your Synthetic data.
  version: 0.1.0
servers:
  - url: https://app.synthetic.ai/api/v1
security: []
paths:
  /invoice-previews:
    query:
      tags:
        - Contracts
      summary: List invoice previews
      description: >-
        Lists the invoices a change would bill, before the change is made, in
        the order they would be issued. Send exactly one of these in the body:


        - `contractId`: the invoices the contract will bill from the start of
        its draft amendment, once that amendment is agreed. Refused when the
        contract has no draft amendment or is deleted. If the draft amendment is
        a cancellation, the list is empty; send `cancellation` instead.

        - `terms`: the invoices that terms would bill before they are saved,
        such as a new contract's. Refused when the terms cannot be billed, such
        as terms with no line items; the error says why.

        - `cancellation`: the invoice that would still be billed if the contract
        were cancelled from `cancelAt`, for its last charges billed in arrears
        (`IN_ARREARS`). Empty when there are none.


        Every invoice comes back on one page, so `hasMore` is always false.
        Needs a key holding `contracts:read` and `invoices:read`.
      operationId: invoices-preview-list
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contractId:
                  type: string
                  format: uuid
                  pattern: >-
                    ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                  description: The contract whose draft amendment to preview.
                terms:
                  type: object
                  properties:
                    startAt:
                      format: date-time
                      description: >-
                        The first day the terms cover. Only the date is used;
                        send it as midnight UTC.
                      type: string
                    endAt:
                      format: date-time
                      description: >-
                        The day the terms end. They cover the days before this
                        date, not the date itself. Only the date is used; send
                        it as midnight UTC.
                      type: string
                    paymentTermsDays:
                      type: integer
                      minimum: 0
                      maximum: 9007199254740991
                      description: >-
                        How many days the customer has to pay each invoice.
                        Leave it out for 0, which makes payment due the day the
                        invoice is issued.
                    lineItems:
                      type: array
                      items:
                        type: object
                        properties:
                          description:
                            type: string
                            description: What the line item says on each invoice.
                          amount:
                            type: object
                            properties:
                              value:
                                type: integer
                                minimum: -9007199254740991
                                maximum: 9007199254740991
                              currencyCode:
                                type: string
                                enum:
                                  - USD
                                  - CAD
                                  - EUR
                                  - USDC
                            required:
                              - value
                              - currencyCode
                            description: >-
                              What the line item charges each time it bills. Its
                              value is a whole number of the currency's smallest
                              unit, such as cents.
                          cadence:
                            anyOf:
                              - type: string
                                enum:
                                  - MONTHLY
                                  - QUARTERLY
                                  - SEMI_ANNUAL
                                  - ANNUAL
                              - type: 'null'
                            description: >-
                              How often the line item bills; null for a one-time
                              charge.
                          billingTiming:
                            type: string
                            enum:
                              - IN_ADVANCE
                              - IN_ARREARS
                            description: >-
                              When a line item with a cadence bills for each
                              period: IN_ADVANCE on the invoice dated the day
                              the period starts, IN_ARREARS on the invoice dated
                              the day it ends. Leave it out for IN_ADVANCE, and
                              for a one-time charge.
                        required:
                          - description
                          - amount
                          - cadence
                      description: >-
                        What the terms charge for. Every line item must be in
                        the same currency.
                  description: >-
                    Contract terms to preview without saving them, such as a new
                    contract's.
                cancellation:
                  type: object
                  properties:
                    contractId:
                      type: string
                      format: uuid
                      pattern: >-
                        ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
                      description: The contract to cancel.
                    cancelAt:
                      format: date-time
                      description: >-
                        The day the cancellation would end the contract. Only
                        the date is used; send it as midnight UTC.
                      type: string
                  required:
                    - contractId
                    - cancelAt
                  description: >-
                    A cancellation to preview without agreeing it: the contract,
                    and the day it would end.
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/InvoicePreview'
                  hasMore:
                    type: boolean
                  nextCursor:
                    type: string
                  prevCursor:
                    type: string
                required:
                  - data
                  - hasMore
                additionalProperties: false
        '400':
          description: Input validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.UNAUTHORIZED'
        '404':
          description: The record does not exist for your business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.NOT_FOUND'
        '500':
          description: An unexpected error occurred.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
      security:
        - BearerAuth: []
components:
  schemas:
    InvoicePreview:
      type: object
      properties:
        periodStartAt:
          format: date-time
          description: >-
            The first day of the billing period the invoice is for. A line can
            bill for other days, such as a charge in arrears for the period
            before; its billingStartAt and billingEndAt give its own days. Only
            the date matters; the time is always midnight UTC.
          type: string
        periodEndAt:
          format: date-time
          description: >-
            The day that billing period ends. It covers the days before this
            date, not the date itself. Only the date matters; the time is always
            midnight UTC.
          type: string
        scheduledIssueAt:
          format: date-time
          description: >-
            The day the invoice would be issued. Only the date matters; the time
            is always midnight UTC.
          type: string
        paymentTermsDays:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
          description: >-
            How many days the customer would have to pay once the invoice is
            issued.
        plannedDueAt:
          format: date-time
          description: >-
            The day payment would be due: scheduledIssueAt plus paymentTermsDays
            days. Only the date matters; the time is always midnight UTC.
          type: string
        totalAmount:
          type: object
          properties:
            value:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            currencyCode:
              type: string
              enum:
                - USD
                - CAD
                - EUR
                - USDC
          required:
            - value
            - currencyCode
          additionalProperties: false
          description: >-
            The sum of the invoice's lines. Its value is a whole number of the
            currency's smallest unit, so { "value": 200000, "currencyCode":
            "USD" } is $2,000.00.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/InvoicePreviewLineItem'
          description: Every line the invoice would have.
        hasUnfinalizedChanges:
          type: boolean
          description: >-
            Whether agreeing the contract's draft amendment would change what
            the contract bills. True when the contract has no agreed terms yet,
            because agreeing them is what starts its billing. The same on every
            invoice in the list. Always false for `terms` and `cancellation`.
      required:
        - periodStartAt
        - periodEndAt
        - scheduledIssueAt
        - paymentTermsDays
        - plannedDueAt
        - totalAmount
        - lines
        - hasUnfinalizedChanges
      additionalProperties: false
      description: >-
        An invoice that would be billed if a change went ahead: a contract's
        draft amendment being agreed, new terms being saved, or a contract being
        cancelled. It is worked out on each request and never stored, so it has
        no id, number or status.
    error.BAD_REQUEST:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Input validation failed
        code:
          type: string
          description: The error code
          example: BAD_REQUEST
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
      title: Input validation failed error (400)
      description: The error information
      example:
        code: BAD_REQUEST
        message: Input validation failed
        issues: []
    error.UNAUTHORIZED:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Unauthorized
        code:
          type: string
          description: The error code
          example: UNAUTHORIZED
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
      title: Unauthorized error (401)
      description: The error information
      example:
        code: UNAUTHORIZED
        message: Unauthorized
        issues: []
    error.NOT_FOUND:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: The record does not exist for your business.
        code:
          type: string
          description: The error code
          example: NOT_FOUND
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
      title: The record does not exist for your business. error (404)
      description: The error information
      example:
        code: NOT_FOUND
        message: The record does not exist for your business.
        issues: []
    error.INTERNAL_SERVER_ERROR:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: An unexpected error occurred.
        code:
          type: string
          description: The error code
          example: INTERNAL_SERVER_ERROR
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
      title: An unexpected error occurred. error (500)
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: An unexpected error occurred.
        issues: []
    InvoicePreviewLineItem:
      type: object
      properties:
        contractLineItemId:
          anyOf:
            - type: string
              format: uuid
              pattern: >-
                ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
            - type: 'null'
          description: >-
            The contract line item this line charges for. Null for lines of
            `terms`, which are not saved.
        description:
          type: string
          description: What the line would say on the invoice.
        billingStartAt:
          format: date-time
          description: >-
            The first day this line would bill for. Only the date matters; the
            time is always midnight UTC.
          type: string
        billingEndAt:
          format: date-time
          description: >-
            The day this line's billing would end. It covers the days before
            this date, not the date itself. Only the date matters; the time is
            always midnight UTC.
          type: string
        amount:
          type: object
          properties:
            value:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            currencyCode:
              type: string
              enum:
                - USD
                - CAD
                - EUR
                - USDC
          required:
            - value
            - currencyCode
          additionalProperties: false
          description: >-
            What this line would charge. Its value is a whole number of the
            currency's smallest unit, such as cents.
      required:
        - contractLineItemId
        - description
        - billingStartAt
        - billingEndAt
        - amount
      additionalProperties: false
      description: >-
        One charge on an invoice preview: what it is for, the days it covers and
        its amount.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'An API key created in Settings, sent as `Authorization: Bearer <key>`.'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.