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

# Update task by ID

> Completely updates a task by replacing all fields with the provided data. This endpoint requires a complete representation of the task object.



## OpenAPI

````yaml /openapi/public/openapi-task.json put /task/{taskid}
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)**
paths:
  /task/{taskid}:
    put:
      tags:
        - Task
      summary: Update task by ID
      description: >-
        Completely updates a task by replacing all fields with the provided
        data. This endpoint requires a complete representation of the task
        object.
      operationId: PutTask
      parameters:
        - name: taskId
          in: path
          required: true
          description: |-
            Unique identifier for the task that generated by system.
            **Example**: `6352736c628401059b37a2e2`
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/putRequestTask'
        required: true
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                title: NetworkCreateResponse
                properties:
                  status:
                    type: boolean
                    description: Status of response.
                  message:
                    description: Message of API response.
                    type: string
                  task:
                    description: Detail of object task.
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  task:
                    _id: 6352736c628401059b37a2e2
                    flow: Visit
                    hubId: 634e98498ce07d29474a7e29
                    startTime: '2022-11-02T07:28:23+00:00'
                    organizationId: 634e98098ce07d29474a7e22
                    status: UNASSIGNED
                    hub:
                      _id: 634e98498ce07d29474a7e29
                      name: Jakarta
                      lat: -6.205154152722965
                      lng: 106.84667067970608
                    orderIndex: 10
                    field1: John Birdy
                    field2: Gambir Jakarta
                    field3: '-6.230815251,106.75684387'
                    createdFrom: API
                    endTime: '2022-11-05T07:28:23+00:00'
                    createdBy: Roger
                    updatedTime: '2022-11-01T07:28:23+00:00'
                    createdTime: '2022-11-01T07:28:23+00:00'
        '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.
        '404':
          description: Data not found
          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: Data not found
        '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:
    putRequestTask:
      title: putRequestTask
      example:
        flow: Visit
        hubId: 634e98498ce07d29474a7e29
        field1: John Birdy
        field2: Gambir Jakarta
        field3: '-6.230815251,106.75684387'
        startTime: '2022-11-02T07:28:23+00:00'
        endTime: '2022-11-05T07:28:23+00:00'
      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:** `John Birdy`
        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
      required:
        - flow
        - hubId
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````