Token-based access
Target Audience: Developers
TL;DR
Toucan AI uses signed authentication tokens to define granular user permissions and session lifespan without exposing backend credentials.
When to use this
Use this page to configure the permissions object during token generation to control specific user actions, such as editing dashboards or querying the AI assistant.
Fine-grained permissions
The authentication token includes a permissions object that determines the available actions for the embedded user. This model allows for precision control at the resource level.
Permission levels
can_view
Grants read-only access to the specified resource.
can_edit
Grants full access to view, create, update, and delete the resource.
can_query
Specifically enables the use of the AI assistant for data exploration.
Permission models by resource
dashboard
can_view, can_edit
Controls the ability to view or manage dashboards.
chart
can_view, can_edit
Controls the ability to view or manage individual charts.
database
can_view, can_edit
Controls access to data source configurations within Toucan AI.
ai
can_query
Grants permission to use the AI assistant.
Note: Database permissions control the management of connection settings and table metadata within Toucan AI; they do not grant direct write access to your source database.
Implementation examples
To generate a token with specific permissions, perform an HTTP POST request to the /embed/generate-token endpoint.
Your request must include:
The
x-api-keyheader with your API keyThe
Content-Type: application/jsonheaderA JSON body containing the
userandpermissionsobjects
Example request body:
1. View-only access
Restricts users to reading data without the ability to modify visualizations.
2. Full edit access
Allows users to create and modify both dashboards and charts.
3. AI-enabled exploration
Allows users to view dashboards and perform ad-hoc queries via the AI assistant.
Constraints and defaults
Default Fallback: If no
permissionsobject is provided, Toucan AI defaults tocan_viewfor dashboards, charts, and databases, with no AI access (❌).Permission Overrides: Explicit token permissions override default role behavior. For example, a user with an "explorer" role can be granted
can_editaccess through the token.Security: Tokens must be generated and signed server-side. API keys must never be exposed in client-side code.
Last updated
Was this helpful?
