# SCIM MailDomain examples

## Operations

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

### List all

##### Request

```MarkDown
GET https://<your-domain>/soffid/webservice/scim2/v1/MailDomain
```

##### Response 200 OK

```JSON
{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:ListResponse"
    ],
    "totalResults": 2,
    "startIndex": 1,
    "Resources": [
        {
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/MailDomain/523263",
                "resourceType": "MailDomain"
            },
            "schemas": [
                "urn:soffid:com.soffid.iam.iga.api.MailDomain"
            ],
            "name": "soffid.com",
            "obsolete": false,
            "description": "Soffid",
            "id": 523263
        },
        {
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/MailDomain/523265",
                "resourceType": "MailDomain"
            },
            "schemas": [
                "urn:soffid:com.soffid.iam.iga.api.MailDomain"
            ],
            "name": "soffid.org",
            "obsolete": false,
            "description": "Old Domain",
            "id": 523265
        }
    ]
}
```

### List by filter

List all Mail domain 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

```MarkDown
GET https://<your-domain>/soffid/webservice/scim2/v1/MailDomain?filter=obsolete eq false and description co old
```

##### Response 200 OK

```JSON
{
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:ListResponse"
    ],
    "totalResults": 1,
    "startIndex": 1,
    "Resources": [
        {
            "meta": {
                "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/MailDomain/523265",
                "resourceType": "MailDomain"
            },
            "schemas": [
                "urn:soffid:com.soffid.iam.iga.api.MailDomain"
            ],
            "name": "soffid.org",
            "obsolete": false,
            "description": "Old Domain",
            "id": 523265
        }
    ]
}
```

### Query by id

Query a Mail Domain by its id (primary key).

##### Request

```MarkDown
GET https://<your-domain>/soffid/webservice/scim2/v1/MailDomain/523263
```

##### Response 200 OK

```JSON
{
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/MailDomain/523263",
        "resourceType": "MailDomain"
    },
    "schemas": [
        "urn:soffid:com.soffid.iam.iga.api.MailDomain"
    ],
    "name": "soffid.com",
    "obsolete": false,
    "description": "Soffid",
    "id": 523263
}
```

### Create

#### Request

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

**JSON**

```JSON
{
    "schemas": [
        "urn:soffid:com.soffid.iam.iga.api.MailDomain"
    ],
    "name": "newdomain.com",
    "obsolete": false,
    "description": "New Domain"
}
```

##### Response 201 Created

```JSON
{
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/MailDomain/1976941",
        "resourceType": "MailDomain"
    },
    "schemas": [
        "urn:soffid:com.soffid.iam.iga.api.MailDomain"
    ],
    "name": "newdomain.com",
    "obsolete": false,
    "description": "New Domain",
    "id": 1976941
}
```

### Update partial

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

##### Request

```
PATCH https://<your-domain>/soffid/webservice/scim2/v1/MailDomain/1976941
```

**JSON**

```JSON
{
    "schemas": [
        "urn:soffid:com.soffid.iam.iga.api.MailDomain"
    ],
    "Operations": [
        {
            "op": "replace",
            "path": "description",
            "value": "New domain (xxx)"
        },
        {
            "op": "replace",
            "path": "obsolete",
            "value": "true"
        }
    ]
}
```

##### Response 200 OK

```JSON
{
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/MailDomain/1976941",
        "resourceType": "MailDomain"
    },
    "schemas": [
        "urn:soffid:com.soffid.iam.iga.api.MailDomain"
    ],
    "name": "newdomain.com",
    "obsolete": true,
    "description": "New domain (xxx)",
    "id": 1976941
}
```

### Update all

This operation replaces all values in the Mail Domain.

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

##### Request

```XML
PUT https://<your-domain>/soffid/webservice/scim2/v1/MailDomain/1976941
```

**JSON**

```JSON
{
    "schemas": [
        "urn:soffid:com.soffid.iam.iga.api.MailDomain"
    ],
    "id": 1976941,
    "name": "newdomain.com",
    "obsolete": false,
    "description": "New Domain"
}
```

##### Response 200 OK

```JSON
{
    "meta": {
        "location": "http://soffid.pat.lab:8080/soffid/webservice/scim2/v1/MailDomain/1976941",
        "resourceType": "MailDomain"
    },
    "schemas": [
        "urn:soffid:com.soffid.iam.iga.api.MailDomain"
    ],
    "name": "newdomain.com",
    "obsolete": false,
    "description": "New Domain",
    "id": 1976941
}
```

### Delete

<p class="callout warning">Please note after this delete, the mail domain has to be created again to use it in the next examples.</p>

##### Request

```MarkDown
DELETE https://<your-omain>/soffid/webservice/scim2/v1/MailDomain/1976941
```

##### 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>