# Restricted runtime agent build commands

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Execute build operations allowed by the current trusted run. This page records the restricted protocol foundation. Full candidate objects and resource selection contracts still require owner-specific detail; this is not an addition to ordinary PAT reference APIs.

```text
POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agent-builder/runtime
```

## Before you call this API

Set `MOI_ENDPOINT` to the product API prefix `https://api.moi.matrixorigin.cn/v5`. For private deployments, use the corresponding product API URL.

Applies only to child runtime environments already admitted by the product. Use Endpoint, technical API Key, Workspace, and X-MOI-Runtime-Authorization supplied together by that environment. The latter is the complete Bearer line; do not replace it with a personal access token or short-lived browser proof.

## Request parameters

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl -X POST "$MOI_ENDPOINT/workspaces/$MOI_WORKSPACE_ID/agent-builder/runtime" \
  -H "X-API-Key: $MOI_API_KEY" \
  -H "X-Workspace-ID: $MOI_WORKSPACE_ID" \
  -H "X-MOI-Runtime-Authorization: $MOI_RUNTIME_AUTHORIZATION" \
  -H "Content-Type: application/json" --data '{"operation":"context"}'
```

:::::
:::::{tab-item} Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `workspace_id` | string | Workspace of the admitted run. |
| `X-MOI-Runtime-Authorization` | string | One Bearer proof, validated against the original task, manifest, and admitted tools. |
| `operation` | string | context, resources, propose, or workspace_mcp. |
| `input` | JSON object | context/resources must omit this, including null. The other operations follow their owner contracts. |

:::::
::::::
:::::::

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```text
HTTP 200 application/json
code: 0
data: 对应operation的owner返回对象
```

:::::
:::::{tab-item} Fields

| Field or response item | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 for normal success. |
| `data` | object | The four operation types return different objects; one field table is not a complete contract for all. |
| Candidate result | object | propose publishes a server-side candidate event. Does not establish completed saving/loading/publication. |
| Recoverable failure | HTTP409 or 422 | Retain owner string code/message/data feedback rather than reducing it to ordinary numeric errors. |

:::::
::::::
:::::::

## Error responses

Top-level requests are limited to 1MiB and strictly reject unknown fields and trailing JSON. This does not establish duplicate-key rejection. Handle runtime-proof rejection separately from recoverable candidate errors. See [Runtime contracts](runtime-contracts.md) for detailed operations and effects.
