# POST /databases/users

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the databases group.

Create a database user

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

MariaDB creates an account for localhost and another for 127.0.0.1. It also creates an account for ::1 when IPv6 loopback is available. All accounts use the supplied password and start with no grants. The response returns the created database user in user.

Administrators must supply user to name the customer and can choose any valid name. Customers create database users for themselves. Resellers can create database users for themselves or supply user to select one of their customers. For customers and resellers, name must start with the owner's username followed by an underscore, as in CUSTOMER_.

The API returns 400 for an administrator request without user or for a name outside the allowed format of 1 to 64 ASCII letters, digits, or underscores. UrbeStack refuses names already in use, including names created directly in MariaDB, and names reserved for phpMyAdmin sign-on.

## As a command

- [urbestack-database-user-add](https://urbestack.com/docs/commands/urbestack-database-user-add.md): Creates a database user for a customer.

## Request body

JSON.

- `name` (DatabaseName, required): A database or database user name can contain up to 64 letters, digits, and underscores. For a customer, UrbeStack forms the name as <username>_<what they type> and converts it to lowercase, while an administrator specifies the full name.
- `password` (string, up to 128 characters, required)
- `user` (Username): 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" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "alice",
    "password": "Sup3r-Secret-Passphrase",
    "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 name beginning with <SIGNON_PREFIX> is the panel's own: its phpMyAdmin users
- 400: A password is required: --password-stdin or --password-hash
- 400: Invalid password: 8 to 128 printable characters
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Username '<value>' is reserved
- 400: user is required: the customer the database is for
- 401: Authentication required
- 409: Database user <name> already exists
- 409: Database user <name> exists in MariaDB outside the panel; drop it at a shell, or name another
