# POST /databases/users/{name}/adopt

First published 30 Nov 2026 (release 0.2.36) · Last changed 1 Dec 2026 (release 0.2.37)

UrbeStack release 0.2.39 API operation in the databases group.

Assign an existing MariaDB user name to a customer as a database user

- Who may call it: administrator
- Token scope, any of: databases, all
- Answers: 201 Created

Only administrators can call this operation. Set user to the customer who will own the database user for a MariaDB user name created outside UrbeStack. UrbeStack keeps the account's mysql_native_password hash so applications that sign in with the account keep working. It records grants on the customer's databases as full when the grant includes every privilege on the database, read-only when it includes only SELECT and SHOW VIEW, and custom for any other list of privileges. MariaDB treats an unescaped underscore in a grant as a wildcard. UrbeStack records such a grant for the database whose name matches the name in the grant literally. UrbeStack then applies the recorded grants to every existing account with that name and creates any missing localhost, 127.0.0.1 and ::1 accounts with the same hash. It creates the ::1 account only if IPv6 loopback is available. The operation returns the database user in user.

The API returns 400 if user is missing, is empty or does not identify a customer. It also returns 400 if name is reserved for phpMyAdmin sign-on, matches the name of one of MariaDB's own accounts (root or mysql), or falls outside the allowed format of 1 to 64 ASCII letters, digits or underscores. It returns 404 if MariaDB has no account with that name. It returns 409 if UrbeStack already has a database user with that name, if any account lacks a mysql_native_password hash or has more than one authentication method, or if passwords or grants differ across hosts. It also returns 409 if any account has a global privilege, GRANT OPTION, a role, a PROXY privilege, or a grant on a table, column, routine, name pattern, one of MariaDB's own databases or a database the customer does not own. It also returns 409 if two grants on the same host name the same database and differ in privileges, with the underscore escaped in only one grant. On a 409, the API lists every reason and makes no changes. To grant privileges on an unowned database, first adopt it with POST /databases/{name}/adopt.

## As a command

- [urbestack-database-user-adopt](https://urbestack.com/docs/commands/urbestack-database-user-adopt.md): Assigns a MariaDB user name created outside UrbeStack to the customer named by --user as one of the customer's database users.

## Parameters

- `name` (path, DatabaseName, required)

## Request body

JSON.

- `user` (Username, required): A username consists of lowercase letters, digits and underscores. For the user role, it also serves as the system account name.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/databases/users/alice/adopt" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "user": "alice"
  }'
```

Response, 201 Created:

```
{
  "user": {
    "created_at": "2026-09-09T10:15:00Z",
    "grants": [
      {
        "database": "alice_shop",
        "level": "full",
        "privileges": "text"
      }
    ],
    "id": 1,
    "name": "alice",
    "other_hosts": [
      "text"
    ],
    "updated_at": "text",
    "user": "alice",
    "user_id": 2
  }
}
```

## Errors

- 400: --name is required
- 400: A <what> name is 1 to 64 letters, digits or underscores
- 400: A custom grant needs a privilege list of names separated by commas: SELECT, INSERT, ...
- 400: A name beginning with <SIGNON_PREFIX> is the panel's own: its phpMyAdmin users
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: The level is full, read-only or custom
- 400: Username '<value>' is reserved
- 400: user is required: the customer the database user is given to
- 401: Authentication required
- 404: MariaDB has no account named <name>
- 409: <name> was not adopted: 
- 409: Database user <name> already exists

## Change log

Most recent first.

- 0.2.37 · 1 Dec 2026 · The operation now returns 409 for accounts with a role, a PROXY privilege, more than one authentication method, a grant on one of MariaDB's own databases, or two grants on the same host for the same database with different privileges. These accounts were previously eligible for adoption. The operation also returns 400 for root and mysql.
- 0.2.36 · 30 Nov 2026 · First published.
