Create a Limited Sub-User Profile with API Access at Vultr
Introduction
You can share Vultr account access without sharing login credentials by adding sub-user profiles and restricting the access granted to the sub-users. This guide explains how you can add a limited sub-user profile to your account, enable API access, and then test the sub-user's API access with cURL.
Prerequisites
Before proceeding with this guide, you must have:
- A Vultr account. This account will serve as the main or root account where you will add the sub-user profiles.
- An email account that is not registered at Vultr. This email account will be registered as a sub-user profile of your main account. You cannot add an existing Vultr account as a sub-account.
Create a Limited Sub-User Profile
On your main Vultr account, go to your Users Settings and click Add New User.
On the Name text field, enter a name for your sub-user profile.
On the Email text field, enter the email address unregistered to Vultr.
On the Password text field, you can use the pre-generated Random password or your preferred password by selecting Custom from the dropdown menu.
Grant privileges to the sub-user profile by enabling these permissions:
Manage Users - This allows the sub-user to create and edit other sub-users on your main account.
Warning: Manage Users serves as a super user permission. Enabling this option will grant the sub-user the same privileges the main account has.
Manage Servers - This allows the sub-user to manage and destroy server instances on your main account. Enabling this permission will also enable the View Servers permission.
View Servers - This allows the sub-user to view or access the server instances on your main account.
Deploy New Servers - This allows the sub-user to Deploy server instances on your main account.
Upgrade Existing Servers - This allows the sub-user to upgrade existing server instances, such as adding paid add-ons like DDOS protection or auto backups or upgrading the server instance's size.
Manage Billing - This allows the sub-user to access your main account's billing section and receive billing notices.
Create Support Tickets - This allows the sub-user to access your main account's support section. It includes creating new tickets and closing or replying to existing tickets.
Manage DNS - This allows the sub-user to manage your main account's DNS Settings. It includes adding a Domain and managing its records.
Manage Firewall - This allows the sub-user to manage your main account's Firewall Settings. It includes adding a new Firewall Group or editing and deleting existing firewall groups.
Manage Object Storage - This allows the sub-user to manage your main account's Object Storage. It includes creating and deleting an Object Storage and managing the buckets inside your object storage.
Manage Load Balancers - This allows the sub-user to create, manage, and destroy load balancers on your main account.
Manage Vultr Kubernetes Engines - This allows the sub-user to create, manage, and destroy Kurbernetes Clusters on your main account.
Receive AUP/ToS Notifications - This allows the sub-user to receive Acceptable Use Policy (AUP) and Terms of Service (TOS) Notifications through email.
Receive Maintenance Notifications - This allows the sub-user to receive notifications through email when a Vultr server location undergoes maintenance or if there is an ongoing outage.
After granting privileges to the sub-user, click the Add User button to create the account.
After creating the sub-user account, you can still edit the sub-user profile's information and permissions by clicking the pencil icon from the Users Settings.
Test Sub-User API Access with cURL
Log in to Vultr using the sub-user account.
Go to your account's API Settings, then copy and save your sub-user account's API Key.
Under the Access Control section, click the Allow All IPv4 and Allow All IPv6 buttons to allow API access to any IP address.
Open your terminal or command prompt.
Test the sub-user's API access by getting your account's information. Before running the command below, ensure you have enabled the Manage Billing permission for your sub-user, or it will return an error 401.
Run this command on your terminal or command prompt:
curl "https://api.vultr.com/v2/account" -X GET -H "Authorization: Bearer YOUR-API-KEY-HERE"
Replace
YOUR-API-KEY-HERE
with your sub-user's API Key that you saved in step 2. It should return something like this:{"account":{"balance":-123.123,"pending_charges":1.1,"name":"Your Name","email":"youremail@example.com","acls":["billing"],"last_payment_date":"2022-08-21T17:50:25+00:00","last_payment_amount":-123}}
Notice that the information returned is your main account's information, but the acls only contain the permissions enabled on the sub-user profile.
Conclusion
You have successfully added a sub-user profile to your account and enabled its API access. Control and assign specific privileges or permissions to your team without sharing your login credentials and your API Key because each sub-user has their own personal API Key. To learn more about Vultr's API or for more API examples, please see Vultr's API documentation.