# Update a workspace

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

Change the name of an existing workspace.

```text
PATCH https://moi.matrixorigin.cn/newmoi/workspaces/{id}
```

## Before you call

First [list workspaces](list-workspaces.md#query-parameters) to confirm the workspace to update. Prepare a [personal access token](../../../../guides/genesis/api-keys.md#create-and-manage-personal-access-tokens) and the workspace ID. You do not need to enter a workspace before calling this API.

## Path parameter and request body

Replace `$AI_STUDIO_API_KEY`, `$WORKSPACE_ID`, and `$WORKSPACE_NAME` with actual values.

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

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "'"$WORKSPACE_NAME"'"
  }'
```

:::::
:::::{tab-item} Parameter details

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | ID of the workspace to update. |
| `name` | string | Yes | New workspace name. It cannot be empty. |

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

## Successful response

On success, the API returns 200, which indicates that the name was saved.

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

```json
{
  "code": "OK",
  "msg": "OK"
}
```

:::::
:::::{tab-item} Field details

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |

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

## Error response

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

```json
{
  "code": "ErrParamInvalid",
  "msg": "Invalid request parameters",
  "data": null
}
```

:::::
:::::{tab-item} Field details

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Error code. |
| `msg` | string | Human-readable error message. |
| `data` | null | `null` in an error response. |

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

## Next steps

[List workspaces](list-workspaces.md#query-parameters) to confirm that the name was updated.
