# SCIM Group examples

## Operations

This page shows the operations that can be performed for the group object.

### List all

##### Request

```XML
GET https://<your-domain>/soffid/webservice/scim2/v1/Group
```

##### Response 200 OK

```JSON
{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:ListResponse"
    ],
    "totalResults": 7,
    "startIndex": 1,
    "Resources": [
        {
            "organizational": false,
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Group/83",
                "links": {
                    "members": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/User?filter=primaryGroup+eq+'world'+or secondaryGroup.group.name+eq+'world'",
                    "administrators": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/RoleAccount?filter=group.name+eq+'world'"
                },
                "resourceType": "Group"
            },
            "quota": "0",
            "schemas": [
                "urn:soffid:com.soffid.iam.api.Group"
            ],
            "name": "world",
            "obsolete": false,
            "description": "World Original",
            "attributes": {},
            "id": 83
        },
        {
            "organizational": false,
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Group/87",
                "links": {
                    "members": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/User?filter=primaryGroup+eq+'enterprise'+or secondaryGroup.group.name+eq+'enterprise'",
                    "administrators": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/RoleAccount?filter=group.name+eq+'enterprise'"
                },
                "resourceType": "Group"
            },
            "quota": "0",
            "schemas": [
                "urn:soffid:com.soffid.iam.api.Group"
            ],
            "name": "enterprise",
            "obsolete": false,
            "description": "Enterprise",
            "parentGroup": "world",
            "attributes": {},
            "id": 87
        },
      ......
    ]
}
```

### List by filter

List all groups with a filter expression.

