Create database user

Create a new user for a database.


POST/api/servers/{server}/databases/{database}/users

Create a database user

This endpoint allows you to create a new user for a database with optional remote access and readonly permissions.

Required attributes

  • Name
    user
    Type
    string
    Description

    The username. Allowed: alpha-numeric characters, no dashes allowed.

  • Name
    password
    Type
    string
    Description

    The password for the database user.

Optional attributes

  • Name
    remote
    Type
    boolean
    Description

    Whether the user should be remotely accessible.

  • Name
    remote_ip
    Type
    string
    Description

    The IP address this user connects from. Required if remote is true.

  • Name
    readonly
    Type
    boolean
    Description

    If the created user should only have readonly rights.

Request

POST
/api/servers/{server}/databases/{database}/users
curl -X POST "https://ploi.io/api/servers/{server}/databases/{database}/users" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "user": "my_user",
    "password": "db_password"
  }'

Response

{
  "data": {
    "id": 1,
    "user": "my_user",
    "remote": false,
    "remote_ip": "%",
    "readonly": false,
    "created_at": "2022-02-16 10:45:34"
  }
}