> ## Documentation Index
> Fetch the complete documentation index at: https://docsv4.mile.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Accurate sync rule

> Accurate (Accurate Online accounting) integration. Creates a sync rule. `direction` selects the kind.
**Push** (`module`: `delivery-order`): needs `flowId`, `businessDataId`, `fieldMappings`. A `create` rule must map every required Accurate field and name the Bill component in `lineItems.billComponentId`; an `update` rule needs `event` `onTaskFinished` and at least one mapping. One rule per flow + module + business data. An automation is created for it; when your automation quota is full the rule is saved with auto-sync off (`quotaReached: true`).
**Import** (`module`: `sales-order` or `delivery-order`): needs `flowId`, `targetHubId`, `businessDataId`; one rule per module + business data + flow.
A flow cannot have both a push-create rule and an import rule of the same module.
Validation errors return 422.
Requires permission `add/appIntegration`.



## OpenAPI

````yaml /openapi/public/openapi-setting.json post /integration/accurate/rules
openapi: 3.0.0
info:
  title: API - Setting
  version: 3.0.0
  description: API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: User
    description: >-
      User data includes information contained within a user account, such as
      details that define a user's hub access and role within the system. Hub
      access determines the locations or areas of the application a user can
      access or the specific actions they can perform. User attributes consist
      of the user ID, name, email, and status.


      The app provides five predefined user roles, and you can create custom
      roles based on your organization's needs. The predefined roles are
      **Owner, Admin, Planner, and Field user**. A user can only hold one role
      at a time but can be granted access to multiple hubs.
  - name: Team
    description: >-
      This API allows you to manage teams. It serves as a tool to effectively
      manage and restrict user task assignments within your organization.


      **To see the details of team object, please follow [this
      link](#tag/team_model)**
  - name: Role
    description: >-
      This API enables you to retrieve a list of predefined roles and any custom
      roles associated with your account. By making a GET request to this API,
      you can obtain information about the available roles within the system.
      The predefined roles refer to a set of role types that are already defined
      by the system. In this particular case, the predefined roles include
      Finance, Owner, Planner, Admin, and Field User. Additionally, the API may
      also return any custom roles that have been created within your account.


      **To see the details of role object, please follow [this
      link](#tag/role_model)**
  - name: Hub
    description: >-
      In our system, a Hub is a fundamental entity within an organization,
      serving as the central point for managing various operational components.
      It acts as the parent structure for a wide range of resources and
      functionalities, including tasks, visits, users, vehicles, routing
      results, routing configurations, and data sources.


      **To see the details of hub object, please follow [this
      link](#tag/hub_model)**


      ## Conceptual Understanding of Hubs


      - **User Perspective:** For users, a Hub represents their headquarters or
      primary working area. It is where they carry out their daily activities
      and manage their tasks effectively. Each user interacts with the Hub to
      access resources and perform operations specific to their roles.


      - **Task Perspective:** From the perspective of task management, the Hub
      signifies the working area for tasks. It is the location where tasks are
      initiated, monitored, and completed. The Hub facilitates organization and
      efficiency in task execution.


      - **Routing Perspective:** In the context of routing and logistics, a Hub
      serves as a critical location for vehicles. It is where vehicles begin
      their routes, return after completing their journeys, and may make
      strategic stops along the way. The routing module relies on the Hub to
      optimize vehicle assignments and manage routes effectively.
  - name: App Integration
    description: >-
      This API allows you to manage Integration of enterprise app. Currently
      available for Azure.


      **To see the details of integration object, please follow [this
      link](#tag/app_integration_model)**
  - name: Plugin
    description: >-
      The Plugin API allows developers to create and manage custom add-ons
      within the app. Plugins enable dynamic functionality through JavaScript
      resources and custom icons, allowing organizations to extend platform
      capabilities with custom features and integrations.


      **To see the details of plugin object, please follow [this
      link](#tag/plugin_model)**
  - name: Organization
    description: >-
      Organization management endpoints for configuring organization-level
      settings and preferences.
  - name: Addon
    description: Addon endpoints
  - name: Custom Module
    description: >-
      A "custom module" is like a personalized menu option in MileApp. It's
      something you can create and customize to make it easy to access specific
      features or content.
  - name: Password Policy
    description: >-
      Password Policy endpoints for configuring password requirements and
      security policies for your organization.
  - name: Trash
    description: >-
      Trash lists items that were deleted from your organization, so you can see
      what was removed and when.
paths:
  /integration/accurate/rules:
    post:
      tags:
        - App Integration
      summary: Create Accurate sync rule
      description: >-
        Accurate (Accurate Online accounting) integration. Creates a sync rule.
        `direction` selects the kind.

        **Push** (`module`: `delivery-order`): needs `flowId`, `businessDataId`,
        `fieldMappings`. A `create` rule must map every required Accurate field
        and name the Bill component in `lineItems.billComponentId`; an `update`
        rule needs `event` `onTaskFinished` and at least one mapping. One rule
        per flow + module + business data. An automation is created for it; when
        your automation quota is full the rule is saved with auto-sync off
        (`quotaReached: true`).

        **Import** (`module`: `sales-order` or `delivery-order`): needs
        `flowId`, `targetHubId`, `businessDataId`; one rule per module +
        business data + flow.

        A flow cannot have both a push-create rule and an import rule of the
        same module.

        Validation errors return 422.

        Requires permission `add/appIntegration`.
      operationId: createAccurateRule
      requestBody:
        $ref: '#/components/requestBodies/AccurateRuleRequest'
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                  data:
                    type: object
                    additionalProperties: true
                  quotaReached:
                    type: boolean
                    description: Push rules only.
                example:
                  status: true
                  data:
                    id: 3f6c2a1e-8b4d-4e0f-9a51-2c7d8e9f0a12
                    flowId: 625678f90fc8ba02bb5eb432
                    flowName: Delivery
                    module: delivery-order
                    event: onTaskFinished
                    action: create
                    businessDataId: '123456'
                    fieldMappings:
                      - accurateField: customerNo
                        source:
                          type: string
                          value: input1
                          dataType: string
                      - accurateField: transDate
                        source:
                          type: string
                          value: doneTime
                          dataType: date
                    lineItems:
                      billComponentId: bill1
                      rowMappings:
                        - accurateField: itemName
                          billField: name
                    automation:
                      id: 6710b0d1e4b0a91d2c3f6c33
                      valid: true
                      active: true
                  quotaReached: false
        '422':
          description: Unprocessable entity
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Bad request - invalid parameters provided.
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Internal server error, please contact support@mile.app.
      deprecated: false
      security:
        - bearerAuth: []
components:
  requestBodies:
    AccurateRuleRequest:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/AccurateRuleRequest'
      required: true
  schemas:
    AccurateRuleRequest:
      type: object
      properties:
        direction:
          type: string
          enum:
            - push
            - import
          description: Create only. Kind of rule.
        module:
          type: string
          description: |-
            Accurate module slug.
            **Example:** `delivery-order`
        flowId:
          type: string
          description: |-
            MileApp flow ID.
            **Example:** `625678f90fc8ba02bb5eb432`
        flowName:
          type: string
          description: |-
            Flow name, for display.
            **Example:** `Delivery`
        businessDataId:
          type: string
          description: |-
            Accurate business data (company) ID.
            **Example:** `123456`
        event:
          type: string
          description: |-
            Push only. Task event that triggers the push.
            **Default:** `onTaskFinished`
        action:
          type: string
          enum:
            - create
            - update
          description: >-
            Push only. `create` makes a new document; `update` edits the
            document the task came from.

            **Default:** `create`
        fieldMappings:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            Push only. `[{accurateField, source: {type:
            flow|task|constant|salesOrder, value, dataType}}]`.
        billComponentId:
          type: string
          description: Push only. Bill component ID (same as `lineItems.billComponentId`).
        targetHubId:
          type: string
          description: |-
            Import only. Hub of the created tasks.
            **Example:** `64d9932e2beb9037735ff022`
        headerMappings:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            Import only. `[{accurateField, target: {type: flow, value,
            dataType}}]`.
        lineItems:
          type: object
          description: >-
            Line items. Push: `{billComponentId, rowMappings: [{accurateField,
            billField}]}`. Import: `{targetListId, rowMappings: [{accurateField,
            rowField, dataType}]}`.
          additionalProperties: true
        autoCreateRemainderTask:
          type: boolean
          description: Import only.
      example:
        direction: push
        module: delivery-order
        flowId: 625678f90fc8ba02bb5eb432
        flowName: Delivery
        businessDataId: '123456'
        action: create
        event: onTaskFinished
        fieldMappings:
          - accurateField: customerNo
            source:
              type: string
              value: input1
              dataType: string
        lineItems:
          billComponentId: bill1
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.