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

# List Payments

> This endpoint aggregates patient payments and insurance payments into a single table,
then filters them according to the PaymentFetchParams.

For paginated requests, uses a two-phase approach to avoid statement timeouts:
- Phase 1: Lightweight query (no aggregations) for filtering, counting, and pagination
- Phase 2: Heavy query with full JSON aggregations, but only for the current page's IDs



## OpenAPI

````yaml get /billing/payment/table
openapi: 3.1.0
info:
  title: Decoda API
  description: External API documentation for the Decoda Health platform.
  version: '1.0'
servers: []
security: []
paths:
  /billing/payment/table:
    get:
      tags:
        - provider
        - billing
      summary: List Payments
      description: >-
        This endpoint aggregates patient payments and insurance payments into a
        single table,

        then filters them according to the PaymentFetchParams. Using DISTINCT on
        JSON requires

        either casting them to JSONB (with an equality operator) or removing
        DISTINCT. Here, we

        cast to JSONB so that Postgres can do equality checks on the JSON
        objects.
      operationId: list_payments_billing_payment_table_get
      parameters:
        - name: TENANT
          in: header
          required: true
          schema:
            type: string
            title: Tenant
          description: The tenant you are making this request on behalf of
        - name: API-KEY
          in: header
          required: true
          schema:
            type: string
            title: Api-Key
          description: Your api key
        - name: page
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Page
        - name: per_page
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Per Page
        - name: sort_by
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Sort By
        - name: sort_direction
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                enum:
                  - asc
                  - desc
              - type: 'null'
            title: Sort Direction
        - name: location_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Location Id
        - name: id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Id
        - name: payer
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Payer
        - name: external_patient_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: External Patient Id
        - name: payer_type
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Payer Type
        - name: amount
          in: query
          required: false
          schema:
            anyOf:
              - type: array
                items:
                  type: integer
              - type: 'null'
            title: Amount
        - name: last4
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Last4
        - name: comment
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Comment
        - name: payment_mediums
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Payment Mediums
        - name: status
          in: query
          required: false
          schema:
            anyOf:
              - type: array
                items:
                  $ref: '#/components/schemas/PaymentStatus'
              - type: 'null'
            title: Status
        - name: type
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Type
        - name: tags
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Tags
        - name: created_date
          in: query
          required: false
          schema:
            anyOf:
              - type: array
                items:
                  type: string
                  format: date-time
              - type: string
              - type: 'null'
            title: Created Date
        - name: tz
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Tz
        - name: location_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Location Ids
        - name: creator_name
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Creator Name
        - name: merchant_account_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Merchant Account Ids
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PaymentTable'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    PaymentStatus:
      type: string
      enum:
        - CANCELED
        - CREATED
        - FAILED
        - IN_REVIEW
        - PRESENTING
        - PROCESSING
        - SUCCEEDED
      title: PaymentStatus
    PaymentTable:
      properties:
        items:
          $ref: '#/components/schemas/Page_PaymentTableItem_'
        hasInsurancePayments:
          type: boolean
          title: Hasinsurancepayments
      type: object
      required:
        - items
        - hasInsurancePayments
      title: PaymentTable
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Page_PaymentTableItem_:
      properties:
        data:
          items:
            $ref: '#/components/schemas/PaymentTableItem'
          type: array
          title: Data
        total:
          type: integer
          title: Total
      type: object
      required:
        - data
        - total
      title: Page[PaymentTableItem]
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    PaymentTableItem:
      properties:
        id:
          type: string
          title: Id
        firstName:
          anyOf:
            - type: string
            - type: 'null'
          title: Firstname
        lastName:
          anyOf:
            - type: string
            - type: 'null'
          title: Lastname
        patientId:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientid
        externalPatientId:
          anyOf:
            - type: string
            - type: 'null'
          title: Externalpatientid
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
        phoneNumber:
          anyOf:
            - type: string
            - type: 'null'
          title: Phonenumber
        comment:
          anyOf:
            - type: string
            - type: 'null'
          title: Comment
        amount:
          type: integer
          title: Amount
        currency:
          type: string
          title: Currency
        status:
          type: string
          title: Status
        paymentMedium:
          type: string
          title: Paymentmedium
        fee:
          type: integer
          title: Fee
        feeToPatient:
          type: integer
          title: Feetopatient
        paymentMethod:
          anyOf:
            - $ref: '#/components/schemas/PaymentMethodSummary'
            - type: 'null'
        createdDate:
          type: string
          format: date-time
          title: Createddate
        refunds:
          items:
            $ref: '#/components/schemas/TableRefund-Output'
          type: array
          title: Refunds
        creator:
          anyOf:
            - $ref: '#/components/schemas/UserTiny'
            - type: 'null'
        isPaymentPlan:
          type: boolean
          title: Ispaymentplan
        items:
          items:
            $ref: '#/components/schemas/ItemWithQuantity'
          type: array
          title: Items
          description: List of items with their quantities and prices
        isInsurancePayment:
          type: boolean
          title: Isinsurancepayment
        locationId:
          anyOf:
            - type: string
            - type: 'null'
          title: Locationid
      type: object
      required:
        - id
        - amount
        - currency
        - status
        - paymentMedium
        - fee
        - feeToPatient
        - createdDate
        - refunds
        - isPaymentPlan
        - isInsurancePayment
      title: PaymentTableItem
    PaymentMethodSummary:
      properties:
        id:
          type: string
          title: Id
        patientId:
          anyOf:
            - type: string
            - type: 'null'
          title: Patientid
        rainforestPaymentMethodId:
          type: string
          title: Rainforestpaymentmethodid
        brand:
          anyOf:
            - type: string
            - type: 'null'
          title: Brand
        last4:
          anyOf:
            - type: string
            - type: 'null'
          title: Last4
        expMonth:
          anyOf:
            - type: integer
            - type: 'null'
          title: Expmonth
        expYear:
          anyOf:
            - type: integer
            - type: 'null'
          title: Expyear
        accountHolderType:
          anyOf:
            - type: string
            - type: 'null'
          title: Accountholdertype
        accountNumberLast4:
          anyOf:
            - type: integer
            - type: 'null'
          title: Accountnumberlast4
        bankName:
          anyOf:
            - type: string
            - type: 'null'
          title: Bankname
        routingNumber:
          anyOf:
            - type: integer
            - type: 'null'
          title: Routingnumber
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        type:
          anyOf:
            - $ref: '#/components/schemas/PaymentMethodType'
            - type: 'null'
        isDefault:
          type: boolean
          title: Isdefault
          default: false
        isArchived:
          type: boolean
          title: Isarchived
          default: false
      type: object
      required:
        - id
        - patientId
        - rainforestPaymentMethodId
        - brand
        - last4
        - expMonth
        - expYear
        - accountHolderType
        - accountNumberLast4
        - bankName
        - routingNumber
        - description
        - type
      title: PaymentMethodSummary
    TableRefund-Output:
      properties:
        id:
          type: string
          title: Id
        amount:
          type: integer
          title: Amount
        reason:
          $ref: '#/components/schemas/RefundReason'
        createdDate:
          type: string
          format: date-time
          title: Createddate
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        creator:
          anyOf:
            - $ref: '#/components/schemas/UserTiny'
            - type: 'null'
      type: object
      required:
        - id
        - amount
        - reason
        - createdDate
      title: TableRefund
    UserTiny:
      properties:
        id:
          type: string
          title: Id
          description: The unique identifier for the user.
        firstName:
          anyOf:
            - type: string
            - type: 'null'
          title: Firstname
          description: The user's first name.
        lastName:
          anyOf:
            - type: string
            - type: 'null'
          title: Lastname
          description: The user's last name.
        phoneNumber:
          anyOf:
            - type: string
            - type: 'null'
          title: Phonenumber
          description: The user's phone number.
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
          description: The user's email address.
        type:
          $ref: '#/components/schemas/UserType'
          description: The type of user.
        locationId:
          anyOf:
            - type: string
            - type: 'null'
          title: Locationid
          description: The location of the user.
      type: object
      required:
        - id
        - type
      title: UserTiny
    ItemWithQuantity:
      properties:
        itemName:
          type: string
          title: Itemname
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        chargeId:
          anyOf:
            - type: string
            - type: 'null'
          title: Chargeid
        discountReason:
          anyOf:
            - type: string
            - type: 'null'
          title: Discountreason
        discountAmount:
          anyOf:
            - type: integer
            - type: 'null'
          title: Discountamount
        discountPercentage:
          anyOf:
            - type: number
            - type: 'null'
          title: Discountpercentage
        quantity:
          type: integer
          title: Quantity
        unit:
          anyOf:
            - type: string
            - type: 'null'
          title: Unit
        pricePerItem:
          type: integer
          title: Priceperitem
        itemType:
          anyOf:
            - type: string
            - type: 'null'
          title: Itemtype
      type: object
      required:
        - itemName
        - quantity
        - pricePerItem
      title: ItemWithQuantity
    PaymentMethodType:
      type: string
      enum:
        - CARD
        - ACH
        - APPLE_PAY
      title: PaymentMethodType
    RefundReason:
      type: string
      enum:
        - DUPLICATE
        - DISPUTE
        - BOOKING_FEE
        - OTHER
      title: RefundReason
    UserType:
      type: string
      enum:
        - PROVIDER
        - PATIENT
        - ASSISTANT
      title: UserType

````