Generate an API key
Maintainers:
When designing for the generation of API keys, ensure users know what the key is created for, the security implications, and the end destination of the key.
![Example of an API key being generated Example of an API key being generated](/static/3aff5ce4778f1039f31d197c8842a81d/3cbba/1.png)
An example of API key generation with restricted access options
General access keys
Instant generation
Users click a primary Generate button. Consider displaying a Generating… state if the API key takes time to generate.
![Example of a generate button Example of a generate button](/static/c525c4e597996d854f05bee6e2603269/3cbba/2.png)
Once the API key is generated it displays in a modal. Include a Copy button.
![Example of a successfully created API key Example of a successfully created API key](/static/c9f47f3e34aaeb208d105a4c8dddfad8/3cbba/3.png)
Optionally:
- Display two parts to the API key where required
- Provide information text about the API key
- Allow users to toggle the visibility of the key
- Provide a secondary link to download the key
![Example of a hidden API key Example of a hidden API key](/static/bdfddf1f3ff9598547a503918585f775/3cbba/4.png)
Example of a hidden API key
![Example of a revealed API key Example of a revealed API key](/static/dbfaa322856c05fd3ec339449531edcb/3cbba/5.png)
Example of a revealed API key
Name the API key
You can ask a user to provide a descriptive name before the key is generated. This is particularly useful in instances where a user may have keys for several applications stored in the same location.
![Example of an API key with a custom name Example of an API key with a custom name](/static/d81a35a998c640be809d5b6b97083e4f/3cbba/6.png)
![Example of an API key destination selector Example of an API key destination selector](/static/7b985850d6c7a8473add7fce0c3c1fcb/3cbba/7.png)
Example of an API key destination selector
Restricted access keys
A user may want to limit the access an application or service is granted. Restricted access allows a user to assign specific access control and permissions before the API key is generated.
![Many components can be implemented in the modal content space. Many components can be implemented in the modal content space.](/static/f82121ea7649b92bd5664807b6c9e9db/3cbba/9.png)
Many components can be implemented in the modal content space.
![Example of a restricted API key generation Example of a restricted API key generation](/static/61b49b13ad829b06c53a142225b2bd2d/1ec2b/8.png)
Some examples of restricted API key generation
Show the API key in context (optional)
In some use cases, it can be helpful to also show the user the API key in context, after the modal is closed. In this situation, the key should be displayed near the “Generate” button.
The user may also need the option to generate a new API key.
![One way to display an API key in context, after the modal is closed. One way to display an API key in context, after the modal is closed.](/static/026b45f2844ce62eeb3ec5fc301a2bb2/3cbba/10.png)
One way to display an API key in context, after the modal is closed.