> ## 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 Sales Orders

> Create a new Sales Orders.

A **Sales order** is a record of goods or services sold to a customer

## Additional Required Fields

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

| Integration    | Field         | Description                              |
| -------------- | ------------- | ---------------------------------------- |
| MYOB\_BUSINESS | tax\_code     | The tax code for the sales order         |
| QOYOD          | quotation\_no | The quotation number for the sales order |
| QOYOD          | expiry\_date  | The expiry date of the quotation         |
| QOYOD          | inventory\_id | The inventory id of the sales order      |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.rootfi.dev/v3/accounting/sales_orders \
    --header 'Content-Type: application/json' \
    --header 'api_key: <api-key>' \
    --data '{
    "company_id": 1,
    "data": [
      {
        "contact_id": "123456",
        "document_number": "ROOTFI01",
        "posted_date": "2021-09-28T15:00:00.000Z",
        "delivery_date": "2021-09-28T15:00:00.000Z",
        "currency_id": "GBP",
        "invoice_ids": [],
        "line_items": [
          {
            "account_id": "123456",
            "quantity": 1,
            "item_id": "123456",
            "tax_id": "123456",
            "unit_amount": 100,
            "total_discount": 0,
            "description": "Test Item"
          }
        ]
      }
    ]
  }'
  ```

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

  await rootfi.accounting.salesOrder.create({
    company_id: 1,
    data: [
      {
        contact_id: "123456",
        document_number: "ROOTFI01",
        posted_date: "2021-09-28T15:00:00.000Z",
        delivery_date: "2021-09-28T15:00:00.000Z",
        currency_id: "GBP",
        invoice_ids: [],
        line_items: [
          {
            account_id: "123456",
            quantity: 1,
            item_id: "123456",
            tax_id: "123456",
            unit_amount: 100,
            total_discount: 0,
            description: "Test Item",
          },
        ],
      },
    ],
  });
  ```
</RequestExample>


## OpenAPI

````yaml POST /accounting/sales_orders
openapi: 3.0.1
info:
  title: rootfi
  version: v2
servers:
  - url: https://api.rootfi.dev
    description: Production
security: []
paths:
  /accounting/sales_orders:
    post:
      tags:
        - AccountingSalesOrder
      summary: Create Sales Order
      description: Add a sales order.
      operationId: accounting_salesOrder_create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/accountingtypesCreateSalesOrderRequest'
            examples:
              Example1:
                value:
                  company_id: 1
                  data:
                    - contact_id: '123456'
                      document_number: ROOTFI01
                      posted_date: '2021-09-28T15:00:00.000Z'
                      delivery_date: '2021-09-28T15:00:00.000Z'
                      currency_id: GBP
                      invoice_ids: []
                      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/accountingtypesCreateSalesOrderResponse'
              examples:
                Example1:
                  value:
                    data:
                      status: SUCCESS
                      upload_job_id: aXI9pUDA5T7E2LS
                      data:
                        - job_id: xQm2K441VosP8W4
                          status: success
                          response:
                            platform_id: '3770712000001652001'
                            contact_id: '3770712000000080863'
                            invoice_ids:
                              - '3770712000000000099'
                            currency_id: '3770712000000000099'
                            document_number: PO-00073
                            posted_date: '2023-04-01T00:00:00.000Z'
                            delivery_date: '2023-05-01T00:00:00.000Z'
                            description: Test Invoice
                            currency_rate: 12
                            status: SUBMITTED
                            total_amount: 21.28
                            sub_total: 19
                            tax_amount: 2.28
                            total_discount: 0
                            updated_at: '2023-10-28T00:00:00.000Z'
                            raw_data:
                              platform_id: '1013'
                              name: Test
                              contact_name: Test
                              contact_type: CUSTOMER
                              currency_id: '1'
                              status: ARCHIVED
                          error: null
                    request_timestamp: '2023-10-27T05:05:28.522Z'
                    response_timestamp: '2021-09-28T15:00:00.000Z'
                    request_id: 7a1c0e42-9f85-4d6e-bb5d-358a72913c0b
      security:
        - ApiKeyAuth: []