<p class="callout info">It is allowed to use pagination and sort the information, for more information visit the [Sorting](https://bookstack.soffid.com/link/116#bkmrk-sorting) and [Pagination](https://bookstack.soffid.com/link/116#bkmrk-pagination) information.</p>

##### Request

```XML
GET https://<your-domain>/soffid/webservice/scim2/v1/Group?filter=name co world
```

##### Response 200 OK

```JSON
{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:ListResponse"
    ],
    "totalResults": 2,
    "startIndex": 1,
    "Resources": [
        {
            "organizational": false,
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Group/83",
                "links": {
                    "members": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/User?filter=primaryGroup+eq+'world'+or secondaryGroup.group.name+eq+'world'",
                    "administrators": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/RoleAccount?filter=group.name+eq+'world'"
                },
                "resourceType": "Group"
            },
            "quota": "0",
            "schemas": [
                "urn:soffid:com.soffid.iam.api.Group"
            ],
            "name": "world",
            "obsolete": false,
            "description": "World Original",
            "attributes": {},
            "id": 83
        },
        {
            "organizational": false,
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Group/485118",
                "links": {
                    "members": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/User?filter=primaryGroup+eq+'world2'+or secondaryGroup.group.name+eq+'world2'",
                    "administrators": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/RoleAccount?filter=group.name+eq+'world2'"
                },
                "resourceType": "Group"
            },
            "quota": "0",
            "schemas": [
                "urn:soffid:com.soffid.iam.api.Group"
            ],
            "name": "world2",
            "obsolete": false,
            "description": "World Modified",
            "attributes": {},
            "id": 485118
        }
    ]
}
```

### Query by id

Retrieve a group by its id (primary key).

##### Request

```XML
GET https://<your-domain>/soffid/webservice/scim2/v1/Group/83
```

##### Response 200 OK

```JSON
{
    "organizational": false,
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Group/83",
        "links": {
            "members": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/User?filter=primaryGroup+eq+'world'+or secondaryGroup.group.name+eq+'world'",
            "administrators": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/RoleAccount?filter=group.name+eq+'world'"
        },
        "resourceType": "Group"
    },
    "quota": "0",
    "schemas": [
        "urn:soffid:com.soffid.iam.api.Group"
    ],
    "name": "world",
    "obsolete": false,
    "description": "World Original",
    "attributes": {},
    "id": 83
}
```

### Create

##### Request

```XML
POST https://<your-domain>/soffid/webservice/scim2/v1/Group/
```

**JSON**

```JSON
{
    "schemas": [
        "urn:soffid:com.soffid.iam.iga.api.Group"
    ],
    "name": "EngineeringTeam",
    "description": "Enterprise engineering team",
    "parentGroup": "world"
}
```

##### Response 201 Created

```JSON
{
    "organizational": false,
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Group/1976559",
        "resourceType": "Group"
    },
    "quota": "0",
    "schemas": [
        "urn:soffid:com.soffid.iam.api.Group"
    ],
    "name": "EngineeringTeam",
    "obsolete": false,
    "description": "Enterprise engineering team",
    "parentGroup": "world",
    "attributes": {},
    "id": 1976559
}
```

### Update partial

Only attributes with changes will be updated, the other will maintain the same value.

<p class="callout info">If you want to add users to a group, please visit [SCIM GroupUser examples](https://bookstack.soffid.com/books/scim/page/scim-usergroup-examples "SCIM GroupUser examples") page</p>

##### Request

```XML
PATCH https://<your-domain>/soffid/webservice/scim2/v1/Group/1976559
```

**JSON**

```JSON
{
    "Operations": [
        {
            "op": "replace",
            "path": "description",
            "value": "Enterprise Engineering Group"
        },
        {
            "op": "replace",
            "path": "type",
            "value": "CC"
        }
    ]
}
```

##### Response 200 OK

```JSON
{
    "organizational": false,
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Group/1976559",
        "links": {
            "members": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/User?filter=primaryGroup+eq+'EngineeringTeam'+or secondaryGroup.group.name+eq+'EngineeringTeam'",
            "administrators": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/RoleAccount?filter=group.name+eq+'EngineeringTeam'"
        },
        "resourceType": "Group"
    },
    "quota": "0",
    "schemas": [
        "urn:soffid:com.soffid.iam.api.Group"
    ],
    "name": "EngineeringTeam",
    "obsolete": false,
    "description": "Enterprise Engineering Group",
    "parentGroup": "world",
    "attributes": {},
    "id": 1976559,
    "type": "CC"
}
```

### Update all

This operation replaces all values in the group.

- Note that the attribute id is required to confirm that the resource "...Group/&lt;id&gt;" is the same that the JSON group.
- Note that all the attributes not included in the request will be cleared in the group and their data will be lost.
- Note that not all the attributes are updatable, for example, tag meta, avoid these tags. For more information see [Resource data model page](https://bookstack.soffid.com/books/scim/chapter/resource-data-model-schema).

##### Request

```XML
PUT http://<your-domain>/soffid/webservice/scim2/v1/Group/1976559
```

**JSON**

```JSON
{
    "schemas": [
      "urn:soffid:com.soffid.iam.iga.api.Group"
    ],
    "id": 1976559,
    "name": "EngineeringTeam",
    "description": "Enterprise engineering team",
    "parentGroup": "world"
}
```

##### Response 200 OK

```JSON
{
    "organizational": false,
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/Group/1976559",
        "links": {
            "members": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/User?filter=primaryGroup+eq+'EngineeringTeam'+or secondaryGroup.group.name+eq+'EngineeringTeam'",
            "administrators": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/RoleAccount?filter=group.name+eq+'EngineeringTeam'"
        },
        "resourceType": "Group"
    },
    "quota": "0",
    "schemas": [
        "urn:soffid:com.soffid.iam.api.Group"
    ],
    "name": "EngineeringTeam",
    "obsolete": false,
    "description": "Enterprise engineering team",
    "parentGroup": "world",
    "attributes": {},
    "id": 1976559
}
```

### Delete

<p class="callout warning">Please note that after this delete action, you will need to create again the group to use it in the next examples.</p>

##### Request

```XML
DELETE https://<your-domain>/soffid/webservice/scim2/v1/Group/1976559
```

##### Response 204 No Content

```
204 No Content
```

### Error response

<p class="callout info">For more information about error response visit [https://bookstack.soffid.com/link/116#bkmrk-error-response](https://bookstack.soffid.com/link/116#bkmrk-error-response)</p>