# Public Cloud › Databases › MongoDB › Users API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Public Cloud product's sections: https://developers.eu.ovhcloud.com/reference/public-cloud/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 9 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/public-cloud/databases/mongodb/users.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/public-cloud/databases/mongodb/users.json?format=openapi3

## Operations

- `GET /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user` — List users
- `GET /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}` — Get a user
- `POST /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user` — Create a user
- `DELETE /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}` — Delete a user
- `PUT /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}` — Update a user
- `PATCH /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}` — Partially update a user
- `GET /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles` — List roles
- `POST /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}/resetPassword` — Reset the password of a user
- `GET /publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles/{roleId}` — Get a role

## List users

`GET /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#get-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-user

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/user/get`

Returns the users of the service with their roles and status. Passwords are not returned.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Pagination-Cursor` | header | string |  | Pagination cursor |
| `X-Pagination-Size` | header | integer |  | Pagination size |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.UserWithRoles[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `admin` | boolean | read-only | Whether this is the service administrator, the user created automatically at provisioning time, which cannot be deleted |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the user was created |
| `credentialsLastUpdatedAt` | string (date-time) | read-only | Date at which the user credentials were last updated |
| `id` | string (uuid) | read-only | Unique identifier of the user |
| `password` | string (password) | read-only | Password of the user. Returned only on creation or password reset. |
| `roles` | string[] | read-only | List of roles assigned to the user. Available roles depend on the engine. |
| `status` | publicCloud.database.UserStatusEnum | read-only | Current readiness status of the user — one of `CREATING`, `DELETING`, `ERROR`, `READY`, `UPDATING` |
| `username` | string | read-only | Login name of the user |

```json
[
  {
    "admin": true,
    "checksum": "string",
    "createdAt": "2024-01-01T12:00:00Z",
    "credentialsLastUpdatedAt": "2024-01-01T12:00:00Z",
    "id": "00000000-0000-0000-0000-000000000000",
    "password": "string",
    "roles": [
      "string"
    ],
    "status": "CREATING",
    "username": "string"
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user");

print_r($result);
?>
```

## Get a user

`GET /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#get-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-user-userid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/user/get`

Returns the user, its roles and its status. The password is not returned.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `userId` | path | string (uuid) | yes | User ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.UserWithRoles | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `admin` | boolean | read-only | Whether this is the service administrator, the user created automatically at provisioning time, which cannot be deleted |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the user was created |
| `credentialsLastUpdatedAt` | string (date-time) | read-only | Date at which the user credentials were last updated |
| `id` | string (uuid) | read-only | Unique identifier of the user |
| `password` | string (password) | read-only | Password of the user. Returned only on creation or password reset. |
| `roles` | string[] | read-only | List of roles assigned to the user. Available roles depend on the engine. |
| `status` | publicCloud.database.UserStatusEnum | read-only | Current readiness status of the user — one of `CREATING`, `DELETING`, `ERROR`, `READY`, `UPDATING` |
| `username` | string | read-only | Login name of the user |

```json
{
  "admin": true,
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "credentialsLastUpdatedAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "password": "string",
  "roles": [
    "string"
  ],
  "status": "CREATING",
  "username": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}");

print_r($result);
?>
```

## Create a user

`POST /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#post-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-user

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/user/create`

Creates a user with the given roles and generates its password. The password is returned only on creation and on password reset.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |

### Request body (required)

Type: `publicCloud.database.UserWithRolesCreation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes | Login name of the new user |
| `roles` | string[] |  | List of roles to assign to the user. Available roles depend on the engine. |

```json
{
  "name": "string",
  "roles": [
    "string"
  ]
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.UserWithRoles | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `admin` | boolean | read-only | Whether this is the service administrator, the user created automatically at provisioning time, which cannot be deleted |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the user was created |
| `credentialsLastUpdatedAt` | string (date-time) | read-only | Date at which the user credentials were last updated |
| `id` | string (uuid) | read-only | Unique identifier of the user |
| `password` | string (password) | read-only | Password of the user. Returned only on creation or password reset. |
| `roles` | string[] | read-only | List of roles assigned to the user. Available roles depend on the engine. |
| `status` | publicCloud.database.UserStatusEnum | read-only | Current readiness status of the user — one of `CREATING`, `DELETING`, `ERROR`, `READY`, `UPDATING` |
| `username` | string | read-only | Login name of the user |

```json
{
  "admin": true,
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "credentialsLastUpdatedAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "password": "string",
  "roles": [
    "string"
  ],
  "status": "CREATING",
  "username": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.database.UserWithRolesCreation
result = client.post("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user",
	name = None, # Login name of the new user (type: string)
	roles = None, # List of roles to assign to the user. Available roles depend on the engine. (type: array, nullable)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.database.UserWithRolesCreation
$result = $ovh->post("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user", array(
	name => null, // Login name of the new user (type: string)
	roles => null, // List of roles to assign to the user. Available roles depend on the engine. (type: array, nullable)
));

print_r($result);
?>
```

## Delete a user

`DELETE /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#delete-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-user-userid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/user/delete`

Permanently deletes the user.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `userId` | path | string (uuid) | yes | User ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.UserWithRoles | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `admin` | boolean | read-only | Whether this is the service administrator, the user created automatically at provisioning time, which cannot be deleted |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the user was created |
| `credentialsLastUpdatedAt` | string (date-time) | read-only | Date at which the user credentials were last updated |
| `id` | string (uuid) | read-only | Unique identifier of the user |
| `password` | string (password) | read-only | Password of the user. Returned only on creation or password reset. |
| `roles` | string[] | read-only | List of roles assigned to the user. Available roles depend on the engine. |
| `status` | publicCloud.database.UserStatusEnum | read-only | Current readiness status of the user — one of `CREATING`, `DELETING`, `ERROR`, `READY`, `UPDATING` |
| `username` | string | read-only | Login name of the user |

```json
{
  "admin": true,
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "credentialsLastUpdatedAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "password": "string",
  "roles": [
    "string"
  ],
  "status": "CREATING",
  "username": "string"
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}");

print_r($result);
?>
```

## Update a user

`PUT /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#put-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-user-userid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/user/edit`

Updates the roles of the user. The roles list replaces the current roles. To reset the password, use the resetPassword route of the user or a partial update with credentialsLastUpdatedAt.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `userId` | path | string (uuid) | yes | User ID |

### Request body (required)

Type: `publicCloud.database.UserReplace`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `roles` | string[] | yes | List of roles to assign to the user. Available roles depend on the engine. |

```json
{
  "roles": [
    "string"
  ]
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.UserWithRoles | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `admin` | boolean | read-only | Whether this is the service administrator, the user created automatically at provisioning time, which cannot be deleted |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the user was created |
| `credentialsLastUpdatedAt` | string (date-time) | read-only | Date at which the user credentials were last updated |
| `id` | string (uuid) | read-only | Unique identifier of the user |
| `password` | string (password) | read-only | Password of the user. Returned only on creation or password reset. |
| `roles` | string[] | read-only | List of roles assigned to the user. Available roles depend on the engine. |
| `status` | publicCloud.database.UserStatusEnum | read-only | Current readiness status of the user — one of `CREATING`, `DELETING`, `ERROR`, `READY`, `UPDATING` |
| `username` | string | read-only | Login name of the user |

```json
{
  "admin": true,
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "credentialsLastUpdatedAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "password": "string",
  "roles": [
    "string"
  ],
  "status": "CREATING",
  "username": "string"
}
```

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.database.UserReplace
result = client.put("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}",
	roles = None, # List of roles to assign to the user. Available roles depend on the engine. (type: array)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.database.UserReplace
$result = $ovh->put("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}", array(
	roles => null, // List of roles to assign to the user. Available roles depend on the engine. (type: array)
));

print_r($result);
?>
```

## Partially update a user

`PATCH /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#patch-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-user-userid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/user/edit`

Partially updates the roles of the user. The roles list replaces the current roles. Setting credentialsLastUpdatedAt resets the password and returns the new one.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `userId` | path | string (uuid) | yes | User ID |

### Request body (required)

Type: `publicCloud.database.UserUpdate`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `credentialsLastUpdatedAt` | string (date-time) |  | Date at which the user credentials were last updated. Setting this field triggers a credential reset and returns the new password. |
| `roles` | string[] |  | List of roles to assign to the user. Available roles depend on the engine. |

```json
{
  "credentialsLastUpdatedAt": "2024-01-01T12:00:00Z",
  "roles": [
    "string"
  ]
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.UserWithRoles | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `admin` | boolean | read-only | Whether this is the service administrator, the user created automatically at provisioning time, which cannot be deleted |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the user was created |
| `credentialsLastUpdatedAt` | string (date-time) | read-only | Date at which the user credentials were last updated |
| `id` | string (uuid) | read-only | Unique identifier of the user |
| `password` | string (password) | read-only | Password of the user. Returned only on creation or password reset. |
| `roles` | string[] | read-only | List of roles assigned to the user. Available roles depend on the engine. |
| `status` | publicCloud.database.UserStatusEnum | read-only | Current readiness status of the user — one of `CREATING`, `DELETING`, `ERROR`, `READY`, `UPDATING` |
| `username` | string | read-only | Login name of the user |

```json
{
  "admin": true,
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "credentialsLastUpdatedAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "password": "string",
  "roles": [
    "string"
  ],
  "status": "CREATING",
  "username": "string"
}
```

### Example

```bash
curl -X PATCH \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: publicCloud.database.UserUpdate
result = client.patch("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}",
	credentialsLastUpdatedAt = None, # Date at which the user credentials were last updated. Setting this field triggers a credential reset and returns the new password. (type: string)
	roles = None, # List of roles to assign to the user. Available roles depend on the engine. (type: array, nullable)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: publicCloud.database.UserUpdate
$result = $ovh->patch("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}", array(
	credentialsLastUpdatedAt => null, // Date at which the user credentials were last updated. Setting this field triggers a credential reset and returns the new password. (type: string)
	roles => null, // List of roles to assign to the user. Available roles depend on the engine. (type: array, nullable)
));

print_r($result);
?>
```

## List roles

`GET /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#get-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-roles

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/roles/get`

Returns the roles that can be assigned to users.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Pagination-Cursor` | header | string |  | Pagination cursor |
| `X-Pagination-Size` | header | integer |  | Pagination size |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.Role[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the resource was created |
| `id` | string (uuid) | read-only | Unique identifier of the role |
| `name` | string | read-only | Name of the role |
| `updatedAt` | string (date-time) | read-only | Date of the last update to the resource |

```json
[
  {
    "checksum": "string",
    "createdAt": "2024-01-01T12:00:00Z",
    "id": "00000000-0000-0000-0000-000000000000",
    "name": "string",
    "updatedAt": "2024-01-01T12:00:00Z"
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles");

print_r($result);
?>
```

## Reset the password of a user

`POST /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}/resetPassword`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#post-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-user-userid-resetpassword

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/user/credentials/reset`

Generates a new password for the user and returns it in the response. Reading the user never returns it. The previous password stops working once the new one is applied, and credentialsLastUpdatedAt becomes the date of this reset. This is the same reset as a partial update of the user that sets credentialsLastUpdatedAt.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `serviceId` | path | string (uuid) | yes | Service ID |
| `userId` | path | string (uuid) | yes | User ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.UserWithRoles | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `admin` | boolean | read-only | Whether this is the service administrator, the user created automatically at provisioning time, which cannot be deleted |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the user was created |
| `credentialsLastUpdatedAt` | string (date-time) | read-only | Date at which the user credentials were last updated |
| `id` | string (uuid) | read-only | Unique identifier of the user |
| `password` | string (password) | read-only | Password of the user. Returned only on creation or password reset. |
| `roles` | string[] | read-only | List of roles assigned to the user. Available roles depend on the engine. |
| `status` | publicCloud.database.UserStatusEnum | read-only | Current readiness status of the user — one of `CREATING`, `DELETING`, `ERROR`, `READY`, `UPDATING` |
| `username` | string | read-only | Login name of the user |

```json
{
  "admin": true,
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "credentialsLastUpdatedAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "password": "string",
  "roles": [
    "string"
  ],
  "status": "CREATING",
  "username": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}/resetPassword" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.post("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}/resetPassword")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->post("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/user/{userId}/resetPassword");

print_r($result);
?>
```

## Get a role

`GET /v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles/{roleId}`

Link: https://developers.eu.ovhcloud.com/reference/public-cloud/databases/mongodb/users/#get-publiccloud-project-projectid-manageddatabase-mongodb-serviceid-roles-roleid

**Status:** Beta version  
**IAM actions:** `publicCloudProject:apiovh:database/mongodb/roles/get`

Returns a role that can be assigned to users.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `projectId` | path | string | yes | Project ID |
| `roleId` | path | string (uuid) | yes | Role ID |
| `serviceId` | path | string (uuid) | yes | Service ID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | publicCloud.database.Role | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `checksum` | string | read-only | Hash of the resource used for concurrency control |
| `createdAt` | string (date-time) | read-only | Date at which the resource was created |
| `id` | string (uuid) | read-only | Unique identifier of the role |
| `name` | string | read-only | Name of the role |
| `updatedAt` | string (date-time) | read-only | Date of the last update to the resource |

```json
{
  "checksum": "string",
  "createdAt": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "name": "string",
  "updatedAt": "2024-01-01T12:00:00Z"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles/{roleId}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles/{roleId}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/v2/publicCloud/project/{projectId}/managedDatabase/mongodb/{serviceId}/roles/{roleId}");

print_r($result);
?>
```
