Authentication
How to authenticate with the Semaphor API
Overview
Authentication for the Semaphor API is performed by generating a secure token using the /api/v1/token
endpoint. There are two types of tokens:
- Dashboard Token: Used for embedding dashboards (read-only or self-service). Requires
dashboardId
anddashboardSecret
. - Project Token: Used for management actions (CRUD on dashboards, visuals, etc.). Requires
type: 'project'
,projectId
, andprojectSecret
.
How to Authenticate
1. Generate a Dashboard Token
Use this for embedding dashboards (read-only or self-service):
2. Generate a Project Token
Use this for management actions (CRUD on dashboards, visuals, etc.):
3. Use the Token
Include the returned accessToken
as a Bearer token in the Authorization
header for all subsequent API requests:
Security Best Practices
- Never expose your dashboard or project secrets in client-side code or public repositories.
- Always generate tokens on the server side.
- Rotate secrets regularly and monitor API usage for suspicious activity.
- Cache tokens on your server to reduce API calls and avoid rate limits.
Error Handling
Common authentication errors:
Error Code | Description | Solution |
---|---|---|
INVALID_CREDENTIALS | Dashboard/project ID or secret is incorrect | Verify credentials in Semaphor Console |
TOKEN_EXPIRED | Authentication token has expired | Generate a new token |
INVALID_TOKEN | Token format is invalid | Check token format and regenerate |
RATE_LIMIT_EXCEEDED | Too many authentication attempts | Wait before retrying |
Multi-Tenant Applications
For multi-tenant applications, generate dashboard tokens with tenant-specific credentials and fields (e.g., tenantId
, endUserId
, endUserEmail
) as needed. See the Tokens API documentation for details and examples.