Dear friends, welcome to this tutorial. In this document, I will guide you step-by-step on how to use API Keys in NocoBase to retrieve data, using the "To Dos" example to help you understand every detail. Please read the following content carefully and follow the instructions.

Before we begin, it's important to understand: What is an API Key? It works like an entry ticket that verifies whether an API request comes from an authorized user. When you access the NocoBase system via a website, mobile app, or backend script, this "secret key" quickly validates your identity.
In the HTTP request header, you'll see a format like:
Here, "Bearer" indicates that what follows is a validated API Key, which allows the system to quickly confirm the requester's permissions.
In practice, API Keys are commonly used in the following scenarios:
In short, API Keys not only help confirm the identity of the requester but also monitor usage, limit request frequency, and prevent potential security threats, thereby safeguarding the stable operation of NocoBase.
First, make sure that the built-in Auth: API Keys plugin in NocoBase is activated. Once activated, the system settings center will feature a new configuration page for API keys.

For testing purposes, create a collection named todos (To Dos collection) with the following fields:
idtitlecompleted
Then, enter a few sample to-dos into the collection, such as:

Since API keys are bound to user roles, the system determines request permissions based on the role. Therefore, before creating an API key, you need to create a role and assign the appropriate permissions. It is recommended to create a test role called "To Dos API Role" and assign all permissions for the To Dos collection to this role.

If "To Dos API Role" is not available when creating an API key, it may be because the current user has not been assigned this role. In that case, please assign this role to the current user:

After assigning the role, refresh the page and navigate to the API key management page. Click "Add API Key," and you should see the "To Dos API Role" role available.

For more precise management, you can also create a dedicated "To Dos API User" to log into the system, test permissions, and manage API keys. Simply assign the "To Dos API Role" to this user.

After clicking submit, the system will display a prompt indicating that the API key has been created successfully, and the key will be shown in a popup. Be sure to copy and save this key, as it will not be shown again for security reasons.

For example, you might receive an API key like this:
APP_KEY environment variable. Do not modify it arbitrarily, or all API keys in the system will become invalid.Open the API document plugin, where you can view the request method, URL, parameters, and header information for each API.

Below are some basic API examples provided by NocoBase:
List Query (list API):
Create Record (create API):
Update Record (update API):
Delete Record (delete API):
Here, {baseURL} is the URL of your NocoBase system and {collectionName} is the collection name. For example, when testing locally, if the address is localhost:13000 and the collection name is todos, the request URL would be:
Open Postman, create a new GET request, enter the request URL above, and add the Authorization header with your API key as the value:
After sending the request, if everything is set up correctly, you should receive a response similar to the following:
If the API key is not correctly authorized, you might see an error message like:
In such a case, please check the role permissions, API key binding, and ensure the key format is correct.
Once the test is successful, you can copy the request code for the List API. For instance, the following curl request example is copied from Postman:

To visually demonstrate the effect of API requests, we can use an Iframe Block to display the list of To Dos fetched from NocoBase. Refer to the sample code below:
The above code embeds an Iframe Block that displays a simple "Todo List". Upon loading, it calls the API to retrieve the To Dos and shows the response (as formatted JSON) within the iframe.
Additionally, the following animation demonstrates the dynamic process of the request:

Through the above steps, we have explained in detail how to create and use API keys in NocoBase. From activating the plugin, creating a collection, and binding a role, to testing the API and displaying data in an Iframe Block—each step is crucial. Finally, with the help of DeepSeek, a simple To Dos page was created. Feel free to modify and extend the code as needed.

The code for this example is available in our community post. We welcome your feedback and discussion. We hope this document provides you with clear guidance, and we wish you happy learning and smooth operations!