# Change study plan tasks

Atomically add, edit, remove, or complete exact tasks in one plan. An edit may change an unstarted task's date, morning/afternoon/evening slot, duration, or selected contentRef; after a task starts, its resolved target remains fixed so completion cannot be attributed to different content. It does not change the plan title or goal.

- Capability ID: `study_plans.change_tasks`
- Operation: `ielts_study_plans_change_tasks`
- Category: 学习计划
- Endpoint: `POST /api/v1/agent/capabilities/ielts_study_plans_change_tasks`
- Authentication: Bearer Token（通过 /api/v1/agent-bindings 绑定账号）
- Required scopes: study_plans:write
- Side effect: write
- Human documentation: https://ieltsbuddy.igopx.cn/developers/api/ielts_study_plans_change_tasks

## Request parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `changes` | unknown[] | 是 | changes |
| `reason` | string | 是 | reason |
| `planId` | string | 是 | planId |

## Request example

```bash
curl -X POST \
  'https://work.ieltsbuddy.igopx.cn/api/v1/agent/capabilities/ielts_study_plans_change_tasks' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer $IELTS_BUDDY_TOKEN' \
  --data '{"changes":[],"reason":"<reason>","planId":"<planId>"}'
```

## Request schema

```json
{
  "type": "object",
  "properties": {
    "changes": {
      "minItems": 1,
      "maxItems": 90,
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "add"
              },
              "task": {
                "type": "object",
                "properties": {
                  "contentRef": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "question_part"
                          },
                          "partId": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "kind",
                          "partId"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "mock_paper"
                          },
                          "paperId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 160
                          }
                        },
                        "required": [
                          "kind",
                          "paperId"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "courseId": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          },
                          "kind": {
                            "type": "string",
                            "const": "course_section"
                          },
                          "sectionId": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "courseId",
                          "kind",
                          "sectionId"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "listening_dictation"
                          },
                          "partId": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "kind",
                          "partId"
                        ],
                        "additionalProperties": false
                      }
                    ],
                    "description": "已选定且可排入计划的学习内容引用，由内容资源模块提供。"
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
                    "description": "任务所在的中国日历日期。"
                  },
                  "durationMinutes": {
                    "default": 45,
                    "type": "integer",
                    "minimum": 5,
                    "maximum": 240
                  },
                  "timeSlot": {
                    "type": "string",
                    "enum": [
                      "morning",
                      "afternoon",
                      "evening"
                    ],
                    "description": "任务时段：morning=上午，afternoon=下午，evening=晚上。不提供具体钟点。"
                  }
                },
                "required": [
                  "contentRef",
                  "date",
                  "durationMinutes",
                  "timeSlot"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "kind",
              "task"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "update"
              },
              "patch": {
                "type": "object",
                "properties": {
                  "contentRef": {
                    "oneOf": [
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "question_part"
                          },
                          "partId": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "kind",
                          "partId"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "mock_paper"
                          },
                          "paperId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 160
                          }
                        },
                        "required": [
                          "kind",
                          "paperId"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "courseId": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          },
                          "kind": {
                            "type": "string",
                            "const": "course_section"
                          },
                          "sectionId": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "courseId",
                          "kind",
                          "sectionId"
                        ],
                        "additionalProperties": false
                      },
                      {
                        "type": "object",
                        "properties": {
                          "kind": {
                            "type": "string",
                            "const": "listening_dictation"
                          },
                          "partId": {
                            "type": "integer",
                            "exclusiveMinimum": 0,
                            "maximum": 9007199254740991
                          }
                        },
                        "required": [
                          "kind",
                          "partId"
                        ],
                        "additionalProperties": false
                      }
                    ]
                  },
                  "date": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "durationMinutes": {
                    "type": "integer",
                    "minimum": 5,
                    "maximum": 240
                  },
                  "timeSlot": {
                    "type": "string",
                    "enum": [
                      "morning",
                      "afternoon",
                      "evening"
                    ],
                    "description": "任务时段：morning=上午，afternoon=下午，evening=晚上。不提供具体钟点。"
                  }
                },
                "additionalProperties": false
              },
              "taskId": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "kind",
              "patch",
              "taskId"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "remove"
              },
              "taskId": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "kind",
              "taskId"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "complete"
              },
              "taskId": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "kind",
              "taskId"
            ],
            "additionalProperties": false
          }
        ]
      }
    },
    "reason": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500
    },
    "planId": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "changes",
    "reason",
    "planId"
  ],
  "additionalProperties": false
}
```

## Response envelope

```json
{
  "code": 0,
  "data": {},
  "message": "ok"
}
```

## Errors

| HTTP | Code | Meaning |
| --- | --- | --- |
| 400 | `40001` | 请求参数不符合接口契约 |
| 401 | `40101` | 缺少或使用了无效的访问令牌 |
| 403 | `40301` | 访问令牌不包含接口所需权限 |
| 404 | `40401` | 接口或目标资源不存在 |
