.env
Create an API key
You can create an API key by following these steps:1
Go to your project
Go to Settings > API Keys in your project.

2
Create an API Key
Click on the “Create” button and select permissions you want to grant to
the API key.Select between “You” and “Machine” to associate the API key with your account or a machine user.
Click on the Create API Key button to create the key. Make sure to copy your API key and store it in a safe place. You won’t be able to see it again.
- You: This API key is tied to your user and can make requests against the selected project.
- Machine: A machine user will be added to your project, and an API key associated with that machine user will be created.


3
Use your API Key
Now that you have your API key, you can use it to access your project’s resources programmatically via SDKs or within any API request as a bearer token.
We recommend creating API keys with the least privilege necessary to perform
the required tasks. This helps to reduce the risk of unauthorized access to
your project.
API key permissions
When creating a secret key, you can select the permissions it has, which will give the key access to certain (or all) resources on CodeQR. Here are the different permission options:Permission | Description |
---|---|
All permissions | This API key will have full access to all resources. |
Read only | This API key will have read-only access to all resources. |
Restricted | This API key will have restricted access to some resources: |
You can only set permissions on Secret keys. Publishable keys only have access
to certain endpoints, and cannot be restricted.
Machine users
On CodeQR, you can create API keys that are associated with a “Machine user”. This is particularly helpful when you don’t want to associate the API key with a particular user in your project, to avoid security risks in involving turnover or changes in project ownership.Machine users share the same permissions as the owner
role in a project.
Make sure to only create machine users for trusted applications.


If you delete an API key associated with a machine user, the machine user will
be deleted. Vice versa, if you delete a machine user, their corresponding API
key will be deleted as well.