# タスクの更新

`PATCH /api/task/{taskId}`

URL: https://repsona.com/ja/api/patch-task-taskid

タスクの名前・担当者・期日・ステータスなどを更新します。

## パラメーター

| name | in | type | required | description |
| --- | --- | --- | --- | --- |
| `taskId` | path | integer | 必須 | タスクの ID です。 |

## リクエストボディ

| name | in | type | required | description |
| --- | --- | --- | --- | --- |
| `name` | body | string |  | タスク名です (1 から 255 文字)。 |
| `parentId` | body | integer \| null |  | 親タスクの ID です。`null` にすると最上位のタスクになります。 |
| `projectId` | body | integer |  | タスクが属するプロジェクトの ID です。 |
| `responsibleUserId` | body | integer \| null |  | 担当者のユーザー ID です。`null` にすると担当者なしになります。 |
| `ballHoldingUserId` | body | integer \| null |  | ボールを持っている人 (次に動く人) のユーザー ID です。`null` にすると誰も持っていない状態になります。 |
| `statusId` | body | integer \| null |  | ステータスの ID です。タスクのプロジェクトのステータスを指定します。`null` にするとステータスなしになります。 |
| `milestoneId` | body | integer \| null |  | マイルストーンの ID です。タスクのプロジェクトのマイルストーンを指定します。`null` にするとマイルストーンなしになります。 |
| `priority` | body | integer \| null |  | 優先度です。`1` が高、`2` が中、`3` が低です。`null` にすると優先度なしになります。 |
| `description` | body | string \| null |  | タスクの説明です (Markdown、20,000 文字まで)。`null` にすると空になります。 |
| `startDate` | body | number \| null |  | 開始日です (Unix ミリ秒)。`null` にすると未設定になります。 |
| `dueDate` | body | number \| null |  | 期日です (Unix ミリ秒)。`null` にすると未設定になります。 |
| `extra` | body | object \| null |  | 表示用の追加設定です。意味を持つのは `color` (`#8CC230` のような色の文字列、または `null`) だけです。 |
| `applyToOpenDescendants` | body | boolean |  | `true` にすると、完了していないサブタスク (ステータス未設定を含む) も新しい `statusId` にします。`statusId` と一緒に送ります。省略すると `false` です。 |

## リクエスト

```sh
curl -X PATCH "https://<space>.repsona.com/api/task/{taskId}" \
  -H "Authorization: Bearer $REPSONA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Write release notes for v2.0",
    "statusId": 196,
    "priority": 2,
    "dueDate": 1794614400000
  }'
```

## レスポンス

- 200: Task updated
- 400: Invalid request payload or move state
- 401: Authentication is required
- 404: Task not found

## レスポンスの例

```json
{
  "task": {
    "id": 100442,
    "parentId": null,
    "projectId": 296,
    "responsibleUserId": 1127,
    "ballHoldingUserId": 1127,
    "statusId": 196,
    "milestoneId": 38,
    "sortOrder": null,
    "statusBoardSortOrder": null,
    "priorityBoardSortOrder": null,
    "responsibleUserBoardSortOrder": null,
    "ballHoldingUserBoardSortOrder": null,
    "milestoneBoardSortOrder": null,
    "name": "Write release notes for v2.0",
    "planned": null,
    "actual": null,
    "priority": 2,
    "extra": null,
    "startDate": 1794182400000,
    "dueDate": 1794614400000,
    "createdAt": 1793662651065,
    "updatedAt": 1793662651113,
    "deletedAt": null,
    "tagIds": [
      90
    ]
  },
  "siblings": [],
  "bulk": false,
  "cascaded": null
}
```
