Upvotes 0 Share PDF

Add a user to UCP using the API on the command line

You can add a user programmatically in UCP by using the UCP API along with the curl command.

First, get a UUID token for authentication:

curl -k -s -H "Content-Type: application/json" -X POST -d '{"username": "admin-username", "password": "admin-password"}' 'https://ucp-url/auth/login'

After retrieving the UUID token, you can add a user this way:

curl -k -H "Authorization: Bearer {auth-token}" -X POST https://ucp-url/api/accounts -d '{"username":"username", "password":"password", "first_name":"firstname", "role":1, "admin":true}'

For the role parameter, use one of the following values:

Number Value
0 No Access
1 View Only
2 Restricted Control
3 Full Control

Note: The UCP API is experimental and is subject to change in future versions, possibly affecting backwards compatibility.