# Archive automation tasks

Archiving automation tasks. This interface does not physically delete the task, but instead sets its status to `archived`.

```text
DELETE https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/agent-automation-tasks/{automation_task_id}
```

## Preparation before calling

First [Query automation task details](get-task.md)confirm the current status of the task and obtain the task ID. Prepare a personal access token and target workspace ID that has access to the target workspace.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through the `X-Workspace-ID` Header and also as `workspace_id` in the path.
- `$TASK_ID`: The automation task ID to be archived, as `automation_task_id` in the path.

## Request example

```bash
curl -X DELETE "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/agent-automation-tasks/$TASK_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | Workspace ID. |
| `automation_task_id` | string | Yes | Automation task ID. |

## Successful response

Returns `200` on success. `data` returns the archived task, `data.status` as `archived`. Tasks should not be considered triggerable after being archived.

```json
{
  "code": 0,
  "data": {
    "id": "task_01",
    "workspace_id": "ws_01",
    "status": "archived",
    "version": 3,
    "updated_at": "2026-08-18T03:00:00Z"
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.id` | string | Automation task ID and associated workspace ID. |
| `data.workspace_id` | string | Automation task ID and associated workspace ID. |
| `data.status` | string | `archived` on success. |
| `data.version` | integer | Archived task version. |
| `data.updated_at` | string | Archive time, using RFC 3339 format. |
| Other fields of `data` | object | Are consistent with the task fields returned by [Query automation task details](get-task.md). |

## Error response

```json
{
  "code": 3,
  "message": "<错误信息>"
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `2`（`INVALID_ARGUMENT`）
  - The path parameter is invalid, or the current status of the task cannot be archived.
  - Check task ID and current status.
* - `401`
  - `6`（`UNAUTHENTICATED`）
  - Lack of valid identity credentials.
  - Check API Key.
* - `404`
  - `3`（`NOT_FOUND`）
  - The automated task does not exist.
  - Check the task list first.
* - `409`
  - `4`（`ALREADY_EXISTS`）
  - Task status conflicts with archiving operation.
  - Refresh task details before performing the operation.
* - `503`
  - `15`（`UNAVAILABLE`）
  - The automated task service is unavailable.
  - Try again later.
```

## Follow-up operations

If you need to retain the running results before archiving, please record the run ID that needs to be retained and query the corresponding running details or results.
