This topic describes how to create a user for a tenant by using obshell.
Note
This API is supported starting with obshell V4.2.6.
API details
Constraints
The obshell server performs security verification on the API. For more information, see API hybrid encryption.
Request path
POST /api/v1/tenant/{name}/user
Request parameters
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| user_name | string | Yes | proxyro | The name of the user to be created. |
| password | string | Yes | ***** | The password of the user to be created. |
| root_password | string | No | ***** | The password of the tenant's root user. This parameter is not required when you create a user in the sys tenant. |
| global_privileges | []string | No | ["SELECT", "DELETE"] | The privileges on all databases. |
| db_privileges | []DbPrivilegeParam | No | { "db_name": "oceanbase", "privileges": [ "DROP" ] } |
The privileges on specific databases. For more information, see the data structure of DbPrivilegeParam below. |
| host_name | string | No | % | The access allowlist. |
The data structure of DbPrivilegeParam is as follows:
| Parameter | Type | Required | Example value | Description |
|---|---|---|---|---|
| db_name | string | Yes | oceanbase | The name of the database. |
| privileges | []string | Yes | ["SELECT","DELETE"] | The privileges that the user can have. |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| successful | bool | Indicates whether the request was successful. |
| timestamp | time.Time | The timestamp when the server finishes processing the request. |
| duration | int | The time taken by the server to process the request, in milliseconds. |
| status | int | The HTTP status code that conforms to the HTTP status specification. |
| traceId | string | The Trace ID of the request. |
| error | ApiError | The error generated by the request, which contains the following information:
|
Examples
Request example
POST 10.10.10.1:2886/api/v1/tenant/sys/user
{
"user_name": "proxyro",
"password": "*****",
"global_privileges": [
"CREATE",
"DELETE"
],
"db_privileges": [
{
"db_name": "oceanbase",
"privileges": [
"DROP"
]
}
],
"host_name": "%"
}
Response example
{
"successful": true,
"timestamp": "2025-03-26T10:30:06.045600725+08:00",
"duration": 76,
"status": 200,
"traceId": "cdb313dd77a2f56a"
}
References
In addition to using the CLI to call the API, you can also use the SDK. For more information about how to request APIs by using obshell-sdk-python, see Create a user.