# Enable or disable calculation specifications

Sets the enabled status of a compute specification.

```text
PATCH https://moi.matrixorigin.cn/newmoi/compute-resource-specs/{spec_id}/enabled
```

## Preparation before calling

First [list the calculation specifications](list-compute-resource-specs.md) and confirm the specifications to set the status. Prepare the personal access token, target workspace ID, and spec 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.
- `$SPEC_ID`: The compute spec ID to set the status for, taken from the response of [List compute spec](list-compute-resource-specs.md).

First [Query the calculation specification management permission](get-compute-resource-spec-management-permission.md). The enabled status can only be modified if the result is `true`. Disabling a specification does not replace lifecycle management of existing compute instances.

## Request example

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/compute-resource-specs/$SPEC_ID/enabled" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "enabled": false
  }'
```

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `spec_id` | string | Yes | The ID of the compute specification to set the state for. |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `enabled` | boolean | No | `true` is enabled, `false` is disabled. The service is handled as `false` when not provided, so should always be passed in explicitly. |

## Successful response

Returns `200` on success. `data` returns the updated specification object, where `enabled` is the state after the request.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": "task-standard-small",
    "enabled": false
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.id` | string | Compute spec ID. |
| `data.kind` | string | Resource type. |
| `data.family` | string | Specification family identifier. |
| `data.family_name` | string | Specification family name. |
| `data.family_name_en` | string | English name of the specification family. |
| `data.cpu_milli` | integer | CPU capacity in millicore. |
| `data.memory_mib` | integer | Memory capacity in MiB. |
| `data.gpu_count` | integer | Number of GPUs. |
| `data.gpu_memory_mib` | integer | GPU memory, unit is MiB. |
| `data.gpu_cores` | integer | Number of GPU cores. |
| `data.credit_per_hour` | number | Credit usage per hour. |
| `data.description` | string | Specification. |
| `data.description_en` | string | English specifications; system specifications can be returned. |
| `data.node_placement` | object | Node scheduling configuration. |
| `data.enabled` | boolean | Updated enabled status. |
| `data.is_system` | boolean | Whether it is a built-in specification of the system. |
| `data.created_by` | string | Creator ID. |
| `data.updated_by` | string | The last updater ID. |
| `data.created_at` | string | Creation time. |
| `data.updated_at` | string | Last updated time. |

## Error response

```json
{
  "code": "INVALID_PARAMS",
  "msg": "invalid request parameters",
  "data": null
}
```

### Common HTTP errors

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

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `INVALID_PARAMS`
  - The request body cannot be parsed, or `enabled` is not a Boolean value.
  - Explicitly pass in `enabled` of type boolean.
* - `401`
  - —
  - Missing, invalid or expired access credentials.
  - Check API Key.
* - `403`
  - `COMPUTE_RESOURCE_SPEC_FORBIDDEN`
  - The current identity does not have specification management rights.
  - Try again using an identity with appropriate permissions.
* - `404`
  - —
  - The specification corresponding to `spec_id` does not exist.
  - First [list the calculation specifications](list-compute-resource-specs.md), and confirm the path parameters.
* - `500`
  - `SET_SPEC_ENABLED_FAILED`
  - The server failed to update the enabled status.
  - Try again later; if it continues to fail, contact support.
```

## Follow-up operations

[List calculation specifications](list-compute-resource-specs.md) Confirm the new status.
