> ## 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: v2
servers:
  - url: https://api.rootfi.dev
    description: Production
security: []
paths:
  /accounting/invoice_payments:
    post:
      tags:
        - AccountingInvoicePayment
      summary: Create Invoice Payment
      description: Add an invoice payment.
      operationId: accounting_invoicePayment_create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/accountingtypesCreateInvoicePaymentRequest'
            examples:
              Example1:
                value:
                  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
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/accountingtypesCreateInvoicePaymentsResponse
              examples:
                Example1:
                  value:
                    data:
                      status: SUCCESS
                      upload_job_id: xQm2K441VosP8W4
                      data:
                        - job_id: aXI9pUDA5T7E2LS
                          status: success
                          response:
                            platform_id: '3770712000001688003'
                            payment_id: '3770712000001688001'
                            invoice_id: '3770712000000707001'
                            account_id: '3770712000000000361'
                            credit_note_id: '1234567890123456789'
                            contact_id: '3770712000000226001'
                            currency_id: '3770712000000000099'
                            amount: 19
                            payment_date: '2023-03-01T00:00:00.000Z'
                            payment_mode: Cash
                            document_number: S77
                            memo: Invoice payment
                            currency_rate: 12
                            updated_at: '2023-10-27T00:00:00.000Z'
                            raw_data:
                              platform_id: '123456'
                              nominal_code: Rootfi 01
                              name: Test Account
                              description: Test Description
                              category: LIABILITY
                              sub_category: Long Term Liabilities
                              status: ACTIVE
                          error: null
                    request_timestamp: '2021-09-28T15:00:00.000Z'
                    response_timestamp: '2021-09-28T15:00:00.000Z'
                    request_id: 7a1c0e42-9f85-4d6e-bb5d-358a72913c0b
      security:
        - ApiKeyAuth: []
components:
  schemas:
    accountingtypesCreateInvoicePaymentRequest:
      title: accountingtypesCreateInvoicePaymentRequest
      type: object
      properties:
        company_id:
          type: integer
          example: 1
        data:
          type: array
          items:
            $ref: >-
              #/components/schemas/accountingtypesInvoicePaymentsWriteRequestFields
      required:
        - company_id
        - data
    accountingtypesCreateInvoicePaymentsResponse:
      title: accountingtypesCreateInvoicePaymentsResponse
      type: object
      properties: {}
      allOf:
        - $ref: >-
            #/components/schemas/accountingtypesFinalCreateInvoicePaymentsResponse
        - $ref: '#/components/schemas/timestamp'
    accountingtypesInvoicePaymentsWriteRequestFields:
      title: accountingtypesInvoicePaymentsWriteRequestFields
      type: object
      properties:
        raw_data:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            A JSON containing fields that you can directly pass to the
            accounting platform.
      allOf:
        - $ref: >-
            #/components/schemas/accountingtypesInvoicePaymentsAllResponsesCommonFields
    accountingtypesFinalCreateInvoicePaymentsResponse:
      title: accountingtypesFinalCreateInvoicePaymentsResponse
      type: object
      properties:
        data:
          $ref: >-
            #/components/schemas/accountingtypesCreateInvoicePaymentsResponseData
      required:
        - data
    timestamp:
      title: timestamp
      type: object
      properties:
        request_timestamp:
          type: string
          format: date-time
          description: The time at which the request was received by the server
        response_timestamp:
          type: string
          format: date-time
          description: The time at which the response was sent by the server
        request_id:
          type: string
          description: The unique ID of the request
      required:
        - request_timestamp
        - response_timestamp
        - request_id
    accountingtypesInvoicePaymentsAllResponsesCommonFields:
      title: accountingtypesInvoicePaymentsAllResponsesCommonFields
      type: object
      properties:
        invoice_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique identifier for the invoice
            associated with this invoice payment
        account_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique identifier for the account
            associated with this invoice payment
        contact_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique identifier for the contact
            associated with this invoice payment
        credit_note_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique identifier for the credit note
            associated with this invoice payment
        currency_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique identifier for the currency
            associated with this invoice payment
        amount:
          type: number
          format: double
          nullable: true
          description: The amount of the invoice payment
        payment_date:
          type: string
          nullable: true
          description: The date of the invoice payment
        payment_mode:
          type: string
          nullable: true
          description: The payment mode of the invoice payment
        document_number:
          type: string
          nullable: true
          description: Reference number for the invoice payment
        memo:
          type: string
          nullable: true
          description: Description of the invoice payment
    accountingtypesCreateInvoicePaymentsResponseData:
      title: accountingtypesCreateInvoicePaymentsResponseData
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/accountingtypesInvoicepaymentsResponse'
      required:
        - data
      allOf:
        - $ref: '#/components/schemas/SuccessResponse'
    accountingtypesInvoicepaymentsResponse:
      title: accountingtypesInvoicepaymentsResponse
      type: object
      properties:
        response:
          $ref: >-
            #/components/schemas/accountingtypesInvoicePaymentsWriteResponseFields
        error:
          $ref: '#/components/schemas/ErrorObject'
          nullable: true
          description: The error message if the job failed.
      required:
        - response
      allOf:
        - $ref: '#/components/schemas/JobSuccessResponse'
    SuccessResponse:
      title: SuccessResponse
      type: object
      properties:
        status:
          $ref: '#/components/schemas/Status'
          description: The status of the job.
        upload_job_id:
          type: string
          description: The ID of the job.
      required:
        - status
        - upload_job_id
    accountingtypesInvoicePaymentsWriteResponseFields:
      title: accountingtypesInvoicePaymentsWriteResponseFields
      type: object
      properties:
        raw_data:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            The raw JSON response we receive from the accounting platform for
            this invoice payment
      allOf:
        - $ref: '#/components/schemas/accountingtypesInvoicePaymentsResponseFields'
    ErrorObject:
      title: ErrorObject
      type: object
      properties:
        code:
          type: string
        message:
          type: string
        platform_error:
          type: string
        raw_data:
          type: object
          additionalProperties: true
          nullable: true
      required:
        - code
        - message
        - platform_error
    JobSuccessResponse:
      title: JobSuccessResponse
      type: object
      properties:
        job_id:
          type: string
          description: The ID of the job.
        status:
          $ref: '#/components/schemas/JobResponseStatus'
          description: The status of the job.
      required:
        - job_id
        - status
    Status:
      title: Status
      type: string
      enum:
        - SUCCESS
        - FAILED
        - CREATED
        - RUNNING
    accountingtypesInvoicePaymentsResponseFields:
      title: accountingtypesInvoicePaymentsResponseFields
      type: object
      properties:
        currency_rate:
          type: number
          format: double
          nullable: true
          description: Rate between the currency of the payment and the base currency
        updated_at:
          type: string
          nullable: true
          description: The last ISO 8601 timestamp at which the payment data was updated
      allOf:
        - $ref: '#/components/schemas/accountingtypesInvoicePaymentsPlatformId'
        - $ref: '#/components/schemas/accountingtypesInvoicePaymentId'
        - $ref: >-
            #/components/schemas/accountingtypesInvoicePaymentsAllResponsesCommonFields
    JobResponseStatus:
      title: JobResponseStatus
      type: string
      enum:
        - success
        - failed
    accountingtypesInvoicePaymentsPlatformId:
      title: accountingtypesInvoicePaymentsPlatformId
      type: object
      properties:
        platform_id:
          type: string
          description: The ID that the accounting platform uses to identify this account
      required:
        - platform_id
    accountingtypesInvoicePaymentId:
      title: accountingtypesInvoicePaymentId
      type: object
      properties:
        payment_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique identifier for this specific
            payment
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api_key

````