Method 1: Using API Endpoint
This action can be performed only by an authenticated admin/superuser.
Once authenticated, call the protected endpoint POST /admin with the following JSON body:
{
"identity": "{IDENTITY}",
"password": "{PASSWORD}",
"passwordConfirm": "{PASSWORD}",
"firstname": "{FIRSTNAME}",
"lastname": "{LASTNAME}",
"roles": ["{ROLE_UUID}"]
}
after replacing:
- {IDENTITY} with a valid username OR email address
- {PASSWORD} with a valid password
- {ROLE_UUID} with a valid admin role UUID (you can get a list of admin roles by calling the protected endpoint
GET /admin/role) - {FIRSTNAME} and {LASTNAME} are optional
Note: you can specify multiple admin roles under the roles key. If the submitted data is valid, the response will be similar to the below:
{
"uuid": "d436b044-be36-11eb-9eb1-78f29ef45f43",
"identity": "Letha_Runolfsson96",
"firstName": "Oswald",
"lastName": "Swift",
"status": "active",
"roles": ["{ROLE_UUID}"],
"created": {
"date": "2021-05-26 17:27:06.194613",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"updated": {
"date": "2021-05-26 17:27:06.279705",
"timezone_type": 3,
"timezone": "Europe/Berlin"
},
"_links": {
"self": {
"href": "http://localhost:8080/admin/d436b044-be36-11eb-9eb1-78f29ef45f43"
}
}
}
The new admin account is ready to use.
Method 2: Using Terminal Command
Run the following command in your application's root directory:
php ./bin/cli.php admin:create -i {IDENTITY} -p {PASSWORD}
or
php ./bin/cli.php admin:create --identity {IDENTITY} --password {PASSWORD}
after replacing:
- {IDENTITY} with a valid username OR email address
- {PASSWORD} with a valid password
Note:
- if the specified identity or password contain special characters, make sure you surround them with double quote signs
- this method does not allow specifying an admin role - newly created accounts will have the role of admin
If the submitted data is valid, the outputted response is:
Admin account has been created.
The new admin account is ready to use. You can get more help with this command by running:
php ./bin/cli.php help admin:create
Frequently Asked Questions
What are the two ways to create an admin account in Dotkernel API? +
You can either call the protected API endpoint `POST /admin` with a JSON body, or run the terminal command `php ./bin/cli.php admin:create`.
Who can create an admin account via the API endpoint? +
This action can be performed only by an authenticated admin/superuser, calling the protected `POST /admin` endpoint.
What data does the POST /admin request body need? +
identity, password, passwordConfirm, and roles (one or more valid admin role UUIDs, obtainable via the protected `GET /admin/role` endpoint). firstname and lastname are optional.
What role does an admin get when created via the terminal command? +
The terminal command doesn't allow specifying an admin role, so newly created accounts are given the role of admin.
How do I get more help with the admin:create command? +
Run `php ./bin/cli.php help admin:create`. Also note that if the identity or password contain special characters, they must be surrounded with double quote signs.