API tokens
This article explains how to create and work with API Tokens.
Create API Token
Open Account Settings page from the user menu in the bottom left corner of the sidebar.
- Click on
User menu
in the bottom left corner of the sidebar, - Select
Account Settings
from the dropdown
Follow the steps below to create API Token
- Click on
Tokens
tab in theAccount Settings
page - Click on
Add New API Token
- Enter the name for the API Token
- Click on
Save
button to save the changes - Copy the API Token by clicking on
Copy
button displayed underActions
menu - Use the API Token in the services that require it to authenticate. You can use either the
xc-token
header or theAuthorization
header with bearer token format.
Option 1: Using xc-token header
{
"headers": {
"xc-token": "Copied API token here under quotes"
}
}
Option 2: Using Authorization header (since v0.264.7)
{
"headers": {
"Authorization": "Bearer Copied API token here under quotes"
}
}
xc-token
and Authorization: Bearer
header formats are supported for authentication.API Token created will get added to the list. Copy API token by clicking on Copy
button displayed under Actions
menu
Authentication Methods
NocoDB supports two methods for API token authentication:
Method 1: xc-token Header
Use the xc-token
header with your API token value directly:
{
"headers": {
"xc-token": "your_api_token_here"
}
}
Method 2: Authorization Header (since v0.264.7)
Use the standard Authorization
header with Bearer token format:
{
"headers": {
"Authorization": "Bearer your_api_token_here"
}
}
Both methods are equivalent and provide the same level of security. Choose the one that best fits your application's authentication patterns.
Delete API Token
Note that, all the services using the API Token will stop working once the API Token is deleted.
Open Account Settings page from the user menu in the bottom left corner of the sidebar.
- Click on
User menu
in the bottom left corner of the sidebar, - Select
Account Settings
from the dropdown
- Click on
Tokens
tab in theAccount Settings
page - From the
Actions
menu, click onDelete
button associated with the API Token to be deleted
API Token Access with SSO-Enabled Workspaces
If a workspace is configured to enforce Single Sign-On (SSO), API access to that workspace is restricted to tokens that are created after authenticating via SSO.
To access an SSO-enforced workspace via API, users must:
- Sign in using SSO.
- Generate a new API token from their authenticated session.
For ease of identification, tokens created after SSO is enabled will have a badge indicating they were generated through SSO authentication.
What Happens When SSO is Disabled?
If SSO is later disabled for a workspace:
- API tokens that were created via SSO authentication will continue to work as long as the user is still active and has the required permissions.
- Tokens created prior to enabling SSO will continue to function & can now access the workspace without SSO authentication.
- No tokens are automatically revoked when SSO is disabled.