Authentication
How to obtain and use JWT tokens with the Beacon Tower API.
Overview
All API requests are authenticated using Bearer Tokens (JWT) — short-lived access tokens. Users get theirs with username and password through the OAuth 2.0 Resource Owner Password Credentials (ROPC) flow. Integrations use a service account and the client credentials grant.
Requesting a Token
To authenticate and obtain an access token, send a POST request to the /auth/ropc endpoint:
curl -X POST https://api.beacontower.ai/auth/ropc \
-H "Content-Type: application/json" \
-d '{"username": "user@example.com", "password": "your-password"}'
Request Body
{
"username": "your-username",
"password": "your-password"
}
Response
On successful authentication, the API returns an access token:
{
"accessToken": "eyJhbGciOiJSUzI1NiIs..."
}
Error Responses
| Status Code | Description |
|---|---|
| 400 | Missing or invalid credentials in request body |
| 401 | Invalid username or password |
| 404 | Authentication route not found |
| 500 | Internal server error |
Using the Token
Include the access token in the Authorization header of all API requests:
curl https://api.beacontower.ai/assets \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIs..."
Token Lifetime: Access tokens have a limited lifetime. When a token expires, you will receive a 401 Unauthorized response. Re-authenticate using the
/auth/ropcendpoint to obtain a new token.
Service Accounts for Integrations
A service account is a login for an integration, such as a customer backend that calls the API. It belongs to an organization and is managed like a user.
Service accounts need user-service 2.6.1 or later on your tenant. Earlier tenants do not have these calls. A local tenant has them from btk3s 0.7.6; see Call the API as a service account.
You manage service accounts with a user's token:
| Call | Does |
|---|---|
POST /service-accounts | Creates it, owned by and a member of the organization in organizationId. Returns id, clientId, name and clientSecret. Needs the same rights as creating a user there: permission to manage the organization's users, and the user_management privilege on the organization |
GET /service-accounts, GET /service-accounts/{serviceAccountId} | Those the caller may view, as for users. Never the secret |
POST /service-accounts/{serviceAccountId}/secret | Returns a new secret; the old one stops working at once. Also needs the right to remove every role the service account holds |
DELETE /service-accounts/{serviceAccountId} | Removes it and its relations, by the rules of deleting a user. Its credentials stop working |
POST /service-accounts
Authorization: Bearer <user token>
Content-Type: application/json
{
"organizationId": "3f2c9a1e-5b7d-4c8e-9f10-2a3b4c5d6e7f",
"name": "ERP backend"
}
The secret is shown only by create and rotate. Beacon Tower does not store it, so keep it in your own secret store.
Give the service account roles with POST /relations, using its id as a user subject, for example manager on the organization.
The integration then gets tokens from your tenant's identity provider with the client credentials grant. The identity provider is at auth. followed by your tenant's domain: for a tenant whose API is at https://example.com/api/v1, that is https://auth.example.com.
Keep the secret off the command line, where it would land in shell history and show in ps. Put client_secret=<clientSecret> in a file only you can read, here sa.secret, and let curl read it:
curl https://auth.<your-domain>/realms/beacontower/protocol/openid-connect/token \
-d grant_type=client_credentials \
-d client_id=<clientId> \
-d @sa.secret
The response's access_token is used as a Bearer token like any other. Its subject is the service account's id. When it expires, request a new one the same way.
See Service accounts in the API reference for the request and response shapes.
Scopes and Permissions
Access to API endpoints is controlled by a combination of privileges and resource permissions. Users must have both:
- Organization Privilege — Assigned to the user's organization
- Resource Permission — View, Manage, or Owner access on specific resources
Available Privileges
| Privilege | Description |
|---|---|
asset_management | Assets CRUD operations, commands, and properties |
dashboard_management | Dashboards CRUD operations |
user_management | Users and groups management |
tree_management | Node trees and graph operations |
model_management | Models, drafts, and binding descriptions |
alarm_management | Alarm definitions and status management |
organization_management | Organization CRUD operations |
provider_management | Providers and provider clients management |
notification_management | Notifications and contact groups |
firmware_management | Firmware releases and deployments |
Each privilege maps to a specific set of API endpoint groups. Attempting to access an endpoint without the required privilege will result in a 403 Forbidden response.
Resource Permissions
Resource-level permissions determine what actions a user can perform on individual resources:
- View — Read-only access
- Manage — Read and update access
- Owner — Full control including deletion and permission management
Next Steps
- Follow the Your First Asset guide for a practical walkthrough of authentication and asset creation
- Explore the API Reference for detailed endpoint documentation
- Review the API Reference for error response formats and troubleshooting