> ## 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 Document

> Create a new Document.

**The Documents Data Model** simplifies the handling of document documents across various accounting platforms, providing a standardised approach to accessing and managing document-related information.

To Upload a file using Node JS SDK, you can use the following code:

```typescript theme={null}
import { RootFiClient } from "rootfi-api";

const rootfi = new RootFiClient({ apiKey: "*****" });
await rootfi.accounting.documents.create(fs.createReadStream("./helpers/test_img.png"), {
  companyId: 12,
  documentType: "BILLS",
  documentTypeId: "3770712000000689685",
});
```


## OpenAPI

````yaml POST /accounting/documents
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/documents:
    post:
      tags:
        - AccountingDocuments
      summary: Create Document
      description: Create a new Document.
      operationId: accounting_documents_create
      parameters: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                company_id:
                  description: The company ID of the document
                  type: integer
                document_type_id:
                  type: string
                  nullable: true
                  description: The document type ID of the document
                document_type:
                  $ref: '#/components/schemas/AccountingLineItemtype'
                  description: The document type of the document
                base64_file:
                  description: The base64 file of the document
                  type: string
                  nullable: true
                file_name:
                  type: string
                  nullable: true
                  description: The file name of the document
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accountingCreateDocumentResponse'
        '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:
    AccountingLineItemtype:
      title: AccountingLineItemtype
      type: string
      enum:
        - BILLS
        - INVOICES
        - BILL_CREDIT_NOTES
        - INVOICE_CREDIT_NOTES
        - EXPENSES
        - PURCHASE_ORDERS
        - SALES_ORDERS
    accountingCreateDocumentResponse:
      title: accountingCreateDocumentResponse
      type: object
      properties:
        data:
          $ref: '#/components/schemas/accountingDocumentObject'
          nullable: true
          description: The data of the created document
        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
    accountingDocumentObject:
      title: accountingDocumentObject
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/AccountingRootFiBaseFields'
        - $ref: '#/components/schemas/accountingDocumentFields'
    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
    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
    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
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api_key

````