Create a run strategy

Create a run policy configuration that is referenced by the agent.

POST https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/runtime-policy-profiles

Preparation before calling

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: The workspace ID for which the policy is to be created, passed in the X-Workspace-ID header and also as workspace_id in the path.

Request example

curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/runtime-policy-profiles" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "默认运行限制",
    "budgets": {
      "max_steps": 20
    }
  }'

Path parameters

Parameters

Type

Is it required

Description

workspace_id

string

Yes

Current workspace ID, must be consistent with X-Workspace-ID.

Request body

Parameters

Type

Is it required

Description

name

string

Yes

Policy name.

description

string

No

Policy description.

status

string

No

Policy status.

scope_type

string

No

Policy scope type.

scope_ref

string

No

Scope reference.

admission

object

No

Access conditions.

budgets

object

No

Budget limit.

retry

object

No

Retry policy.

data_policy

object

No

Data policy.

artifact_policy

object

No

Product strategy.

provider_constraints

object

No

Run provider constraints.

labels

object

No

Tag key-value pair.

annotations

object

No

Annotation key-value pair.

metadata

object

No

Extended metadata.

Successful response

Returns 201 on success. data is the new strategy.

{
  "code": 0,
  "data": {
    "id": "policy_01",
    "workspace_id": "ws_01",
    "name": "默认运行限制",
    "status": "active",
    "scope_type": "workspace",
    "budgets": {
      "max_steps": 20
    },
    "version": 1,
    "created_at": "2026-08-18T01:00:00Z",
    "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.workspace_id

string

ID of the workspace to which it belongs.

data.name

string

Policy name and status.

data.status

string

Policy name and status.

data.scope_type

string

Scope types and references; references are only returned if they have a value.

data.scope_ref

string

Scope types and references; references are only returned if they have a value.

data.admission

object

Admission, budget, and retry configuration; returned only if there is a value.

data.budgets

object

Admission, budget, and retry configuration; returned only if there is a value.

data.retry

object

Admission, budget, and retry configuration; returned only if there is a value.

data.data_policy

object

Data, product, and provider constraints; only returned if there is a value.

data.artifact_policy

object

Data, product, and provider constraints; only returned if there is a value.

data.provider_constraints

object

Data, product, and provider constraints; only returned if there is a value.

data.version

integer

Policy version.

data.created_at

string

Creation and update time.

data.updated_at

string

Creation and update time.

Error response

{
  "code": 2,
  "message": "运行策略参数无效"
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

2INVALID_ARGUMENT

The request body or policy field is invalid.

Check request fields.

401

6UNAUTHENTICATED

Credentials are missing or invalid.

Check API Key.

403

5PERMISSION_DENIED

The current identity does not have permission to create.

Use valid credentials, or contact your administrator for authorization.

409

4ALREADY_EXISTS

Policy ID or name conflict.

Modify identification or process existing policies.

503

15UNAVAILABLE

The running policy service is unavailable.

Try again later.

Follow-up operations

Save data.id and reference it as the agent run strategy.

Last updated on