How to create an API Key
Directus has a powerful API that allows you to connect your database with your projects. To start using the API, you will need an API key. This article will cover how to create an API key through Directus.
To create an API key, login to Directus and open the User Directory. Create a new user without a password and generate a token at the bottom.
The User Directory section contains all your Directus users. An API key is treated like any other user including the ability to assign a role with granular permissions.
Step 1 Create a User
Open the User Directory.
Click the Plus (+) icon to add a new user.
Use the First Name to give the user a descriptive name that appears in the internal activity logs. The Last Name can be used to group API accounts together using a common value such as SVC. The Email field is optional if you want to set up any notifications on the account's actions.
It is important to leave the password field blank so no one can log in using this account.
Step 2 Generate a Token (Key)
Scroll to the bottom of the page and you'll see the Token field. Click the Plus inside the field.
Next choose a Role for the API. Avoid using the Administrator role as this has its risks. Instead, create a new role that is specific to the function of this account. I created one called API, but you can create one using the Plus icon within the role field, then set the permissions to what you need. Give it a name the relevant to the purpose such as "Website API Read Only".
Save changes using the big tick at the top.
Conclusion
Now you know how to create new API keys and how to assign them to a role. Be sure to read how you can customize the permissions and secure your API key.
If you keen to know how to use your API key to Authentication your API queries, check out this article: