Get your free beta license ↗
API operation · databases group
PUT

/databases/users/{name}/grants/{database}

First published 3 Oct 20260.1.0Unchanged since publication

Set a database user's privileges on a database

Who may call it
AdministratorResellerCustomer
Token scope, any of
databasesall
Answers200 OK

Use the exact database name. The database and the database user must belong to the same customer, and the caller must be allowed to act for that customer. MariaDB must be installed and database.enabled must be on.

Set level to full for ALL PRIVILEGES on the database, read-only for SELECT and SHOW VIEW, or custom to supply privileges such as SELECT, INSERT. The API returns 400 for an invalid level, a missing or incorrectly formatted custom privilege list, or a name or database value outside the allowed format of 1 to 64 ASCII letters, digits, or underscores. A database user outside the caller's permitted accounts is reported as not found.

UrbeStack resets the password and grants on every MariaDB account for the database user to the recorded values, including accounts for additional hosts. The response returns the updated database user in user.

As a command

Run as root on the server

Parameters

namepath ·DatabaseNameRequired
databasepath ·DatabaseNameRequired

Request body

JSON· 2 fields
levelstring, one of full, read-only, customRequired
privilegesstring
Comma-separated list of database-level privileges for level custom, up to 500 characters, excluding global privileges, FILE, and GRANT OPTION. Allowed privileges are SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, INDEX, REFERENCES, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, TRIGGER, EXECUTE, CREATE ROUTINE, ALTER ROUTINE, and EVENT.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X PUT "$API/databases/users/alice/grants/alice_shop" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "level": "full",
    "privileges": "text"
  }'
Response · 200 OK
{
  "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

8 errors, each a status and a sentence
400--name, --database and --level are required
400<db.name> is <db.user>'s and <name> is <user>'s: a user is granted only databases of the same customer
400A <what> name is 1 to 64 letters, digits or underscores
400A custom grant needs a privilege list of names separated by commas: SELECT, INSERT, ...
400The level is full, read-only or custom
401Authentication required
404No such database user:
404No such database:
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/put-databases-users-name-grants-database/