# タスクの複製

`POST /api/task/{taskId}/duplicate`

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

タスクと、その下のサブタスクを複製します。コメントと添付ファイルは複製されません。

## パラメーター

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

## リクエストボディ

| name | in | type | required | description |
| --- | --- | --- | --- | --- |
| `copyToProjectId` | body | integer \| null |  | 複製先のプロジェクトの ID です。省略するか `null` にすると同じプロジェクトに複製します。別のプロジェクトに複製する場合、ステータスとマイルストーンは引き継がれません。 |
| `prefix` | body | string |  | 複製したタスク名の先頭に付ける文字列です (例: `コピー: `)。省略すると何も付けません。 |
| `suffix` | body | string |  | 複製したタスク名の末尾に付ける文字列です。省略すると何も付けません。 |
| `startDate` | body | integer \| null |  | 複製後の開始日です (Unix ミリ秒)。複製するタスクの中で最も早い日付がこの日になり、ほかの日付も同じ日数ぶんずれます。`inherit.dueDate` が `true` のときだけ使われます。 |
| `inherit` | body | object |  | 元のタスクのどの項目を複製に引き継ぐかを指定します。`true` にしていない項目は空になります。 |

## リクエスト

```sh
curl -X POST "https://<space>.repsona.com/api/task/{taskId}/duplicate" \
  -H "Authorization: Bearer $REPSONA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "copyToProjectId": null,
    "prefix": "Copy of ",
    "suffix": "",
    "startDate": 1796083200000,
    "inherit": {
      "priority": true,
      "tag": true,
      "responsibleUser": true,
      "ballHoldingUser": true,
      "status": true,
      "dueDate": true,
      "milestone": true
    }
  }'
```

## レスポンス

- 200: Duplicated tasks
- 400: Invalid body
- 401: Authentication is required
- 403: Not a project member
- 404: Task not found

## レスポンスの例

```json
{
  "tasks": [
    {
      "id": 100450,
      "parentId": null,
      "projectId": 296,
      "responsibleUserId": 1127,
      "ballHoldingUserId": null,
      "statusId": 195,
      "milestoneId": null,
      "sortOrder": 1024,
      "statusBoardSortOrder": null,
      "priorityBoardSortOrder": null,
      "responsibleUserBoardSortOrder": null,
      "ballHoldingUserBoardSortOrder": null,
      "milestoneBoardSortOrder": null,
      "name": "Copy of Publish the new homepage",
      "planned": null,
      "actual": null,
      "priority": null,
      "extra": null,
      "startDate": null,
      "dueDate": 1796083200000,
      "createdAt": 1793662651372,
      "updatedAt": 1793662651372,
      "deletedAt": null,
      "tagIds": [
        90,
        91
      ]
    }
  ]
}
```
