# Add Group to Groups of a User

## Request

```CURL
POST [[[<REST API URL>|Hub-Rest-Api-URL.html]]]/users/user id/groups?fields=string
```

|  Parameter  |  Description  |
| --- | --- |
|  `fields`  |  Optional. Returns only the specified subset of the fields for each Group. Use [Fields Syntax](hub-api-fields-syntax.html) to define the subset.  |

### Request Body

#### userGroup

extends [authorityHolder](HUB-REST-API_JSON-Scheme.html#authorityHolder)

```JSON
{
  "description": string, 
  "iconUrl": string, 
  "autoJoin": boolean, 
  "autoJoinDomain": string, 
  "requiredTwoFactorAuthentication": boolean, 
  "parentsRequireTwoFactorAuthentication": boolean, 
  "users": [[[[user|HUB-REST-API_JSON-Scheme.html#user]]], ...], 
  "ownUsers": [[[[user|HUB-REST-API_JSON-Scheme.html#user]]], ...], 
  "userCount": int, 
  "parent": [[[userGroup|HUB-REST-API_JSON-Scheme.html#userGroup]]], 
  "subgroups": [[[[userGroup|HUB-REST-API_JSON-Scheme.html#userGroup]]], ...], 
  "allUsers": boolean, 
  "registeredUsers": boolean, 
  "implicit": boolean, 
  "queriedSingleton": boolean, 
  "updatable": boolean, 
  "removable": boolean, 
  "immutable": boolean, 
  "importedFromAuthModule": [[[externalauthmodule|HUB-REST-API_JSON-Scheme.html#externalauthmodule]]], 
  "mappedInAuthModule": [[[externalauthmodule|HUB-REST-API_JSON-Scheme.html#externalauthmodule]]], 
  "idpGroupId": string, 
  "idpGroupName": string, 
  "idpStatus": [[[userGroupIdpStatus|HUB-REST-API_JSON-Scheme.html#userGroupIdpStatus]]], 
  "idpGroupNameOverridden": boolean, 
  "orgId": string, 
  "viewers": [[[[authorityHolder|HUB-REST-API_JSON-Scheme.html#authorityHolder]]], ...], 
  "updaters": [[[[authorityHolder|HUB-REST-API_JSON-Scheme.html#authorityHolder]]], ...], 
    "name": string , 
    "projectRoles": [[[[projectRole|HUB-REST-API_JSON-Scheme.html#projectRole]]], ...] , 
    "transitiveProjectRoles": [[[[projectRole|HUB-REST-API_JSON-Scheme.html#projectRole]]], ...] , 
    "sourcedProjectRoles": [[[[sourcedProjectRole|HUB-REST-API_JSON-Scheme.html#sourcedProjectRole]]], ...] , 
    "id": string , 
    "aliases": [[[[alias|HUB-REST-API_JSON-Scheme.html#alias]]], ...] 
}
```

## Response

|  Response Code  |  Meaning  |
| --- | --- |
|  200 OK  |  Successful request.  |
|  400 Bad Request  |  At least one of the request parameters is invalid. For example, a required field in the passed JSON object is missing. For details, check the error message in the response.  |
|  403 Forbidden  |  The requester has no access to the requested resource.  |
|  404 Not Found  |  The requested resource was not found.  |
|  500 Internal Server Error  |  Failed to process request because of the server error. For details, check the error message in the response.  |

### Response body

```JSON
{
  "description": string, 
  "iconUrl": string, 
  "autoJoin": boolean, 
  "autoJoinDomain": string, 
  "requiredTwoFactorAuthentication": boolean, 
  "parentsRequireTwoFactorAuthentication": boolean, 
  "users": [[[[user|HUB-REST-API_JSON-Scheme.html#user]]], ...], 
  "ownUsers": [[[[user|HUB-REST-API_JSON-Scheme.html#user]]], ...], 
  "userCount": int, 
  "parent": [[[userGroup|HUB-REST-API_JSON-Scheme.html#userGroup]]], 
  "subgroups": [[[[userGroup|HUB-REST-API_JSON-Scheme.html#userGroup]]], ...], 
  "allUsers": boolean, 
  "registeredUsers": boolean, 
  "implicit": boolean, 
  "queriedSingleton": boolean, 
  "updatable": boolean, 
  "removable": boolean, 
  "immutable": boolean, 
  "importedFromAuthModule": [[[externalauthmodule|HUB-REST-API_JSON-Scheme.html#externalauthmodule]]], 
  "mappedInAuthModule": [[[externalauthmodule|HUB-REST-API_JSON-Scheme.html#externalauthmodule]]], 
  "idpGroupId": string, 
  "idpGroupName": string, 
  "idpStatus": [[[userGroupIdpStatus|HUB-REST-API_JSON-Scheme.html#userGroupIdpStatus]]], 
  "idpGroupNameOverridden": boolean, 
  "orgId": string, 
  "viewers": [[[[authorityHolder|HUB-REST-API_JSON-Scheme.html#authorityHolder]]], ...], 
  "updaters": [[[[authorityHolder|HUB-REST-API_JSON-Scheme.html#authorityHolder]]], ...], 
    "name": string , 
    "projectRoles": [[[[projectRole|HUB-REST-API_JSON-Scheme.html#projectRole]]], ...] , 
    "transitiveProjectRoles": [[[[projectRole|HUB-REST-API_JSON-Scheme.html#projectRole]]], ...] , 
    "sourcedProjectRoles": [[[[sourcedProjectRole|HUB-REST-API_JSON-Scheme.html#sourcedProjectRole]]], ...] , 
    "id": string , 
    "aliases": [[[[alias|HUB-REST-API_JSON-Scheme.html#alias]]], ...] 
}
```

