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

> Create a new Expense.

**Expenses** are Payment made by a business at the time of purchase (ex. a credit card payment)


## OpenAPI

````yaml POST /accounting/expenses
openapi: 3.0.1
info:
  title: rootfi
  version: v2
servers:
  - url: https://api.rootfi.dev
    description: Production
security: []
paths:
  /accounting/expenses:
    post:
      tags:
        - AccountingExpenses
      summary: Create an expense
      description: Add an expense.
      operationId: accounting_expenses_create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/accountingtypesCreateExpensesRequest'
            examples:
              Example1:
                value:
                  company_id: 1
                  data:
                    - document_number: ROOTFI01
                      payment_mode: CASH
                      posted_date: '2021-09-28T15:00:00.000Z'
                      currency_id: GBP
                      memo: Test Invoice
                      account_id: '123456'
                      contact_id: '123456'
                      line_items:
                        - account_id: '123456'
                          quantity: 1
                          item_id: '123456'
                          tax_id: '123456'
                          unit_amount: 100
                          total_discount: 0
                          description: Test Item
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/accountingtypesCreateExpensesResponse'
              examples:
                Example1:
                  value:
                    data:
                      status: SUCCESS
                      upload_job_id: aXI9pUDA5T7E2LS
                      data:
                        - job_id: xQm2K441VosP8W4
                          status: success
                          response:
                            platform_id: '3770712000001676061'
                            account_id: '3770712000000076064'
                            contact_id: '3770712000000418001'
                            currency_id: '3770712000000000099'
                            document_number: A-123
                            tax_amount: 0
                            posted_date: '2023-06-03T00:00:00.000Z'
                            memo: Test Invoice
                            currency_rate: 12
                            total_amount: 4032
                            sub_total: 40
                            updated_at: '2023-11-01T00: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:
    accountingtypesCreateExpensesRequest:
      title: accountingtypesCreateExpensesRequest
      type: object
      properties:
        company_id:
          type: integer
          example: 1
        data:
          type: array
          items:
            $ref: '#/components/schemas/accountingtypesExpensesWriteRequest'
      required:
        - company_id
        - data
    accountingtypesCreateExpensesResponse:
      title: accountingtypesCreateExpensesResponse
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/accountingtypesFinalCreateExpensesResponse'
        - $ref: '#/components/schemas/timestamp'
    accountingtypesExpensesWriteRequest:
      title: accountingtypesExpensesWriteRequest
      type: object
      properties:
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/LineItems'
          nullable: true
          description: Array of Expense Line items associated with the expense
        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/accountingtypesExpensesAllresponsesCommonFields'
    accountingtypesFinalCreateExpensesResponse:
      title: accountingtypesFinalCreateExpensesResponse
      type: object
      properties:
        data:
          $ref: '#/components/schemas/accountingtypesCreateExpensesResponseData'
      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
    LineItems:
      title: LineItems
      type: object
      properties:
        account_id:
          type: string
          nullable: true
          description: The ID of the account in the accounting platform
        quantity:
          type: number
          format: double
          nullable: true
          description: The quantity of the item
        item_id:
          type: string
          nullable: true
          description: The ID of the item in the accounting platform
        tax_id:
          type: string
          nullable: true
          description: The ID of the tax in the accounting platform
        unit_amount:
          type: number
          format: double
          nullable: true
          description: The unit amount of the item
        total_discount:
          type: number
          format: double
          nullable: true
          description: The total discount on the item
        description:
          type: string
          nullable: true
          description: The description of the item
        tracking_category_ids:
          type: array
          items:
            type: string
          nullable: true
          description: The IDs of the tracking categories in the accounting platform
    accountingtypesExpensesAllresponsesCommonFields:
      title: accountingtypesExpensesAllresponsesCommonFields
      type: object
      properties:
        account_id:
          type: string
          nullable: true
          description: Account ID of the expense
        contact_id:
          type: string
          nullable: true
          description: Contact ID of the expense
        currency_id:
          type: string
          nullable: true
          description: Currency ID of the expense
        document_number:
          type: string
          nullable: true
          description: Reference number for the expense
        payment_mode:
          type: string
          nullable: true
          description: Payment mode of the expense
        posted_date:
          type: string
          nullable: true
          description: Date of creation of the expense
        memo:
          type: string
          nullable: true
          description: Memo description of the expense
    accountingtypesCreateExpensesResponseData:
      title: accountingtypesCreateExpensesResponseData
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/accountingtypesExpensesResponse'
      required:
        - data
      allOf:
        - $ref: '#/components/schemas/SuccessResponse'
    accountingtypesExpensesResponse:
      title: accountingtypesExpensesResponse
      type: object
      properties:
        response:
          $ref: '#/components/schemas/accountingtypesExpensesWriteResponseFields'
        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
    accountingtypesExpensesWriteResponseFields:
      title: accountingtypesExpensesWriteResponseFields
      type: object
      properties:
        raw_data:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            The raw JSON response we get from the accounting platform for that
            data
      allOf:
        - $ref: '#/components/schemas/accountingtypesExpensesResponseField'
    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
    accountingtypesExpensesResponseField:
      title: accountingtypesExpensesResponseField
      type: object
      properties:
        tax_amount:
          type: number
          format: double
          nullable: true
          description: Total tax amount levied on the expense
        currency_rate:
          type: number
          format: double
          nullable: true
          description: Rate between the currency of the payment and the base currency
        total_amount:
          type: number
          format: double
          nullable: true
          description: Total value of the expense
        sub_total:
          type: number
          format: double
          nullable: true
          description: Total pre tax value of the expense
        updated_at:
          type: string
          nullable: true
          description: The date at which the expense was updated on the accounting platform
      allOf:
        - $ref: '#/components/schemas/accountingtypesExpensesPlatformId'
        - $ref: '#/components/schemas/accountingtypesExpensesAllresponsesCommonFields'
    JobResponseStatus:
      title: JobResponseStatus
      type: string
      enum:
        - success
        - failed
    accountingtypesExpensesPlatformId:
      title: accountingtypesExpensesPlatformId
      type: object
      properties:
        platform_id:
          type: string
          description: The ID that the accounting platform uses to identify this expense
      required:
        - platform_id
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api_key

````