# Update task

Update a paused import task. The interface will only modify the fields provided in the request.

```text
POST https://moi.matrixorigin.cn/newmoi/task/update
```

## Before you call

Prepare the personal access token, target workspace ID, and task ID that have access to the target workspace. First, [Query task details](get-import-task.md) confirms that the task has been suspended; unsuspended tasks cannot be updated.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: The workspace ID of the task to be updated, passed through the `X-Workspace-ID` Header.
- `$TASK_ID`: Task ID to be updated.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/task/update" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "task_id": "'$TASK_ID'",
    "name": "import_orders_v2",
    "load_mode_config": {
      "load_interval_type": 4
    }
  }'
```

## Request body

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `task_id` | string | Yes | The ID of the import task to update. |
| `name` | string | No | The new task name; an empty string will not update the name. |
| `load_mode_config` | object | No | Load mode for file import. When this object is provided, the load plan is updated with the fields in it. |
| `load_mode_config.load_interval_type` | integer | No | Load interval type: `1` every day, `2` every hour, `3` every minute, `4` once, `5` every 5 minutes, `6` every 10 minutes, `7` every 30 minutes, `8` every 2 hours, `9` every 4 hours, `10` every 6 hours, `11` every 12 hours. |
| `load_mode_config.interval` | integer | No | Period parameter; represents the execution hour in days. |
| `file_filter_config` | object | No | File filter configuration; providing this object replaces the current file filter configuration entirely. |
| `file_filter_config.filename_globs` | string[] | No | Filename glob pattern. |
| `file_filter_config.min_file_size` | integer | No | Minimum file size in bytes. |
| `file_filter_config.max_file_size` | integer | No | Maximum file size in bytes. |
| `file_filter_config.min_create_time` | integer | No | Minimum creation time, using a Unix timestamp. |
| `file_filter_config.max_create_time` | integer | No | Maximum creation time, using a Unix timestamp. |
| `file_filter_config.file_types` | integer[] | No | File type filter code. |
| `file_filter_config.path_regex` | string | No | File path filter regular expression. |
| `uris` | string[] | No | List of source file URIs; replacing the current URI list entirely when this field is provided. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Successful response

Returns `200` on success and `data` is `null`.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": null
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | null | This interface does not return the updated task; please query the details again to confirm. |

## Error response

```json
{
  "code": "ErrForbidden",
  "msg": "permission denied",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 25 30 33

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - The request body is invalid, or the task is not in the paused state.
  - Fix JSON and pause the task first.
* - `403`
  - `ErrForbidden`
  - The caller does not have permission to update the task.
  - Check workspace and object authorization.
* - `503`
  - `ErrCoreAuthorizeUnavailable`
  - The service is temporarily unable to complete the authorization check.
  - Try again later.
* - `200`
  - `ErrServer`
  - The service failed to update the task.
  - Check both HTTP status and `code`.
```

## Follow-up operations

This interface does not return the complete task object. Use the same task ID [Query task details](get-import-task.md) to confirm the update result.
