---
updatedAt: 2026-05-27T10:18:53.000Z
agentTools:
  projectIndex: https://gethapn.readme.io/llms.txt
---

# Updates a task

Updates a task.


# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "description": "The Hapn API is an HTTP interface for managing devices, accounts, and cloud data.",
    "version": "1.0.0",
    "title": "Hapn API",
    "termsOfService": "https://gethapn.com/terms",
    "contact": {
      "name": "Dev",
      "email": "developer@gethapn.com",
      "url": "http://gethapn.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    }
  },
  "servers": [
    {
      "url": "https://api.iotgps.io/v1",
      "description": "Prod"
    },
    {
      "url": "https://api-dev.iotgps.io/v1",
      "description": "Dev"
    }
  ],
  "paths": {
    "/tasks/{taskId}": {
      "put": {
        "summary": "Updates a task",
        "tags": [
          "Tasks"
        ],
        "operationId": "update-task",
        "description": "Updates a task.\n",
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "description": "The task id",
            "schema": {
              "type": "number"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "x-examples": {
                  "example-1": {
                    "dueDate": "2022-01-02T17:44:02.000Z",
                    "dueOdometer": 1000,
                    "dueActiveHours": 100,
                    "startDate": "2022-01-02T17:44:02.000Z",
                    "startingOdometer": 1000,
                    "startingActiveHours": 100
                  }
                },
                "properties": {
                  "dueDate": {
                    "type": "string"
                  },
                  "dueOdometer": {
                    "type": "number"
                  },
                  "dueActiveHours": {
                    "type": "number"
                  },
                  "startDate": {
                    "type": "string"
                  },
                  "startingOdometer": {
                    "type": "number"
                  },
                  "startingActiveHours": {
                    "type": "number"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task updated",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/SuccessResponse"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "result": {
                          "$ref": "#/components/schemas/Task"
                        }
                      }
                    }
                  ]
                },
                "examples": {
                  "example-1": {
                    "value": {
                      "success": true,
                      "message": "ok",
                      "result": {
                        "id": 1,
                        "taskScheduleId": 1,
                        "imei": "868239050345326",
                        "clientId": 123,
                        "dueDate": "2022-01-02T17:44:02.000Z",
                        "dueOdometer": 1000,
                        "dueActiveHours": 100,
                        "startDate": "2022-01-02T17:44:02.000Z",
                        "startingOdometer": 1000,
                        "startingActiveHours": 100,
                        "createdAt": "2022-01-02T17:44:02.000Z",
                        "modifiedBy": "user",
                        "modifiedAt": "2022-01-02T17:44:02.000Z",
                        "deletedBy": "user",
                        "deletedAt": "2022-01-02T17:44:02.000Z",
                        "pastDueAt": "2022-01-02T17:44:02.000Z",
                        "completedBy": "user",
                        "completedAt": "2022-01-02T17:44:02.000Z",
                        "completionNotes": "Task completion notes",
                        "completionOdometer": 1000,
                        "completionActiveHours": 100,
                        "queuedAt": "2022-01-02T17:44:02.000Z",
                        "predictedDueDate": "2022-01-02T17:44:02.000Z",
                        "status": "deleted"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/TaskNotFound"
          },
          "500": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "SuccessResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "result": {
            "type": "object"
          }
        },
        "required": [
          "message",
          "success"
        ],
        "x-examples": {
          "example-1": {
            "value": {
              "success": true,
              "message": "ok",
              "result": {
                "imei": "12345"
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "success",
          "message"
        ],
        "x-examples": {
          "example-1": {
            "value": {
              "success": false,
              "message": "Unauthorized"
            }
          }
        }
      },
      "Task": {
        "title": "Task",
        "description": "A task",
        "type": "object",
        "x-examples": {
          "example-1": {
            "id": 1,
            "taskScheduleId": 1,
            "imei": "868239050345326",
            "clientId": 123,
            "dueDate": "2022-01-02T17:44:02.000Z",
            "dueOdometer": 1000,
            "dueActiveHours": 100,
            "startDate": "2022-01-02T17:44:02.000Z",
            "startingOdometer": 1000,
            "startingActiveHours": 100,
            "createdAt": "2022-01-02T17:44:02.000Z",
            "modifiedBy": "user",
            "modifiedAt": "2022-01-02T17:44:02.000Z",
            "deletedBy": "user",
            "deletedAt": "2022-01-02T17:44:02.000Z",
            "pastDueAt": "2022-01-02T17:44:02.000Z",
            "completedBy": "user",
            "completedAt": "2022-01-02T17:44:02.000Z",
            "completionNotes": "Task completion notes",
            "completionOdometer": 1000,
            "completionActiveHours": 100,
            "queuedAt": "2022-01-02T17:44:02.000Z",
            "predictedDueDate": "2022-01-02T17:44:02.000Z",
            "status": "deleted"
          }
        },
        "properties": {
          "id": {
            "type": "number",
            "description": "The task identifier"
          },
          "taskScheduleId": {
            "type": "number",
            "description": "The task schedule identifier"
          },
          "imei": {
            "type": "string",
            "description": "The device identifier"
          },
          "clientId": {
            "type": "number",
            "description": "The client identifier"
          },
          "dueDate": {
            "type": "string",
            "description": "Date the task is due. If specified, after this date, the task is past due"
          },
          "dueOdometer": {
            "type": "number",
            "description": "Odometer number that makes the task past due (in km). If specified and device odometer greater or equal, the task is past due."
          },
          "dueActiveHours": {
            "type": "number",
            "description": "Hours of operation that make the task due. If specified and device active hours greater or equal, the task is past due."
          },
          "startDate": {
            "type": "string",
            "description": "If present, task status does not change before this date"
          },
          "startingOdometer": {
            "type": "number",
            "description": "If present, task status does not change until odomoter has reached this number (km)"
          },
          "startingActiveHours": {
            "type": "number",
            "description": "If present, task status does not change until the active hours have reached this number"
          },
          "createdAt": {
            "type": "string",
            "description": "The task creation date"
          },
          "modifiedBy": {
            "type": "string",
            "description": "The task last modifier"
          },
          "modifiedAt": {
            "type": "string",
            "description": "The task modification date"
          },
          "deletedBy": {
            "type": "string",
            "description": "The task deleter"
          },
          "deletedAt": {
            "type": "string",
            "description": "The task deletion date"
          },
          "completedBy": {
            "type": "string",
            "description": "The task completer"
          },
          "completedAt": {
            "type": "string",
            "description": "The task completion date"
          },
          "completionNotes": {
            "type": "string",
            "description": "Notes collected at the time the task was completed"
          },
          "completionOdometer": {
            "type": "number",
            "description": "Odometer recorded at the time the task was completed (in km)"
          },
          "completionActiveHours": {
            "type": "number",
            "description": "Acti"
          },
          "pastDueAt": {
            "type": "string",
            "description": "The date the task was past due"
          },
          "predictedDueDate": {
            "type": "string",
            "description": "For tasks with active hours and odometer criterias, the date we predict the task will become past due using a linear regression"
          },
          "queuedAt": {
            "type": "string",
            "description": "The time this task was queued to be evaluated, this value is null if the task is not queued to be evaluated"
          },
          "status": {
            "type": "string",
            "description": "The task status",
            "enum": [
              "pending",
              "past_due",
              "completed",
              "deleted"
            ]
          }
        },
        "required": [
          "id",
          "taskScheduleId",
          "clientId",
          "imei"
        ]
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "example-1": {
                "value": {
                  "success": false,
                  "message": "Unauthorized"
                }
              }
            }
          }
        }
      },
      "Error": {
        "description": "Server error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "example-1": {
                "value": {
                  "success": false,
                  "message": "Error"
                }
              }
            }
          }
        }
      },
      "TaskNotFound": {
        "description": "The specified resource was not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "examples": {
              "example-1": {
                "value": {
                  "success": false,
                  "message": "Task not found"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "OAuth2": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://auth.usehapn.com/oauth2/token",
            "scopes": {}
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Tasks",
      "description": "Maintenance tasks"
    }
  ],
  "security": [
    {
      "OAuth2": []
    }
  ]
}
```