How to use your API key
Include your API key in theAuthorization header of every API request:
All API requests must be made over HTTPS.
Create an API key
Each key belongs to one environment, production or staging, and works only for that environment. To create a key:- In your Userpilot dashboard, go to Environment > API keys, or open the API keys tab directly.
- Click Create API key.
- Enter a Name that tells you where the key is used, for example “Backend integration”. Names can be up to 60 characters.
- Select the Environment for the key.
- Click Create key, then copy the key.
- Store the key somewhere safe, select I’ve copied and stored this key, and click Done.
You need permission to manage environments to open the API keys tab. If you
don’t see the tab, ask an admin of your Userpilot account.
Manage your API keys
The API keys tab lists the keys of both environments, with who created each key and when, and who deactivated it and when. You can search keys by name and filter them by environment and status. Open the actions menu of a key to change it:- Deactivate: Requests that use the key stop working with
401 Unauthorized. The key stays in the list, and you can re-activate it later. - Re-activate: The key works again.
- Delete: Removes a deactivated key permanently. You can delete a key 30 seconds after you deactivate it. To confirm, type the name of the key. A deleted key can’t be re-activated.
Rotate an API key
To replace a key without downtime:- Create a new key for the same environment.
- Update your integration to use the new key.
- Deactivate the old key, and check that your integration still works.
- Delete the old key.
Security best practices
- Never expose your API key in client-side code or public repositories.
- Use a separate key for each integration, so you can deactivate one without affecting the others.
- Rotate your API keys regularly.
- Deactivate keys you no longer use.