components:
  schemas:
    accountingtypesCreateSalesOrderRequest:
      title: accountingtypesCreateSalesOrderRequest
      type: object
      properties:
        company_id:
          type: integer
          example: 1
        data:
          type: array
          items:
            $ref: '#/components/schemas/accountingtypesSalesOrderWriteRequest'
      required:
        - company_id
        - data
    accountingtypesCreateSalesOrderResponse:
      title: accountingtypesCreateSalesOrderResponse
      type: object
      properties: {}
      allOf:
        - $ref: '#/components/schemas/accountingtypesFinalCreateSalesOrderResponse'
        - $ref: '#/components/schemas/timestamp'
    accountingtypesSalesOrderWriteRequest:
      title: accountingtypesSalesOrderWriteRequest
      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.
        line_items:
          type: array
          items:
            $ref: '#/components/schemas/LineItems'
          nullable: true
          description: Array of Sales Order Line items associated with the sales order
      allOf:
        - $ref: >-
            #/components/schemas/accountingtypesSalesOrderAllResponseCommonFields
    accountingtypesFinalCreateSalesOrderResponse:
      title: accountingtypesFinalCreateSalesOrderResponse
      type: object
      properties:
        data:
          $ref: '#/components/schemas/accountingtypesCreateSalesOrderResponseData'
      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
    accountingtypesSalesOrderAllResponseCommonFields:
      title: accountingtypesSalesOrderAllResponseCommonFields
      type: object
      properties:
        contact_id:
          type: string
          nullable: true
          description: >-
            The accounting platform’s unique ID of the contact associated with
            this sales order
        invoice_ids:
          type: array
          items:
            type: string
          nullable: true
          description: Array of Invoices associated with the sales order
        currency_id:
          type: string
          nullable: true
          description: Currency ID of the sales order
        document_number:
          type: string
          nullable: true
          description: Reference number for the sales order
        posted_date:
          type: string
          nullable: true
          description: Date of creation of the sales order
        delivery_date:
          type: string
          nullable: true
          description: The delivery date for the sales order
        description:
          type: string
          nullable: true
          description: Description of the sales order
    accountingtypesCreateSalesOrderResponseData:
      title: accountingtypesCreateSalesOrderResponseData
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/accountingtypesSalesOrderResponse'
      required:
        - data
      allOf:
        - $ref: '#/components/schemas/SuccessResponse'
    accountingtypesSalesOrderResponse:
      title: accountingtypesSalesOrderResponse
      type: object
      properties:
        response:
          $ref: '#/components/schemas/accountingtypesSalesOrderWriteResponseFields'
        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
    accountingtypesSalesOrderWriteResponseFields:
      title: accountingtypesSalesOrderWriteResponseFields
      type: object
      properties:
        raw_data:
          type: object
          additionalProperties: true
          nullable: true
          description: >-
            The raw JSON response we receive from the accounting platform for
            this sales order
      allOf:
        - $ref: '#/components/schemas/accountingtypesSalesOrderResponseObject'
    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
    accountingtypesSalesOrderResponseObject:
      title: accountingtypesSalesOrderResponseObject
      type: object
      properties:
        currency_rate:
          type: number
          format: double
          nullable: true
          description: Rate between the currency of the sales order and the base currency
        status:
          $ref: '#/components/schemas/ArtifactStatus'
          nullable: true
          description: The status of the sales order.
        total_amount:
          type: number
          format: double
          nullable: true
          description: The total value of the sales order
        sub_total:
          type: number
          format: double
          nullable: true
          description: The total pre-tax value of the sales order
        tax_amount:
          type: number
          format: double
          nullable: true
          description: The total tax amount levied on the sales order
        total_discount:
          type: number
          format: double
          nullable: true
          description: The total value of discounts applied to the sales order
        updated_at:
          type: string
          nullable: true
          description: >-
            The date at which the information was updated on the accounting
            platform
      allOf:
        - $ref: '#/components/schemas/accountingtypesSalesOrderPlatformId'
        - $ref: >-
            #/components/schemas/accountingtypesSalesOrderAllResponseCommonFields
    JobResponseStatus:
      title: JobResponseStatus
      type: string
      enum:
        - success
        - failed
    ArtifactStatus:
      title: ArtifactStatus
      type: string
      enum:
        - DRAFT
        - SUBMITTED
        - PARTIALLY_PAID
        - PAID
        - OVERDUE
        - VOID
        - UNKNOWN
    accountingtypesSalesOrderPlatformId:
      title: accountingtypesSalesOrderPlatformId
      type: object
      properties:
        platform_id:
          type: string
          description: >-
            The ID that the accounting platform uses to identify this sales
            order
      required:
        - platform_id
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api_key

````