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

# Create Invoice Payments

> Create a new invoice payments in the database.

**The Invoice Payments Data Model** streamlines the representation and management of invoice payment information across multiple accounting platforms.

## Additional Required Fields

To successfully create an invoice payment, certain fields must be included in the raw\_data object of the request body. The required fields are as follows:

| Integration       | Field                | Description                                            |
| ----------------- | -------------------- | ------------------------------------------------------ |
| MS\_DYNAMICS\_365 | payment\_journal\_id | The ID of the payment journal.                         |
| NETSUITE          | arr\_account\_id     | The ID of the account to which the payment is applied. |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.rootfi.dev/v3/accounting/invoice_payments \
    --header 'Content-Type: application/json' \
    --header 'api_key: <api-key>' \
    --data '{
    "company_id": 1,
    "data": [
      {
        "invoice_id": "123456",
        "account_id": "123456",
        "contact_id": "123456",
        "amount": 100,
        "payment_date": "2021-09-28T15:00:00.000Z",
        "document_number": "ROOTFI01",
        "memo": "Test Memo"
      }
    ]
  }'
  ```

  ```javascript NodeJS theme={null}
  import { RootFiClient } from "rootfi-api";
  const rootfi = new RootFiClient({ apiKey: "<api_key>" });

  await rootfi.accounting.invoicePayment.create({
    company_id: 1,
    data: [
      {
        invoice_id: "123456",
        account_id: "123456",
        contact_id: "123456",
        amount: 100,
        payment_date: "2021-09-28T15:00:00.000Z",
        document_number: "ROOTFI01",
        memo: "Test Memo",
      },
    ],
  });
  ```
</RequestExample>


## OpenAPI

````yaml POST /accounting/invoice_payments
openapi: 3.0.1
info:
  title: rootfi
  version: v3
servers:
  - url: https://api.rootfi.dev/v3
    description: global
  - url: https://api.sa.rootfi.dev/v3
    description: saudi
security: []
paths:
  /accounting/invoice_payments:
    post:
      tags:
        - AccountingInvoicePayments
      summary: Create Invoice Payments
      description: Create a new invoice payments in the database.
      operationId: accounting_invoicePayments_create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/accountingCreateInvoicePaymentsRequest'
            examples:
              Example1:
                value:
                  company_id: 123
                  data:
                    - payment_id: '123456'
                      invoice_id: '123456'
                      account_id: '123456'
                      credit_note_id: '123456'
                      amount: 12.3
                      payment_mode: '123456'
                      currency_id: '123456'
                      currency_rate: '123456'
                      memo: '123456'
                      updated_at: '2024-01-22T05:07:31.465Z'
                      payment_date: '2024-01-22T05:07:31.465Z'
                      contact_id: '123456'
                      document_number: '123456'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accountingCreateInvoicePaymentsResponse'
              examples:
                Example1:
                  value:
                    data:
                      rootfi_id: 157
                      rootfi_deleted_at: null
                      rootfi_created_at: '2024-01-22T05:07:31.465Z'
                      rootfi_updated_at: '2024-01-22T05:07:31.000Z'
                      rootfi_company_id: 1089
                      platform_id: '123456_1'
                      platform_unique_id: '123456'
                      payment_id: '123456'
                      invoice_id: '123456'
                      account_id: '123456'
                      credit_note_id: '123456'
                      amount: 123.4
                      payment_mode: '123456'
                      currency_id: '123456'
                      currency_rate: '123456'
                      memo: '123456'
                      updated_at: '2024-01-22T05:07:31.465Z'
                      payment_date: '2024-01-22T05:07:31.465Z'
                      contact_id: '123456'
                      document_number: '123456'
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RootFiAPIResponseType'
        '403':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RootFiAPIResponseType'
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RootFiAPIResponseType'
        '500':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RootFiAPIResponseType'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    accountingCreateInvoicePaymentsRequest:
      title: accountingCreateInvoicePaymentsRequest
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/accountingInvoicePaymentsFields'
          description: The data of the invoice payments endpoint
      required:
        - data
      allOf:
        - $ref: '#/components/schemas/CompanyIDRequestField'
    accountingCreateInvoicePaymentsResponse:
      title: accountingCreateInvoicePaymentsResponse
      type: object
      properties:
        data:
          $ref: '#/components/schemas/accountingInvoicePaymentsObject'
          nullable: true
          description: The data of the invoice payments endpoint
        sync_id:
          type: string
          nullable: true
          description: The sync id of the request
    RootFiAPIResponseType:
      title: RootFiAPIResponseType
      type: object
      properties:
        error:
          $ref: '#/components/schemas/RootFiAPIResponseErrorType'
          description: The error message
      required:
        - error
    accountingInvoicePaymentsFields:
      title: accountingInvoicePaymentsFields
      type: object
      properties:
        payment_id:
          type: string
          nullable: true
          description: The payment id of the invoice payments
        invoice_id:
          type: string
          nullable: true
          description: The invoice id of the invoice payments
        account_id:
          type: string
          nullable: true
          description: The account id of the invoice payments
        credit_note_id:
          type: string
          nullable: true
          description: The credit note id of the invoice payments
        amount:
          type: number
          format: double
          nullable: true
          description: The amount of the invoice payments
        payment_mode:
          type: string
          nullable: true
          description: The payment mode of the invoice payments
        currency_id:
          type: string
          nullable: true
          description: The currency id of the invoice payments
        currency_rate:
          type: string
          nullable: true
          description: The currency rate of the invoice payments
        memo:
          type: string
          nullable: true
          description: The memo of the invoice payments
        updated_at:
          type: string
          nullable: true
          description: The updated date of the invoice payments
        payment_date:
          type: string
          nullable: true
          description: The payment date of the invoice payments
        contact_id:
          type: string
          nullable: true
          description: The contact id of the invoice payments
        document_number:
          type: string
          nullable: true
          description: The document number of the invoice payments
    CompanyIDRequestField:
      title: CompanyIDRequestField
      type: object
      properties:
        company_id:
          type: integer
          description: The ID of the company in the accounting platform
        run_async:
          type: boolean
          nullable: true
          description: Run the request asynchronously
      required:
        - company_id
    accountingInvoicePaymentsObject:
      title: accountingInvoicePaymentsObject
      type: object
      properties:
        invoice:
          $ref: '#/components/schemas/accountingInvoiceObject'
          nullable: true
          description: The invoice object of the invoice payments
        account:
          $ref: '#/components/schemas/accountingAccountObject'
          nullable: true
          description: The account object of the invoice payments
        currency:
          $ref: '#/components/schemas/accountingCurrencyObject'
          nullable: true
          description: The currency object of the invoice payments
        contact:
          $ref: '#/components/schemas/accountingContactAllFields'
          nullable: true
          description: The contact object of the invoice payments
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingInvoicePaymentsFields'
    RootFiAPIResponseErrorType:
      title: RootFiAPIResponseErrorType
      type: object
      properties:
        message:
          type: string
          description: The error message
        code:
          type: string
          description: The error code
        field:
          type: string
          description: The status of the error
      required:
        - message
        - code
        - field
    accountingInvoiceObject:
      title: accountingInvoiceObject
      type: object
      properties:
        currency:
          $ref: '#/components/schemas/accountingCurrencyObject'
          nullable: true
          description: The currency of the invoice
        contact:
          $ref: '#/components/schemas/accountingContactAllFields'
          nullable: true
          description: The contact of the invoice
        documents:
          type: array
          items:
            $ref: '#/components/schemas/accountingDocumentObject'
          nullable: true
          description: The documents of the invoice
        invoice_payments:
          type: array
          items:
            $ref: '#/components/schemas/accountingInvoicePaymentsAllFields'
          nullable: true
          description: The invoice payments of the invoice
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingInvoiceFields'
    accountingAccountObject:
      title: accountingAccountObject
      type: object
      properties:
        parent_account:
          $ref: '#/components/schemas/accountingAccountAllFields'
          nullable: true
          description: The parent account of the account.
        currency:
          $ref: '#/components/schemas/accountingCurrencyObject'
          nullable: true
          description: The currency of the account.
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingAccountFields'
    accountingCurrencyObject:
      title: accountingCurrencyObject
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingCurrencyFields'
    accountingContactAllFields:
      title: accountingContactAllFields
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingContactFields'
    AccountingRootFiBaseFields:
      title: AccountingRootFiBaseFields
      type: object
      properties:
        rootfi_id:
          type: number
          format: double
          description: The unique ID we assign for that data's information
          example: 157
        rootfi_deleted_at:
          type: string
          format: date-time
          nullable: true
          description: The date at which the data was deleted in the accounting platform
        rootfi_created_at:
          type: string
          format: date-time
          description: The date at which RootFi first synced this data
          example: '2024-01-22T05:07:31.465Z'
        rootfi_updated_at:
          type: string
          format: date-time
          description: The latest date at which RootFi updated this data
          example: '2024-01-22T05:07:31.000Z'
        rootfi_company_id:
          type: number
          format: double
          description: The ID of the company in the accounting platform
          example: 1089
        platform_id:
          type: string
          description: An unique custom RootFi ID made from platform's unique_id.
          example: '123456'
        platform_unique_id:
          type: string
          nullable: true
          description: The ID of the data in the accounting platform.
        raw_data:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            A JSON containing fields that you can directly get from the
            accounting platform.
        data_hash:
          type: string
          nullable: true
          description: The hash of the data
      required:
        - rootfi_id
        - rootfi_created_at
        - rootfi_updated_at
        - rootfi_company_id
        - platform_id
    accountingDocumentObject:
      title: accountingDocumentObject
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingDocumentFields'
    accountingInvoicePaymentsAllFields:
      title: accountingInvoicePaymentsAllFields
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingInvoicePaymentsFields'
    accountingInvoiceFields:
      title: accountingInvoiceFields
      type: object
      properties:
        currency_id:
          type: string
          nullable: true
          description: The currency ID of the invoice
        contact_id:
          type: string
          nullable: true
          description: The contact ID of the invoice
        total_discount:
          type: number
          format: double
          nullable: true
          description: The total discount of the invoice
        sub_total:
          type: number
          format: double
          nullable: true
          description: The sub total of the invoice
        tax_amount:
          type: number
          format: double
          nullable: true
          description: The tax amount of the invoice
        total_amount:
          type: number
          format: double
          nullable: true
          description: The total amount of the invoice
        amount_due:
          type: number
          format: double
          nullable: true
          description: The amount due of the invoice
        document_number:
          type: string
          nullable: true
          description: The document number of the invoice
        posted_date:
          type: string
          nullable: true
          description: The posted date of the invoice
        due_date:
          type: string
          nullable: true
          description: The due date of the invoice
        memo:
          type: string
          nullable: true
          description: The memo of the invoice
        updated_at:
          type: string
          nullable: true
          description: The updated at of the invoice
        status:
          type: string
          nullable: true
          description: The status of the invoice
        currency_rate:
          type: number
          format: double
          nullable: true
          description: The currency rate of the invoice
        sales_order_ids:
          type: array
          items:
            type: string
          nullable: true
          description: The sales order IDs of the invoice
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/LineItemFields'
          nullable: true
          description: The line items of the invoice
    accountingAccountAllFields:
      title: accountingAccountAllFields
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingAccountFields'
    accountingAccountFields:
      title: accountingAccountFields
      type: object
      properties:
        name:
          type: string
          nullable: true
          description: Name of the account
        description:
          type: string
          nullable: true
          description: Description of the account
        nominal_code:
          type: string
          nullable: true
          description: The nominal code of the account
        current_balance:
          type: number
          format: double
          nullable: true
          description: The current balance of the account
        updated_at:
          type: string
          nullable: true
          description: The date the account was last updated
        status:
          type: string
          nullable: true
          description: The status of the account
        category:
          $ref: '#/components/schemas/AccountCategory'
          nullable: true
          description: The category of the account
        sub_category:
          type: string
          nullable: true
          description: The sub category of the account
        currency_id:
          type: string
          nullable: true
          description: The currency id of the account
        parent_account_id:
          type: string
          nullable: true
          description: The parent account id of the account
    accountingCurrencyFields:
      title: accountingCurrencyFields
      type: object
      properties:
        name:
          type: string
          nullable: true
          description: The name of the currency
        code:
          type: string
          nullable: true
          description: The currency code.
        symbol:
          type: string
          nullable: true
          description: >-
            The symbol that represents the currency. Not applicable for many
            currencies.
        is_base_currency:
          type: boolean
          nullable: true
          description: Whether the currency is the base currency for the company.
        exchange_rate:
          type: number
          format: double
          nullable: true
          description: The exchange rate for the currency.
        updated_at:
          type: string
          nullable: true
          description: The last ISO 8601 timestamp that the data was updated at.
    accountingContactFields:
      title: accountingContactFields
      type: object
      properties:
        name:
          type: string
          nullable: true
          description: Name of the contact
        contact_name:
          type: string
          nullable: true
          description: Name of the contact person for the contact
        contact_type:
          $ref: '#/components/schemas/ContactType'
          nullable: true
          description: The type of contact. Values are either CUSTOMER or VENDOR
        currency_id:
          type: string
          nullable: true
          description: The ISO-4217 currency code
        tax_number:
          type: string
          nullable: true
          description: Contact’s tax number
        registration_number:
          type: string
          nullable: true
          description: Contact’s identifying number
        status:
          $ref: '#/components/schemas/BaseStatus'
          nullable: true
          description: The status of the contact. Values are ACTIVE, ARCHIVED, UNKNOWN
        updated_at:
          type: string
          nullable: true
          description: The date the contact was last updated
        external_links:
          type: array
          items:
            $ref: '#/components/schemas/ExternalLinks'
          nullable: true
          description: External links for the contact
        phone_numbers:
          type: array
          items:
            $ref: '#/components/schemas/PhoneNumbers'
          nullable: true
          description: Phone numbers for the contact
        addresses:
          type: array
          items:
            $ref: '#/components/schemas/Addresses'
          nullable: true
          description: Addresses for the contact
    accountingDocumentFields:
      title: accountingDocumentFields
      type: object
      properties:
        file_name:
          type: string
          nullable: true
          description: The file name of the document
        file_type:
          type: string
          nullable: true
          description: The file type of the document
        file_size:
          type: string
          nullable: true
          description: The file size of the document
        document_type_id:
          type: string
          nullable: true
          description: The platform_id of the voucher to which the file will be linked to.
        document_type:
          type: string
          nullable: true
          description: The document type of the document
        document_uploaded:
          type: boolean
          nullable: true
          description: The document uploaded of the document
        updated_at:
          type: string
          nullable: true
          description: The updated date of the document
    LineItemFields:
      title: LineItemFields
      type: object
      properties:
        rootfi_id:
          type: number
          format: double
          nullable: true
          description: The unique ID we assign for that data's information
        platform_id:
          type: string
          nullable: true
          description: The platform id of the line item
        line_item_type:
          $ref: '#/components/schemas/AccountingLineItemtype'
          nullable: true
          description: The line item type of the line item
        line_item_type_id:
          type: string
          nullable: true
          description: The line item type id of the line item
        tracking_category_ids:
          type: array
          items:
            type: string
          nullable: true
          description: The tracking category ids of the line item
        project_id:
          type: string
          nullable: true
          description: The project id of the line item
        item_id:
          type: string
          nullable: true
          description: The item id of the line item
        item:
          $ref: '#/components/schemas/accountingItemObject'
          nullable: true
          description: The item of the line item
        tax_id:
          type: string
          nullable: true
          description: The tax id of the line item
        tax:
          $ref: '#/components/schemas/accountingTaxRateObject'
          nullable: true
          description: The tax of the line item
        account_id:
          type: string
          nullable: true
          description: The account id of the line item
        account:
          $ref: '#/components/schemas/accountingAccountObject'
          nullable: true
          description: The account of the line item
        description:
          type: string
          nullable: true
          description: The description of the line item
        quantity:
          type: number
          format: double
          nullable: true
          description: The quantity of the line item
        unit_amount:
          type: number
          format: double
          nullable: true
          description: The unit amount of the line item
        total_amount:
          type: number
          format: double
          nullable: true
          description: The total amount of the line item
        sub_total:
          type: number
          format: double
          nullable: true
          description: The sub total of the line item
        tax_amount:
          type: number
          format: double
          nullable: true
          description: The tax amount of the line item
        total_discount:
          type: number
          format: double
          nullable: true
          description: The total discount of the line item
        updated_at:
          type: string
          format: date-time
          nullable: true
          description: The last ISO 8601 timestamp that the data was updated at
    AccountCategory:
      title: AccountCategory
      type: string
      enum:
        - ASSET
        - EXPENSE
        - LIABILITY
        - EQUITY
        - INCOME
        - BANK
        - UNKNOWN
    ContactType:
      title: ContactType
      type: string
      enum:
        - CUSTOMER
        - VENDOR
    BaseStatus:
      title: BaseStatus
      type: string
      enum:
        - ACTIVE
        - ARCHIVED
        - UNKNOWN
    ExternalLinks:
      title: ExternalLinks
      type: object
      properties:
        rootfi_id:
          type: integer
          nullable: true
          description: The RootFi ID of the contact
        platform_id:
          type: string
          nullable: true
          description: The platform ID of the contact
        link:
          type: string
          nullable: true
          description: The link to the contact
        type:
          $ref: '#/components/schemas/ExternalLinkType'
          nullable: true
          description: The type of the link.
    PhoneNumbers:
      title: PhoneNumbers
      type: object
      properties:
        rootfi_id:
          type: integer
          nullable: true
          description: The RootFi ID of the contact
        platform_id:
          type: string
          nullable: true
          description: The platform ID of the contact
        number:
          type: string
          nullable: true
          description: The number to the contact
        type:
          $ref: '#/components/schemas/ContactNumberType'
          nullable: true
          description: The type of the link.
    Addresses:
      title: Addresses
      type: object
      properties:
        rootfi_id:
          type: integer
          nullable: true
          description: The RootFi ID of the contact
        platform_id:
          type: string
          nullable: true
          description: The platform ID of the contact
        street:
          type: string
          nullable: true
          description: The street of the address
        locality:
          type: string
          nullable: true
          description: The locality of the address
        city:
          type: string
          nullable: true
          description: The city of the address
        state:
          type: string
          nullable: true
          description: The state of the address
        pincode:
          type: string
          nullable: true
          description: The pincode of the address
        country:
          type: string
          nullable: true
          description: The country of the address
    AccountingLineItemtype:
      title: AccountingLineItemtype
      type: string
      enum:
        - BILLS
        - INVOICES
        - BILL_CREDIT_NOTES
        - INVOICE_CREDIT_NOTES
        - EXPENSES
        - PURCHASE_ORDERS
        - SALES_ORDERS
    accountingItemObject:
      title: accountingItemObject
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingItemFields'
    accountingTaxRateObject:
      title: accountingTaxRateObject
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingTaxRateFields'
    ExternalLinkType:
      title: ExternalLinkType
      type: string
      enum:
        - EMAIL
        - WEBSITE
    ContactNumberType:
      title: ContactNumberType
      type: string
      enum:
        - MOBILE
        - TELEPHONE
        - FAX
    accountingItemFields:
      title: accountingItemFields
      type: object
      properties:
        name:
          type: string
          nullable: true
          description: Name of the item
        description:
          type: string
          nullable: true
          description: Description of the item
        status:
          $ref: '#/components/schemas/BaseStatus'
          nullable: true
          description: Status of the item. Values are ACTIVE, ARCHIVED, UNKNOWN
        type:
          $ref: '#/components/schemas/ItemType'
          nullable: true
          description: >-
            Type of the item. Values are INVENTORY, NON_INVENTORY, SERVICE,
            UNKNOWN
        code:
          type: string
          nullable: true
          description: Reference code of the item
        quantity_on_hand:
          type: integer
          nullable: true
          description: Quantity on hand
        is_bill_item:
          type: boolean
          nullable: true
          description: >-
            Check if there are details (bill_item) of this item getting
            purchased
        bill_item:
          $ref: '#/components/schemas/accountingItemDetail'
          nullable: true
          description: Item details of this item getting purchased
        is_invoice_item:
          type: boolean
          nullable: true
          description: Check if there are details (invoice_item) of this item getting sold
        invoice_item:
          $ref: '#/components/schemas/accountingItemDetail'
          nullable: true
          description: Item details of this item getting sold
        updated_at:
          type: string
          nullable: true
          description: The date the item was last updated
    accountingTaxRateFields:
      title: accountingTaxRateFields
      type: object
      properties:
        name:
          type: string
          nullable: true
          description: Display name
        code:
          type: string
          nullable: true
          description: Simple ID for the tax rate
        tax_type:
          type: string
          nullable: true
          description: The type of tax as mentioned in the accounting platform
        effective_tax_rate:
          type: number
          format: double
          nullable: true
          description: >-
            The total tax rate after accounting for the compounding effects of
            the all tax components
        total_tax_rate:
          type: number
          format: double
          nullable: true
          description: The sum of all the tax rate components
        components:
          type: array
          items:
            $ref: '#/components/schemas/accountingTaxRateComponent'
          nullable: true
          description: The list of tax rate components
        updated_at:
          type: string
          nullable: true
          description: The last time the tax rate was updated
    ItemType:
      title: ItemType
      type: string
      enum:
        - INVENTORY
        - NON_INVENTORY
        - SERVICE
        - UNKNOWN
    accountingItemDetail:
      title: accountingItemDetail
      type: object
      properties:
        tax_id:
          type: string
          nullable: true
          description: Tax id of the item
        account_id:
          type: string
          nullable: true
        unit_price:
          type: number
          format: double
          nullable: true
          description: Unit price of the item
        description:
          type: string
          nullable: true
          description: Description of the item
    accountingTaxRateComponent:
      title: accountingTaxRateComponent
      type: object
      properties:
        name:
          type: string
          nullable: true
          description: Display name
        rate:
          type: number
          format: double
          nullable: true
          description: >-
            The total tax rate after accounting for the compounding effects of
            the all tax components
        tax_agency:
          type: string
          nullable: true
          description: The tax agency of the tax rate component
        is_compound:
          type: boolean
          nullable: true
          description: Whether the tax rate component is compound
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api_key

````