> ## 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 Journal Entry

> Create a new Journal Entry.

The [Journal Entries](https://docs.rootfi.dev/api-reference/journal-entries/overview) are basic records of a company's financial transactions used to record the debits and credits of each transaction.

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.rootfi.dev/v3/accounting/journal_entries \
    --header 'Content-Type: application/json' \
    --header 'api_key: <api-key>' \
    --data '{
    "company_id": 1,
    "data": [
      {
        "document_number": "ROOTFI01",
        "posted_date": "2021-09-28T15:00:00.000Z",
        "description": "Test Invoice",
        "currency_id": "GBP",
        "business_unit_id": "1",
        "journal_lines": [
          {
            "account_id": "123456",
            "type": "DEBIT",
            "net_amount": 100,
            "contact_id": "123456",
            "tax_id": "123456",
            "tracking_category_ids": [],
            "description": "Test Item"
          },
          {
            "account_id": "123456",
            "type": "CREDIT",
            "net_amount": 100,
            "contact_id": "123456",
            "tax_id": "123456",
            "tracking_category_ids": [],
            "description": "Test Item"
          }
        ]
      }
    ]
  }'
  ```

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

  await rootfi.accounting.journalEntries.create({
    company_id: 1,
    data: [
      {
        document_number: "ROOTFI01",
        posted_date: "2021-09-28T15:00:00.000Z",
        description: "Test Invoice",
        currency_id: "GBP",
        business_unit_id: "1",
        journal_lines: [
          {
            account_id: "123456",
            type: "DEBIT",
            net_amount: 100,
            contact_id: "123456",
            tax_id: "123456",
            tracking_category_ids: [],
            description: "Test Item",
          },
          {
            account_id: "123456",
            type: "CREDIT",
            net_amount: 100,
            contact_id: "123456",
            tax_id: "123456",
            tracking_category_ids: [],
            description: "Test Item",
          },
        ],
      },
    ],
  });
  ```
</RequestExample>


## OpenAPI

````yaml POST /accounting/journal_entries
openapi: 3.0.1
info:
  title: rootfi
  version: v2
servers:
  - url: https://api.rootfi.dev
    description: Production
security: []
paths:
  /accounting/journal_entries:
    post:
      tags:
        - AccountingJournalEntries
      summary: Create a journal entry
      description: Add a journal entry.
      operationId: accounting_journalEntries_create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/accountingtypesCreateJournalEntryRequest'
            examples:
              Example1:
                value:
                  company_id: 1
                  data:
                    - document_number: ROOTFI01
                      posted_date: '2021-09-28T15:00:00.000Z'
                      description: Test Invoice
                      currency_id: GBP
                      journal_lines:
                        - account_id: '123456'
                          type: DEBIT
                          net_amount: 100
                          contact_id: '123456'
                          tax_id: '123456'
                          tracking_category_ids: []
                          description: Test Item
                        - account_id: '123456'
                          type: CREDIT
                          net_amount: 100
                          contact_id: '123456'
                          tax_id: '123456'
                          tracking_category_ids: []
                          description: Test Item
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accountingtypesCreateJournalEntryResponse'
              examples:
                Example1:
                  value:
                    data:
                      status: SUCCESS
                      upload_job_id: aXI9pUDA5T7E2LS
                      data:
                        - job_id: xQm2K441VosP8W4
                          status: success
                          response:
                            platform_id: '3770712000001649001'
                            account_id: '3770712000000000361'
                            currency_id: '3770712000000000099'
                            document_number: ROOTFI01
                            description: journal_desc
                            posted_date: '2023-06-12T00:00:00.000Z'
                            amount: 568
                            currency_rate: 12
                            journal_entry_type: both
                            updated_at: '2023-10-27T00:00:00.000Z'
                            journal_lines:
                              - platform_id: '3770712000001725038'
                                journal_entry_id: '3770712000001725026'
                                account_id: '3770712000000035001'
                                contact_id: '3770712000000080780'
                                tax_id: null
                                tracking_category_ids:
                                  - '3770712000000000335_3770712000001122010'
                                type: DEBIT
                                description: Test Description for Journal
                                net_amount: 5
                                tax_amount: null
                                updated_at: null
                            raw_data:
                              platform_id: '1013'
                              name: Test
                              contact_name: Test
                              contact_type: CUSTOMER
                              currency_id: '1'
                              status: ARCHIVED
                          error: null
                    request_timestamp: '2023-10-25T13:39:41.201Z'
                    response_timestamp: '2023-10-25T13:39:41.201Z'
                    request_id: 7a1c0e42-9f85-4d6e-bb5d-358a72913c0b
      security:
        - ApiKeyAuth: []
