Authentication Methods
UTMStack API supports two authentication methods:- Bearer Token Authentication: Uses username/password to obtain a Bearer token for API requests
- API Key Authentication: Uses an internal API key sent in request headers
Method 1: Bearer Token Authentication
Step 1: Authentication Request
Use the /api/authenticate endpoint to log in and receive a Bearer token.
🔧 Request Example:
Make sure to replace the credentials (username and password) with the actual user credentials for your environment.
Step 2: Parse the Response
The response will be a JSON object containing the Bearer token, usually under the key id_token or similar, for example:
Step 3: Use the Bearer Token
Include the token in the Authorization header when making requests to protected endpoints.
Use the /api/elasticsearch/search endpoint to test your Bearer token authentication.
Request Example:
Response:
What happens when you don’t include the Authorization header when making requests to protected endpoints.
Request without Authorization:
Response:
Method 2: API Key Authentication
Use the Utm-Internal-Key header for server-to-server authentication without requiring user credentials.
Important Security Notice: This API key is unique to each UTMStack instance and never changes. It must be kept strictly confidential and should never be shared with anyone outside your organization. Improper use or unauthorized access to this key could compromise your entire UTMStack instance. Do not modify this value in your configuration files.
Step 1: Obtain the API Key
To get the internal API key, you need access to your UTMStack server instance:- Connect to your UTMStack server terminal
- Run the following command:
- Look for the
backend:section, then underenvironment:, find the value:
Copy the value after
INTERNAL_KEY = - this is your API key for authentication.Step 2: Use the API Key in Requests
Include the API key in theUtm-Internal-Key header when making requests:
Header Configuration:
- Name:
Utm-Internal-Key - Location: Header
- Value: The internal key obtained from
compose.yml
Request Example:
Keep your internal API key secure and never expose it in client-side code. This method is intended for server-to-server communication.
Step 3: API Key Response
When using the correct API key, you’ll receive the same successful response as with Bearer token authentication:Authentication Methods Comparison
| Feature | Bearer Token | API Key (Utm-Internal-Key) |
|---|---|---|
| Use Case | User-based authentication | Server-to-server communication |
| Security | Token expires, user-specific | Long-lived, instance-specific |
| Setup | Requires user credentials | Requires server access |
| Best For | Interactive applications | Automated scripts, integrations |
Choose Bearer Token for user-facing applications and API Key for backend integrations and automated systems.
Official API Documentation
UTMStack provides two official resources where developers can explore and interact with the API:Interactive Swagger UI (Demo Instance)
For hands-on testing and live API interaction, you can explore the Swagger UI provided by the public UTMStack demo instance: https://demo.utmstack.com/swagger-ui/index.htmlEach client instance has its own unique Swagger URL, based on how their environment is configured.
https://<your-company>.utmstack.com/swagger-ui/index.htmlhttps://utmstack.<your-domain>.com/swagger-ui/index.html
These tools make it easy to test endpoints, view required parameters, and understand the behavior of the platform’s APIs.