Attach user to database

Grant an existing database user access to a specific database.


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

Attach user to database

This endpoint allows you to attach an existing database user to a specific database by granting access permissions.

Required attributes

  • Name
    user_id
    Type
    integer
    Description

    The ID of an existing database user on this server to attach.

Request

POST
/api/servers/{server}/databases/{database}/users/attach
curl -X POST "https://ploi.io/api/servers/{server}/databases/{database}/users/attach" \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "user_id": 123
  }'

Response

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

Errors

You may encounter these errors when attaching a user.

User already attached

{
  "message": "The given data was invalid",
  "errors": {
    "user": ["This user has already been attached to this database"]
  }
}

User not found

{
  "message": "Database user not found on this server"
}