<span id="回填历史智能体产物"></span>

# Backfill historical agent artifacts

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

Create missing agent artifact records from existing files that meet source requirements.


```http
POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agent-artifacts/backfill
```

<span id="调用前准备"></span>

## Before you call this API

`BASE_URL` uses the product API prefix `https://api.moi.matrixorigin.cn/v5`. For a dedicated deployment, use its corresponding product API address.

[Prepare identity, volume privileges, and version references](objects.md#prepare).

<span id="请求"></span>

## Request

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

```bash
curl --request POST \
  "$BASE_URL/workspaces/$WORKSPACE_ID/agent-artifacts/backfill" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID" \
  --header "Content-Type: application/json" \
  --data '{"dry_run":true,"limit":200}'
```

Execution example after confirming the write:

```bash
curl --request POST \
  "$BASE_URL/workspaces/$WORKSPACE_ID/agent-artifacts/backfill" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID" \
  --header "Content-Type: application/json" \
  --data '{"dry_run":false,"limit":200}'
```

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

| Parameter | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | Path | string | Yes | Workspace ID in the current environment. |
| `dry_run` | Body | boolean | No | Defaults to false and performs writes. true only counts candidates. |
| `limit` | Body | integer | No | Defaults to 200; 0 also means 200. Maximum 1000; negative values or values above 1000 are rejected. |

Run dry_run=true first to inspect candidates. Run the false example only after confirming writes. An empty object, JSON null, no request body, or Content-Length of 0 uses false. An empty body of unknown length may be rejected during binding. dry-run skipped equals scanned candidates, not records that already existed. Backfill neither reruns the agent nor restores lost files.

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

<span id="成功响应"></span>

## Successful response

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

```json
{
  "code": 0,
  "data": {
    "scanned": 1,
    "inserted": 0,
    "skipped": 1,
    "failed": 0,
    "dry_run": true
  }
}
```

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

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 on success; batch operations still require checking each item. |
| `data` | object | [Corresponding response object](objects.md#responses). |

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

<span id="错误响应"></span>

## Error response

[Errors and result confirmation](boundaries.md#errors) distinguishes overall failures, item failures, and invisible sources.
