Attach user to database
Attaches an existing database user to a specific database by granting access permissions.
POST api/servers/{server}/databases/{database}/users/attach
Parameters
Parameter | Type | Status | Description |
---|---|---|---|
user_id | integer | required | The ID of an existing database user on this server to attach |
Example Request
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" \
--data '{"user_id": 123}'
Example Response
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"id": 123,
"user": "existing_user",
"remote": false,
"remote_ip": "%",
"readonly": false,
"created_at": "2022-02-16 10:45:34"
}
}
Error Responses
User Already Attached
HTTP/1.1 422 UNPROCESSABLE ENTITY
Content-Type: application/json
{
"message": "The given data was invalid",
"errors": {
"user": ["This user has already been attached to this database"]
}
}
User Not Found on Server
HTTP/1.1 404 NOT FOUND
Content-Type: application/json
{
"message": "Database user not found on this server"
}
Notes
- The database user must already exist on the server
- The user cannot be already attached to the target database
- This operation grants the user permissions to access the specified database
- The response returns the database user details after successful attachment
- The user cannot be already attached to the target database
- This operation grants the user permissions to access the specified database
- The response returns the database user details after successful attachment