# Update running strategy

Partially updated run policy configuration. Each successful update increments the policy version and only affects subsequent admission operations.

```text
PATCH https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/runtime-policy-profiles/{policy_id}
```

## Preparation before calling

First [query the running policy details](get-runtime-policy-profile.md) and confirm the policy to be updated. Prepare the personal access token, target workspace ID, and policy ID that have 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.
- `$POLICY_ID`: The running policy ID to update, as `policy_id` in the path.

## Request example

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/runtime-policy-profiles/$POLICY_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "budgets": {
      "max_steps": 30
    },
    "retry": {
      "max_attempts": 2
    }
  }'
```

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | The current workspace ID. |
| `policy_id` | string | Yes | The running policy ID. |

## Request body

All fields are optional, submit only the fields that need to be updated.

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `name` | string | No | Policy name and description. |
| `description` | string | No | Policy name and description. |
| `status` | string | No | Policy status and scope. |
| `scope_type` | string | No | Policy status and scope. |
| `scope_ref` | string | No | Policy status and scope. |
| `admission` | object | No | Admission, budget, and retry configuration. |
| `budgets` | object | No | Admission, budget, and retry configuration. |
| `retry` | object | No | Admission, budget, and retry configuration. |
| `data_policy` | object | No | Data, product, and provider restrictions. |
| `artifact_policy` | object | No | Data, product, and provider restrictions. |
| `provider_constraints` | object | No | Data, product, and provider restrictions. |
| `labels` | object | No | Attached tags, annotations, and metadata. |
| `annotations` | object | No | Attached tags, annotations, and metadata. |
| `metadata` | object | No | Attached tags, annotations, and metadata. |

## Successful response

On success, `200` is returned, and `data` is the updated strategy. SAVE NEW `data.version`.

```json
{
  "code": 0,
  "data": {
    "id": "policy_01",
    "name": "默认运行限制",
    "status": "active",
    "scope_type": "workspace",
    "budgets": {
      "max_steps": 30
    },
    "retry": {
      "max_attempts": 2
    },
    "version": 2,
    "updated_at": "2026-08-18T01:00:00Z"
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.id` | string | Run policy ID. |
| `data.name` | string | Updated policy name, status, and scope type. |
| `data.status` | string | Updated policy name, status, and scope type. |
| `data.scope_type` | string | Updated policy name, status, and scope type. |
| `data.budgets` | object | Updated budget and retry configuration; only returned if there is a value. |
| `data.retry` | object | Updated budget and retry configuration; only returned if there is a value. |
| `data.version` | integer | The updated policy version. |
| `data.updated_at` | string | Update time. |

## Error response

```json
{
  "code": 2,
  "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 request body or policy field is invalid.
  - Check request fields.
* - `401`
  - `6`（`UNAUTHENTICATED`）
  - Credentials are missing or invalid.
  - Check API Key.
* - `403`
  - `5`（`PERMISSION_DENIED`）
  - The current identity does not have update permissions.
  - Use valid credentials, or contact your administrator for authorization.
* - `404`
  - `3`（`NOT_FOUND`）
  - Run policy does not exist.
  - Query the running policy list first.
* - `409`
  - `4`（`ALREADY_EXISTS`）
  - The updated strategy conflicts with existing resources.
  - Modify the update content and try again.
* - `503`
  - `15`（`UNAVAILABLE`）
  - The running policy service is unavailable.
  - Try again later.
```

## Follow-up operations

Use [Query the details of the running strategy](get-runtime-policy-profile.md) to confirm the current fields and versions.
