---
orphan: true
---

# Take over ownership of historical computing resources

Register workspace ownership for historical computing resources. This operation is for controlled remediation and requires appropriate administrative rights.

```text
POST https://moi.matrixorigin.cn/newmoi/compute-resources/{resource_id}/adopt-legacy-ownership
```

## Preparation before calling

First [Query the computing resource details](get-compute-resource.md) confirm that the target is a historical resource that needs to be repaired. Prepare the personal access token, target workspace ID, and compute resource 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 `X-Workspace-ID` Header.
- `$RESOURCE_ID`: ID of the computing resource whose ownership is to be registered.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/compute-resources/$RESOURCE_ID/adopt-legacy-ownership" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_id` | string | Yes | Compute resource ID. |

## Successful response

Returns `200` and registered ownership information on success.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "workspace_id": "ws-01",
    "resource_type": "compute_resource",
    "resource_id": "cr-01",
    "owner_role_id": "role-owner",
    "authorized_role_id": "role-admin",
    "status": "active",
    "ownership_version": 1,
    "idempotent_replay": false
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.workspace_id` | string | ID of the workspace to which the resource belongs. |
| `data.resource_type` | string | Resource type. |
| `data.resource_id` | string | Computing resource ID. |
| `data.owner_role_id` | string | Owner role ID. |
| `data.authorized_role_id` | string | This authorization role ID. |
| `data.status` | string | Ownership record status. |
| `data.ownership_version` | integer | Ownership version number. |
| `data.idempotent_replay` | boolean | Whether the replay is idempotent. |

## Error response

```json
{
  "code": "ADOPT_LEGACY_OWNERSHIP_FAILED",
  "msg": "服务器内部错误",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `401`
  - —
  - Missing or invalid access credentials.
  - Check API Key and Workspace Header.
* - `403`
  - `PERMISSION_DENIED`
  - The current identity does not have permission to perform historical ownership restoration.
  - Contact the administrator to confirm remediation permissions and target resources.
* - `404`
  - `NOT_FOUND`
  - The computing resource does not exist or does not belong to the current workspace.
  - Check `resource_id` and workspace.
* - `500`
  - `ADOPT_LEGACY_OWNERSHIP_FAILED`
  - The server failed to register ownership.
  - Contact the administrator after recording the request time and error message.
```
