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

# Create multiple tasks



## OpenAPI

````yaml /openapi/public/openapi-task.json post /tasks/bulk/
openapi: 3.0.0
info:
  title: MileApp API - Task
  version: 3.0.0
  description: MileApp API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: Task
    description: >-
      A task is an item of work intended for completion by an assignee. It can
      embody activities like pickups, deliveries, planning, inspections, sales
      visits, or other work-related actions within your organization. Tasks
      encompass essential attributes, including IDs, flow, time, status
      indicators, assignee information, order index, and other pertinent data.
      The content of a task is configurable based on your specified flow
      settings. For instance, tasks can serve as visits during the route
      optimization process, functioning as pivotal elements. The task can also
      represent a visit in route optimization, please follow [this
      link](#tag/Routing) to read more detail.


      **To see the details of task object, please follow [this
      link](#tag/task_model)**
  - name: Location History
    description: >-
      Location history is data that stores the user's location points that are
      sent periodically from the MileApp mobile application if the user
      activates the tracking feature. However, this endpoint can also be useful
      for integration into the user's IoT devices such as GPS or other mobile
      trackers. All location data sent can be visualized in MileApp in real time
      and makes it easier for users to monitor field activities more accurately.


      **Related Guide:** [Start Finish
      Feature](/configuration/start-trip-end-trip-feature)
  - name: Task Schedule
    description: >-
      Task Schedule is a mechanism to generate tasks according to the schedule
      that is set by you. The task schedule attributes consist of IDs,
      repetition period data (daily, weekly, etc.), flow structure, task
      content, and time of the schedule's start & end. This schedule could help
      you to set a task that will be repeated at a certain period.


      **To see the details of task schedule object, please follow [this
      link](#tag/task_schedule_model)**
  - name: Activity
    description: >-
      An Activity is a multi-step task group created from a Workflow template.
      When you create an Activity, MileApp automatically creates one parent task
      (with `taskType = activityMaster`) plus one child task (with `taskType =
      activityChild`) per Workflow step, and copies field values forward between
      steps according to the Workflow's field mappings. Activities are stored
      alongside regular tasks — the parent's `_id` is also the Activity ID, and
      its `subId` array lists every child task in Workflow-step order.


      After creation, retrieve, update, or delete an Activity through the
      standard Task endpoints using the Activity master task's ID.


      **To see the details of Activity object, please follow [this
      link](#tag/activity_model)**
paths:
  /tasks/bulk/:
    post:
      tags:
        - Task
      summary: Create multiple tasks
      operationId: PostTaskBulk
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/postBulkRequestTask'
        required: true
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                title: NetworkBulkCreateResponse
                properties:
                  success:
                    description: Total success created task.
                    type: integer
                  failed:
                    description: Total failed created task.
                    type: integer
                  tasks:
                    description: Detail of created task.
                    type: array
                    items:
                      type: object
                      properties:
                        status:
                          type: boolean
                          description: Status of response.
                        _id:
                          description: Task ID
                          type: string
                        message:
                          description: Message of create task
                          type: string
                        refId:
                          description: Reference id of create task
                          type: string
                example:
                  success: 2
                  failed: 0
                  tasks:
                    - status: true
                      message: Task has been created
                      _id: 62067ee1cd77000042006f89
                    - status: true
                      message: Task has been created
                      _id: 62067ee3cd77000042006f8b
                      refId: 66544e0855d2696d401d8252
        '400':
          description: Bad Request
          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:
  schemas:
    postBulkRequestTask:
      title: postBulkRequestTask
      example:
        background: false
        tasks:
          - flow: Visit
            hubId: 634e98498ce07d29474a7e29
            field1: Jack Ward
            field2: Gambir Jakarta
            field3: '-6.230815251,106.75684387'
            startTime: '2022-11-02T07:28:23+00:00'
            endTime: '2022-11-05T07:28:23+00:00'
          - flow: Visit
            hubId: 634e98498ce07d29474a7e29
            field1: John Birdy
            refId: 66544e0855d2696d401d8252
      type: object
      properties:
        background:
          type: boolean
          description: >-
            When the background parameter is set to `true` , the action will be
            processed in the background. In this mode, the API call will return
            quickly with a response indicating that the create task request has
            been received and is being processed asynchronously in the
            background. When the background parameter is set to `false`
            (default), the create task will be processed directly via API. This
            means that the API call will wait for the create task process to
            complete before returning the results to the user. 
             **Default:** `false`.
        tasks:
          type: array
          description: The maximum data for creating multiple tasks is 2000 data.
          items:
            type: object
            properties:
              flow:
                type: string
                description: >-
                  The unique name of organization's flow. Use [GET /flows
                  API](#tag/Flow/operation/getflow) to get the list of flow
                  names.

                  **Example:** `Visit`
              hubId:
                type: string
                description: >-
                  Fundamental entity within an organization, serving as the
                  central point for managing various operational components. Use
                  **GET /hubs** endpoint to get the list of Hub IDs.
                  **Example:** `634e98498ce07d29474a7e29`
              field1:
                type: string
                description: >-
                  This field's type & value is according to Flow's setting. Use
                  [GET /flow/{flowName}/task
                  API](#tag/Flow/operation/getCreateTaskPayload) to get example
                  of payload.

                  **Example:** `Jack Ward`
              field2:
                type: string
                description: >-
                  This field's type & value is according to Flow's setting. Use
                  [GET /flow/{flowName}/task
                  API](#tag/Flow/operation/getCreateTaskPayload) to get example
                  of payload.

                  **Example:** `Gambir Jakarta`
              field3:
                type: string
                description: >-
                  This field's type & value is according to Flow's setting. Use
                  [GET /flow/{flowName}/task
                  API](#tag/Flow/operation/getCreateTaskPayload) to get example
                  of payload.

                  **Example:** `-6.230815251,106.75684387`
              startTime:
                type: string
                format: date-time
                description: >-
                  Start time refers to the designated time for users to begin a
                  task. If `startTime` is not provided, it will default to the
                  configured time in the flow. You can view the datetime format
                  here.

                  **Example:** `2022-11-02T07:28:23+00:00`
              endTime:
                type: string
                format: date-time
                description: >-
                  End time is the deadline for completing a task. If `endTime`
                  is not specified, it will default to the configured time in
                  the flow.The task cannot be completed if the date has passed
                  the `endtime`. You can view the datetime format here

                  **Example:** `2022-11-05T07:28:23+00:00`
              assignee:
                type: array
                description: >-
                  You can assign tasks using user email according to their task
                  hub.  To assign tasks to multiple users, use a comma (',') as
                  a separator.

                  **Example:** `['leandro@mile.app']`
                items:
                  type: object
                  additionalProperties: true
              refId:
                type: string
                description: |-
                  You can add `refId` to return a value as a task reference .
                  **Example:** `66544e0855d2696d401d8252`
            required:
              - flow
              - hubId
      required:
        - tasks
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````