---
orphan: true
---

# Cancel resource operation

Requests the cancellation of an unfinished agent resource operation.

```text
POST https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/operations/{operation_id}/cancel
```

## Preparation before calling

The examples below use `$AI_STUDIO_API_KEY`, `$WORKSPACE_ID`, and `$OPERATION_ID`.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/operations/$OPERATION_ID/cancel" -H "X-API-Key: $AI_STUDIO_API_KEY" -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Successful response

Returns `200` and operation status on success.

```json
{"code":0,"data":{"id":"op_01","status":"canceled"}}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.id` | string | Operation ID. |
| `data.status` | string | The state after cancellation. |

## Error response

```json
{"code":5,"message":"operation not found"}
```
