# Web Cloud › Web Cloud DB › Users and grants › Users API

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

> 5 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/web-cloud/web-cloud-db/users-and-grants/users/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/web-cloud/web-cloud-db/users-and-grants/users.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/web-cloud/web-cloud-db/users-and-grants/users.json?format=openapi3

## Operations

- `GET /hosting/privateDatabase/{serviceName}/user` — List users
- `POST /hosting/privateDatabase/{serviceName}/user` — Create a user
- `GET /hosting/privateDatabase/{serviceName}/user/{userName}` — Get a user
- `DELETE /hosting/privateDatabase/{serviceName}/user/{userName}` — Delete a user
- `POST /hosting/privateDatabase/{serviceName}/user/{userName}/changePassword` — Change a user password

## List users

`GET /1.0/hosting/privateDatabase/{serviceName}/user`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/users-and-grants/users/#get-hosting-privatedatabase-servicename-user

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:user/get`

Returns the names of the users of the service.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | Service name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | string[] | successful operation |

```json
[
  "string"
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/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("/hosting/privateDatabase/{serviceName}/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("/hosting/privateDatabase/{serviceName}/user");

print_r($result);
?>
```

## Create a user

`POST /1.0/hosting/privateDatabase/{serviceName}/user`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/users-and-grants/users/#post-hosting-privatedatabase-servicename-user

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:user/create`

Creates a user on the service, with no rights on any database until a grant is added. The password must be alphanumeric and at least 8 characters long.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | Service name |

### Request body (required)

Type: `hosting.privateDatabase.User.CreatePayload`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `password` | string (password) | yes | Password for the new user ( alphanumeric and 8 characters minimum ) |
| `userName` | string | yes | User name used to connect on your databases |

```json
{
  "password": "string",
  "userName": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | hosting.privateDatabase.Task | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `databaseName` | string | read-only | Database name on which the task is working |
| `doneDate` | string (date-time) | read-only | Completion date |
| `dumpId` | integer | read-only | DumpId on which the task is working |
| `function` | hosting.privateDatabase.task.FunctionEnum | read-only | Function name — one of `abuse`, `changeFtpPassword`, `changeRam`, `changeVersion`, `configuration/update`, `create`, `database/copy`, `database/copyRestore`, `database/create`, `database/delete`, `database/dump`, `database/dump/delete`, … |
| `id` | integer | read-only | The id of the task |
| `lastUpdate` | string (date-time) | read-only | Last update |
| `startDate` | string (date-time) | read-only | Task creation date |
| `status` | hosting.privateDatabase.task.StatusEnum | read-only | Task status — one of `cancelled`, `doing`, `done`, `error`, `todo` |
| `userName` | string | read-only | User name on which the task is working |

```json
{
  "databaseName": "string",
  "doneDate": "2024-01-01T12:00:00Z",
  "dumpId": 0,
  "function": "abuse",
  "id": 0,
  "lastUpdate": "2024-01-01T12:00:00Z",
  "startDate": "2024-01-01T12:00:00Z",
  "status": "cancelled",
  "userName": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/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: hosting.privateDatabase.User.CreatePayload
result = client.post("/hosting/privateDatabase/{serviceName}/user",
	password = None, # Password for the new user ( alphanumeric and 8 characters minimum ) (type: string)
	userName = None, # User name used to connect on your databases (type: string)
)

# 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: hosting.privateDatabase.User.CreatePayload
$result = $ovh->post("/hosting/privateDatabase/{serviceName}/user", array(
	password => null, // Password for the new user ( alphanumeric and 8 characters minimum ) (type: string)
	userName => null, // User name used to connect on your databases (type: string)
));

print_r($result);
?>
```

## Get a user

`GET /1.0/hosting/privateDatabase/{serviceName}/user/{userName}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/users-and-grants/users/#get-hosting-privatedatabase-servicename-user-username

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:user/get`

Returns the creation date of the user and the databases it is granted on, with its rights.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | Service name |
| `userName` | path | string | yes | User name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | hosting.privateDatabase.User | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `creationDate` | string (date-time) | read-only | Creation date of the user |
| `databases` | hosting.privateDatabase.User.Database[] | read-only | Databases granted for this user |
| `databases[].databaseName` | string | read-only | Database granted for this user |
| `databases[].grantId` | integer | read-only | The grantId associated for this databaseName and this userName |
| `databases[].grantType` | hosting.privateDatabase.grant.GrantEnum | read-only | User's rights on this database — one of `admin`, `none`, `overquota_admin`, `overquota_rw`, `ro`, `rw` |
| `userName` | string | read-only | User name used to connect to your databases |

```json
{
  "creationDate": "2024-01-01T12:00:00Z",
  "databases": [
    {
      "databaseName": "string",
      "grantId": 0,
      "grantType": "admin"
    }
  ],
  "userName": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/user/{userName}" \
  -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("/hosting/privateDatabase/{serviceName}/user/{userName}")

# 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("/hosting/privateDatabase/{serviceName}/user/{userName}");

print_r($result);
?>
```

## Delete a user

`DELETE /1.0/hosting/privateDatabase/{serviceName}/user/{userName}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/users-and-grants/users/#delete-hosting-privatedatabase-servicename-user-username

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:user/delete`

Deletes the user and its grants. The databases are kept.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | Service name |
| `userName` | path | string | yes | User name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | hosting.privateDatabase.Task | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `databaseName` | string | read-only | Database name on which the task is working |
| `doneDate` | string (date-time) | read-only | Completion date |
| `dumpId` | integer | read-only | DumpId on which the task is working |
| `function` | hosting.privateDatabase.task.FunctionEnum | read-only | Function name — one of `abuse`, `changeFtpPassword`, `changeRam`, `changeVersion`, `configuration/update`, `create`, `database/copy`, `database/copyRestore`, `database/create`, `database/delete`, `database/dump`, `database/dump/delete`, … |
| `id` | integer | read-only | The id of the task |
| `lastUpdate` | string (date-time) | read-only | Last update |
| `startDate` | string (date-time) | read-only | Task creation date |
| `status` | hosting.privateDatabase.task.StatusEnum | read-only | Task status — one of `cancelled`, `doing`, `done`, `error`, `todo` |
| `userName` | string | read-only | User name on which the task is working |

```json
{
  "databaseName": "string",
  "doneDate": "2024-01-01T12:00:00Z",
  "dumpId": 0,
  "function": "abuse",
  "id": 0,
  "lastUpdate": "2024-01-01T12:00:00Z",
  "startDate": "2024-01-01T12:00:00Z",
  "status": "cancelled",
  "userName": "string"
}
```

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/user/{userName}" \
  -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("/hosting/privateDatabase/{serviceName}/user/{userName}")

# 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("/hosting/privateDatabase/{serviceName}/user/{userName}");

print_r($result);
?>
```

## Change a user password

`POST /1.0/hosting/privateDatabase/{serviceName}/user/{userName}/changePassword`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/users-and-grants/users/#post-hosting-privatedatabase-servicename-user-username-changepassword

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:user/changePassword`

Changes the password of the user. The password must be alphanumeric and at least 8 characters long.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `serviceName` | path | string | yes | Service name |
| `userName` | path | string | yes | User name |

### Request body (required)

Type: `hosting.privateDatabase.User.ChangePasswordPayload`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `password` | string (password) | yes | Password for the new user ( alphanumeric and 8 characters minimum ) |

```json
{
  "password": "string"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | hosting.privateDatabase.Task | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `databaseName` | string | read-only | Database name on which the task is working |
| `doneDate` | string (date-time) | read-only | Completion date |
| `dumpId` | integer | read-only | DumpId on which the task is working |
| `function` | hosting.privateDatabase.task.FunctionEnum | read-only | Function name — one of `abuse`, `changeFtpPassword`, `changeRam`, `changeVersion`, `configuration/update`, `create`, `database/copy`, `database/copyRestore`, `database/create`, `database/delete`, `database/dump`, `database/dump/delete`, … |
| `id` | integer | read-only | The id of the task |
| `lastUpdate` | string (date-time) | read-only | Last update |
| `startDate` | string (date-time) | read-only | Task creation date |
| `status` | hosting.privateDatabase.task.StatusEnum | read-only | Task status — one of `cancelled`, `doing`, `done`, `error`, `todo` |
| `userName` | string | read-only | User name on which the task is working |

```json
{
  "databaseName": "string",
  "doneDate": "2024-01-01T12:00:00Z",
  "dumpId": 0,
  "function": "abuse",
  "id": 0,
  "lastUpdate": "2024-01-01T12:00:00Z",
  "startDate": "2024-01-01T12:00:00Z",
  "status": "cancelled",
  "userName": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/user/{userName}/changePassword" \
  -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: hosting.privateDatabase.User.ChangePasswordPayload
result = client.post("/hosting/privateDatabase/{serviceName}/user/{userName}/changePassword",
	password = None, # Password for the new user ( alphanumeric and 8 characters minimum ) (type: string)
)

# 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: hosting.privateDatabase.User.ChangePasswordPayload
$result = $ovh->post("/hosting/privateDatabase/{serviceName}/user/{userName}/changePassword", array(
	password => null, // Password for the new user ( alphanumeric and 8 characters minimum ) (type: string)
));

print_r($result);
?>
```