components:
  schemas:
    accountingtypesCreateJournalEntryRequest:
      title: accountingtypesCreateJournalEntryRequest
      type: object
      properties:
        company_id:
          type: integer
          description: The company ID
          example: 1
        data:
          type: array
          items:
            $ref: '#/components/schemas/accountingtypesJournalEntriesWriteRequest'
      required:
        - company_id
        - data
    accountingtypesCreateJournalEntryResponse:
      title: accountingtypesCreateJournalEntryResponse
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/accountingtypesFinalCreateJournalEntryResponse'
        - $ref: '#/components/schemas/timestamp'
    accountingtypesJournalEntriesWriteRequest:
      title: accountingtypesJournalEntriesWriteRequest
      type: object
      properties:
        journal_lines:
          type: array
          items:
            $ref: '#/components/schemas/JournalLines'
          nullable: true
          description: Array of Journal Entry Line items associated with the journal entry
        raw_data:
          nullable: true
          description: >-
            A JSON containing fields that you can directly pass to the
            accounting platform.
      allOf:
        - $ref: >-
            #/components/schemas/accountingtypesJournalEntriesAllResponsesCommonFields
    accountingtypesFinalCreateJournalEntryResponse:
      title: accountingtypesFinalCreateJournalEntryResponse
      type: object
      properties:
        data:
          $ref: '#/components/schemas/accountingtypesCreateJournalEntryResponseData'
      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
    JournalLines:
      title: JournalLines
      type: object
      properties:
        account_id:
          type: string
          description: The ID of the account in the accounting platform
        type:
          $ref: '#/components/schemas/JournalLineType'
          description: The type of the journal line
        net_amount:
          type: number
          format: double
          description: The net amount of the journal line
        contact_id:
          type: string
          nullable: true
          description: The ID of the contact in the accounting platform
        tax_id:
          type: string
          nullable: true
          description: The ID of the tax in the accounting platform
        tracking_category_ids:
          type: array
          items:
            type: string
          nullable: true
          description: The IDs of the tracking categories in the accounting platform
        description:
          type: string
          nullable: true
          description: The description of the journal line
        raw_data:
          nullable: true
          description: >-
            A JSON containing fields that you can directly pass to the
            accounting platform.
      required:
        - account_id
        - type
        - net_amount
    accountingtypesJournalEntriesAllResponsesCommonFields:
      title: accountingtypesJournalEntriesAllResponsesCommonFields
      type: object
      properties:
        account_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique ID for the account associated with
            the journal entry
        currency_id:
          type: string
          nullable: true
          description: The ISO-4217 currency code
        document_number:
          type: string
          nullable: true
          description: Reference number for the journal entry
        description:
          type: string
          nullable: true
          description: Memo description of the journal entry
        posted_date:
          type: string
          nullable: true
          description: Date of creation of the journal entry
    accountingtypesCreateJournalEntryResponseData:
      title: accountingtypesCreateJournalEntryResponseData
      type: object
      properties:
        data:
          type: array
          items:
            $ref: >-
              #/components/schemas/accountingtypesCreateJournalEntriesResponseData
      required:
        - data
      allOf:
        - $ref: '#/components/schemas/SuccessResponse'
    JournalLineType:
      title: JournalLineType
      type: string
      enum:
        - DEBIT
        - CREDIT
    accountingtypesCreateJournalEntriesResponseData:
      title: accountingtypesCreateJournalEntriesResponseData
      type: object
      properties:
        response:
          $ref: >-
            #/components/schemas/accountingtypesJournalEntriesWriteResponseFields
        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
    accountingtypesJournalEntriesWriteResponseFields:
      title: accountingtypesJournalEntriesWriteResponseFields
      type: object
      properties:
        journal_lines:
          type: array
          items:
            $ref: '#/components/schemas/JournalLinesDataa'
          nullable: true
          description: Array of Journal Entry Line items associated with the journal entry
        raw_data:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            The raw JSON response we receive from the accounting platform for
            this journal entry
      allOf:
        - $ref: '#/components/schemas/accountingtypesJoyrnalLinesResponseFields'
    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
    JournalLinesDataa:
      title: JournalLinesDataa
      type: object
      properties:
        platform_id:
          type: string
          description: The accounting Platform’s ID for this journal line
        journal_entry_id:
          type: string
          description: The accounting Platform’s ID for this journal entry
        account_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique ID for the account associated with
            the journal line
        contact_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique ID for the contact associated with
            the journal line
        tax_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique ID for the tax associated with the
            journal line
        tracking_category_ids:
          type: array
          items:
            type: string
          nullable: true
          description: >-
            The accounting platform’s unique ID for the tracking category
            associated with the journal line
        type:
          $ref: '#/components/schemas/JournalLineType'
          nullable: true
          description: Type of the journal line. Values are `credit`, `debit`, `unknown`.
        description:
          type: string
          nullable: true
          description: Description of the journal line
        net_amount:
          type: number
          format: double
          description: The net amount of the journal line
        tax_amount:
          type: number
          format: double
          nullable: true
          description: The tax amount of the journal line
        updated_at:
          type: string
          format: date-time
          nullable: true
          description: The last ISO 8601 timestamp that the data was updated at
        raw_data:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            A JSON containing fields that you can directly pass to the
            accounting platform.
      required:
        - platform_id
        - journal_entry_id
        - net_amount
    accountingtypesJoyrnalLinesResponseFields:
      title: accountingtypesJoyrnalLinesResponseFields
      type: object
      properties:
        amount:
          type: integer
          nullable: true
          description: The total amount of the journal entry
        currency_rate:
          type: integer
          nullable: true
          description: Rate between the currency of the payment and the base currency
        journal_entry_type:
          type: string
          nullable: true
          description: Type of the journal entry
        updated_at:
          type: string
          nullable: true
          description: >-
            The date at which the information was updated on the accounting
            platform
      allOf:
        - $ref: '#/components/schemas/accountingtypesJournalEntriesPlatformId'
        - $ref: >-
            #/components/schemas/accountingtypesJournalEntriesAllResponsesCommonFields
    JobResponseStatus:
      title: JobResponseStatus
      type: string
      enum:
        - success
        - failed
    accountingtypesJournalEntriesPlatformId:
      title: accountingtypesJournalEntriesPlatformId
      type: object
      properties:
        platform_id:
          type: string
          description: >-
            The ID that the accounting platform uses to identify this journal
            entry
      required:
        - platform_id
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api_key

````