Skip to main content

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 CodeDescription
400Missing or invalid credentials in request body
401Invalid username or password
404Authentication route not found
500Internal 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/ropc endpoint 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:

CallDoes
POST /service-accountsCreates 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}/secretReturns 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:

  1. Organization Privilege — Assigned to the user's organization
  2. Resource Permission — View, Manage, or Owner access on specific resources

Available Privileges​

PrivilegeDescription
asset_managementAssets CRUD operations, commands, and properties
dashboard_managementDashboards CRUD operations
user_managementUsers and groups management
tree_managementNode trees and graph operations
model_managementModels, drafts, and binding descriptions
alarm_managementAlarm definitions and status management
organization_managementOrganization CRUD operations
provider_managementProviders and provider clients management
notification_managementNotifications and contact groups
firmware_managementFirmware 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