Skip to content

Create database user

POST /api/v2/shared-hosting/{accountId}/database-users

Create a MySQL user on a web hosting account. The account must be active (403 forbidden otherwise) and on cPanel (409 account_not_eligible_cpanel otherwise). The API does not add the account’s name prefix. When the account’s databases are named like abcde_wp_example, start the user name with the same prefix. The new user has no access to any database yet. Link it with POST /api/v2/shared-hosting/{accountId}/database-users/{username}/privileges. The response never repeats the password.

Authentication: An API key with the scopes write:hosting and console:services. About keys and scopes

Request

Path parameters

accountIdstringrequired
The web hosting account ID (acct_…).

Body

usernamestringrequired
The MySQL user name. Letters, digits and underscores. The API accepts up to 64 characters. The database server takes at most 32, the prefix included. A longer name answers 502 upstream_failed.
passwordstringrequired
8-128 characters with uppercase, lowercase, and a number. It must also be hard to guess. The user name inside the password counts against it. Generate your own.

Example

POST /api/v2/shared-hosting/{accountId}/database-users
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/database-users" \
-H "Authorization: Bearer $HOSTUP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"username": "abcde_wp_exampleuser",
"password": "Amber-Ladder-41-Orchard"
}'

Responses

201 Database user created.

Response 201
{
"id": "dbu_01hxa3b4c5d6e7f8g9h0j1k2m3",
"username": "abcde_wp_exampleuser",
"host": null,
"databases": []
}
Response fields
idstring
The database user ID (dbu_…).
usernamestring
The MySQL user name.
hoststring or null
Always null here.
databasesarray of string
Always empty on creation.

Errors

Errors are Problem Details with a stable code. Branch on the code, not on the text.

400password_too_weak: detail names the broken rule. The body also has minimumScore (3). When the password is easy to guess, it also has score and suggestions. Show suggestions to the user. invalid_request with pointer /body: a field is missing or empty, username has other characters than letters, digits and underscores, or password is longer than 128 characters.
401Unauthorized. Authentication is required.
403forbidden. With requiredScopes in the body, the key lacks a scope. The key needs all the scopes in that list, although detail asks for one of them. Without requiredScopes, the hosting account is not active. Check serviceStatus on GET /api/v2/shared-hosting/{accountId}.
404Not found. The resource does not exist or is not owned by the caller.
409account_not_eligible_cpanel: the account is on Hostup’s previous hosting platform. Support moves it to cPanel at no charge.
429Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
500Internal error. Retry later or contact support if the issue persists.
502upstream_failed: the control panel did not create the user. The usual causes are a user name that is already taken, one longer than 32 characters, or one without the account’s prefix on a server that uses prefixes. Sending the same name again fails the same way. Check the names with GET /api/v2/shared-hosting/{accountId}/database-users first.