# moveCollectionToGroup

Mutation

Move a Collection into a view group, or out (when groupId is null).

Available to agents as MCP tool `moveCollectionToGroup` — see [Write tools](/api/v2/docs/mcp/write-tools#move-collection-to-group).

## Arguments

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `collectionId` | `ID!` | Yes | — | UUID of the Collection to move (as returned by `collections`). Collection management is available only in workspaces whose Collections use the standard storage; where they use an older format the ids `collections` returns are not accepted here and the call returns a userError without changing anything. |
| `groupId` | `ID` | No | — | Target ViewGroup UUID. Pass null to remove the Collection from any group it currently belongs to. |

## Returns

| Name | Type | Description |
| --- | --- | --- |
| `collection` | [`Collection`](/api/v2/docs/types/collection) | The moved Collection, with the populated `group` field. Null when the Collection was not found or the move failed. |
| `userErrors` | [`[UserError!]!`](/api/v2/docs/types/user-error) | List of user-facing errors. Empty on success. |

## Examples

### Move a collection into a group

Move a Collection into a view group (or out with a null groupId).

```graphql
mutation MoveCollectionToGroupDefault($collectionId: ID!, $groupId: ID) {
  moveCollectionToGroup(collectionId: $collectionId, groupId: $groupId) {
    collection {
      id
      name
      group {
        id
        name
      }
    }
    userErrors {
      field
      message
    }
  }
}
```

Variables:

```json
{
  "collectionId": "122321ce-843e-5b07-9f56-94323c0ae39e",
  "groupId": "8e0f0ff1-8024-5af5-9506-49091f53a920"
}
```

Response — HTTP 200:

```json
{
  "data": {
    "moveCollectionToGroup": {
      "collection": {
        "id": "122321ce-843e-5b07-9f56-94323c0ae39e",
        "name": "Best Sellers",
        "group": {
          "id": "8e0f0ff1-8024-5af5-9506-49091f53a920",
          "name": "Northwind Sidebar"
        }
      },
      "userErrors": []
    }
  }
}
```
