---
title: "Config endpoints examples"
description: ""
url: "https://docs.itrsgroup.com/docs/opsview/current/rest-api/config/api-config-examples/index.html"
---
## Updating multiple Service Checks

The restapi can be used to update multiple servicechecks in one go:

1. Obtain the list of check to be modified and store in a file, i.e. all service checks with 'foo' in the name.

    ```
    opsview_rest --token-file /path/to/opsview_restapi_token --pretty --data-format=json GET 'config/servicecheck?json_filter={"name":{"-like":"%25foo%25"}}' > checks.json
    ```

2. Edit the `checks.json` file as necessary.
3. Import the contents of the file back into Opsview.

    ```
    opsview_rest --token-file /path/to/opsview_restapi_token --pretty --data-format=json --content-file=checks.json --pretty PUT config/servicecheck
    ```


**Note**


The ID's within the `checks.json` file must be left unchanged else new checks will be created, not current checks updated. Amending service check names could lose historical (graphing) information.



## Determining if a Host exists

To see if the host `foo` already exists:

```
opsview_rest --token-file /path/to/opsview_restapi_token GET 'config/host/exists?name=foo'
```

This will return ”{'exists' ⇒ '0'}” if the host does not exist, ”{'exists' ⇒ '1'}” if it does.

## Fetching information for a specific contact

To fetch contact information without fetching the ID first

```
opsview_rest --token-file /path/to/opsview_restapi_token GET 'config/contact?s.name=admin'
```

## Create a new user

This shows creating a new user with the minimum fields specified while the `changelog` is enabled:

```
opsview_rest --token-file /path/to/opsview_restapi_token put 'config/contact' --data='{"name":"newname","fullname":"New Name","changelog":"New user"}'
```

## Amend a users role

```
opsview_rest --token-file /path/to/opsview_restapi_token put 'config/contact' --data='{"name":"newname","role": { "name":"Administrator"}}'
```


**Note**


For more information on how to generate and use the token file, see [opsview_rest](https://docs.itrsgroup.com/docs/opsview/current/rest-api/rest-api-background/api-common-examples/index.html#opsview_rest) documentation.




