> For the complete documentation index, see [llms.txt](https://docs.ionos.com/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/cloud/java/dbaas-mongodb/api/usersapi.md).

# UsersApi

## UsersApi

All URIs are relative to *<https://api.ionos.com/databases/mongodb>*

| Method                                              | HTTP request                                      | Description                 |
| --------------------------------------------------- | ------------------------------------------------- | --------------------------- |
| [**clustersUsersDelete**](#clustersusersdelete)     | **DELETE** /clusters/{clusterId}/users/{username} | Delete a MongoDB User by ID |
| [**clustersUsersFindById**](#clustersusersfindbyid) | **GET** /clusters/{clusterId}/users/{username}    | Get a MongoDB User by ID    |
| [**clustersUsersGet**](#clustersusersget)           | **GET** /clusters/{clusterId}/users               | Get all Cluster Users       |
| [**clustersUsersPatch**](#clustersuserspatch)       | **PATCH** /clusters/{clusterId}/users/{username}  | Patch a MongoDB User by ID  |
| [**clustersUsersPost**](#clustersuserspost)         | **POST** /clusters/{clusterId}/users              | Create MongoDB User         |

## **clustersUsersDelete**

> User clustersUsersDelete(clusterId, username)

Delete a MongoDB User by ID

Deletes a MongoDB user specified by its ID.

#### Example

```java
// Import classes:
import com.ionoscloud.dbaasmongo.ApiClient;
import com.ionoscloud.dbaasmongo.ApiException;
import com.ionoscloud.dbaasmongo.Configuration;
import com.ionoscloud.dbaasmongo.auth.*;
import com.ionoscloud.dbaasmongo.model.*;
import com.ionoscloud.dbaasmongo.api.UsersApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    
    // Configure HTTP basic authorization: basicAuth
    HttpBasicAuth basicAuthentication = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
    basicAuthentication.setUsername("YOUR USERNAME");
    basicAuthentication.setPassword("YOUR PASSWORD");


    UsersApi apiInstance = new UsersApi(defaultClient);
    String clusterId = "clusterId_example"; // String | The unique ID of the cluster.
    String username = "username_example"; // String | The authentication username.
    try {
      User result = apiInstance.clustersUsersDelete(clusterId, username);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsersApi#clustersUsersDelete");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

⚠️ **Note**: for the example above, you need to provide all parameters to the method call. Null values will resolve to the API defaults.

#### Parameters

| Name          | Type       | Description                   | Notes |
| ------------- | ---------- | ----------------------------- | ----- |
| **clusterId** | **String** | The unique ID of the cluster. |       |
| **username**  | **String** | The authentication username.  |       |

#### Return type

[**User**](https://docs.ionos.com/cloud/java/dbaas-mongodb/models/user.md)

#### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## **clustersUsersFindById**

> User clustersUsersFindById(clusterId, username)

Get a MongoDB User by ID

Retrieves the MongoDB user identified by the username.

#### Example

```java
// Import classes:
import com.ionoscloud.dbaasmongo.ApiClient;
import com.ionoscloud.dbaasmongo.ApiException;
import com.ionoscloud.dbaasmongo.Configuration;
import com.ionoscloud.dbaasmongo.auth.*;
import com.ionoscloud.dbaasmongo.model.*;
import com.ionoscloud.dbaasmongo.api.UsersApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    
    // Configure HTTP basic authorization: basicAuth
    HttpBasicAuth basicAuthentication = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
    basicAuthentication.setUsername("YOUR USERNAME");
    basicAuthentication.setPassword("YOUR PASSWORD");


    UsersApi apiInstance = new UsersApi(defaultClient);
    String clusterId = "clusterId_example"; // String | The unique ID of the cluster.
    String username = "username_example"; // String | The authentication username.
    try {
      User result = apiInstance.clustersUsersFindById(clusterId, username);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsersApi#clustersUsersFindById");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

⚠️ **Note**: for the example above, you need to provide all parameters to the method call. Null values will resolve to the API defaults.

#### Parameters

| Name          | Type       | Description                   | Notes |
| ------------- | ---------- | ----------------------------- | ----- |
| **clusterId** | **String** | The unique ID of the cluster. |       |
| **username**  | **String** | The authentication username.  |       |

#### Return type

[**User**](https://docs.ionos.com/cloud/java/dbaas-mongodb/models/user.md)

#### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## **clustersUsersGet**

> UsersList clustersUsersGet(clusterId, limit, offset)

Get all Cluster Users

Retrieves a list of MongoDB users.

#### Example

```java
// Import classes:
import com.ionoscloud.dbaasmongo.ApiClient;
import com.ionoscloud.dbaasmongo.ApiException;
import com.ionoscloud.dbaasmongo.Configuration;
import com.ionoscloud.dbaasmongo.auth.*;
import com.ionoscloud.dbaasmongo.model.*;
import com.ionoscloud.dbaasmongo.api.UsersApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    
    // Configure HTTP basic authorization: basicAuth
    HttpBasicAuth basicAuthentication = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
    basicAuthentication.setUsername("YOUR USERNAME");
    basicAuthentication.setPassword("YOUR PASSWORD");


    UsersApi apiInstance = new UsersApi(defaultClient);
    String clusterId = "clusterId_example"; // String | The unique ID of the cluster.
    Integer limit = 100; // Integer | The maximum number of elements to return. Use together with 'offset' for pagination.
    Integer offset = 0; // Integer | The first element to return. Use together with 'limit' for pagination.
    try {
      UsersList result = apiInstance.clustersUsersGet(clusterId, limit, offset);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsersApi#clustersUsersGet");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

⚠️ **Note**: for the example above, you need to provide all parameters to the method call. Null values will resolve to the API defaults.

#### Parameters

| Name          | Type        | Description                                                                          | Notes                         |
| ------------- | ----------- | ------------------------------------------------------------------------------------ | ----------------------------- |
| **clusterId** | **String**  | The unique ID of the cluster.                                                        |                               |
| **limit**     | **Integer** | The maximum number of elements to return. Use together with 'offset' for pagination. | \[optional] \[default to 100] |
| **offset**    | **Integer** | The first element to return. Use together with 'limit' for pagination.               | \[optional] \[default to 0]   |

#### Return type

[**UsersList**](https://docs.ionos.com/cloud/java/dbaas-mongodb/models/userslist.md)

#### HTTP request headers

* **Content-Type**: Not defined
* **Accept**: application/json

## **clustersUsersPatch**

> User clustersUsersPatch(clusterId, username, patchUserRequest)

Patch a MongoDB User by ID

Patches a MongoDB user specified by its ID.

#### Example

```java
// Import classes:
import com.ionoscloud.dbaasmongo.ApiClient;
import com.ionoscloud.dbaasmongo.ApiException;
import com.ionoscloud.dbaasmongo.Configuration;
import com.ionoscloud.dbaasmongo.auth.*;
import com.ionoscloud.dbaasmongo.model.*;
import com.ionoscloud.dbaasmongo.api.UsersApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    
    // Configure HTTP basic authorization: basicAuth
    HttpBasicAuth basicAuthentication = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
    basicAuthentication.setUsername("YOUR USERNAME");
    basicAuthentication.setPassword("YOUR PASSWORD");


    UsersApi apiInstance = new UsersApi(defaultClient);
    String clusterId = "clusterId_example"; // String | The unique ID of the cluster.
    String username = "username_example"; // String | The authentication username.
    PatchUserRequest patchUserRequest = new PatchUserRequest(); // PatchUserRequest | Part of the MongoDB user which should be modified.
    try {
      User result = apiInstance.clustersUsersPatch(clusterId, username, patchUserRequest);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsersApi#clustersUsersPatch");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

⚠️ **Note**: for the example above, you need to provide all parameters to the method call. Null values will resolve to the API defaults.

#### Parameters

| Name                 | Type                                                                                                                    | Description                                        | Notes |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ----- |
| **clusterId**        | **String**                                                                                                              | The unique ID of the cluster.                      |       |
| **username**         | **String**                                                                                                              | The authentication username.                       |       |
| **patchUserRequest** | [**PatchUserRequest**](https://github.com/ionos-cloud/sdk-java-dbaas-mongo/blob/master/docs/models/PatchUserRequest.md) | Part of the MongoDB user which should be modified. |       |

#### Return type

[**User**](https://docs.ionos.com/cloud/java/dbaas-mongodb/models/user.md)

#### HTTP request headers

* **Content-Type**: application/json
* **Accept**: application/json

## **clustersUsersPost**

> User clustersUsersPost(clusterId, user)

Create MongoDB User

Creates a MongoDB user.

#### Example

```java
// Import classes:
import com.ionoscloud.dbaasmongo.ApiClient;
import com.ionoscloud.dbaasmongo.ApiException;
import com.ionoscloud.dbaasmongo.Configuration;
import com.ionoscloud.dbaasmongo.auth.*;
import com.ionoscloud.dbaasmongo.model.*;
import com.ionoscloud.dbaasmongo.api.UsersApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    
    // Configure HTTP basic authorization: basicAuth
    HttpBasicAuth basicAuthentication = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
    basicAuthentication.setUsername("YOUR USERNAME");
    basicAuthentication.setPassword("YOUR PASSWORD");


    UsersApi apiInstance = new UsersApi(defaultClient);
    String clusterId = "clusterId_example"; // String | The unique ID of the cluster.
    User user = new User(); // User | The user to be created.
    try {
      User result = apiInstance.clustersUsersPost(clusterId, user);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling UsersApi#clustersUsersPost");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

⚠️ **Note**: for the example above, you need to provide all parameters to the method call. Null values will resolve to the API defaults.

#### Parameters

| Name          | Type                                                                       | Description                   | Notes |
| ------------- | -------------------------------------------------------------------------- | ----------------------------- | ----- |
| **clusterId** | **String**                                                                 | The unique ID of the cluster. |       |
| **user**      | [**User**](https://docs.ionos.com/cloud/java/dbaas-mongodb/models/user.md) | The user to be created.       |       |

#### Return type

[**User**](https://docs.ionos.com/cloud/java/dbaas-mongodb/models/user.md)

#### HTTP request headers

* **Content-Type**: application/json
* **Accept**: application/json


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ionos.com/cloud/java/dbaas-mongodb/api/usersapi.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
