Authentication overview

Postmon utilizes API keys as its primary method for authenticating requests made to its data collection and management APIs. This approach allows developers to integrate Postmon's real-time analytics capabilities into web and mobile applications, as well as backend services, by including a unique Project API Key with each request. This key identifies the sender and links the incoming data to a specific Postmon project, ensuring proper attribution and access control. The API key model simplifies the authentication process for developers while providing a foundational layer of security for data transmission. All communication with the Postmon API is expected to occur over HTTPS, encrypting data in transit and protecting against eavesdropping and tampering.

Postmon's API is designed for various use cases, including tracking user behavior, managing event data, and integrating with external data warehouses. The consistent use of API keys across these functions streamlines development and maintenance. For detailed information on API endpoints and request formats, developers can consult the Postmon API reference documentation.

Supported authentication methods

Postmon's API primarily relies on a single, consistent authentication method to simplify integration and ensure data security. The method is designed to be straightforward for both client-side and server-side implementations.

API Key Authentication

Postmon employs API key authentication, where a unique string (the API key) is used to identify the client making the request. This key is associated with a specific Postmon project and grants access to that project's data. API keys are typically passed in the request body, header, or URL query parameters, depending on the specific API endpoint and the SDK being used. For example, when using Postmon's JavaScript SDK for web tracking, the API key is initialized with the SDK client, which then automatically includes it in subsequent event tracking calls.

While API keys offer simplicity, their security relies on proper handling and storage. They function as a bearer token, meaning anyone in possession of the key can potentially make authenticated requests. Therefore, best practices dictate that API keys, especially those with write access, should be treated with the same level of confidentiality as passwords. For server-to-server communication or sensitive operations, it's recommended to store API keys securely and transmit them over encrypted channels (HTTPS), which Postmon enforces for all API interactions.

The following table summarizes Postmon's primary authentication method:

Method When to Use Security Level
API Key All API interactions: event tracking, data retrieval, management operations. Suitable for both client-side (with precautions) and server-side applications. Moderate-High (dependent on secure storage and transmission via HTTPS). Requires careful management to prevent unauthorized access.

Getting your credentials

Accessing your Postmon project and its data requires a Project API Key. This key is generated and managed within the Postmon dashboard. Here's how to obtain your API key:

  1. Log In to Postmon Dashboard: Navigate to the Postmon website and log in to your account.
  2. Select Your Project: Once logged in, choose the specific project for which you need the API key. If you have multiple projects, ensure you select the correct one.
  3. Access Project Settings: Within your project, look for 'Project Settings' or a similar configuration menu. The exact location may vary slightly based on dashboard updates, but it's typically found in a sidebar or top-level navigation.
  4. Locate API Keys Section: Inside Project Settings, there will be a dedicated section for 'API Keys' or 'Access Tokens'. Here, you will find your existing API key(s) or an option to generate new ones.
  5. Copy Your API Key: Your Project API Key will be displayed. Copy this key carefully. It's a long alphanumeric string.
  6. (Optional) Generate New Key: If you believe your existing key has been compromised, or if you need separate keys for different environments (e.g., development, staging, production), you can typically generate a new API key from this same section. Remember to update all applications using the old key if you generate a new one.

It is important to treat your API key as a sensitive credential. Do not embed it directly into publicly accessible client-side code without appropriate mitigations, and never commit it directly into version control systems like Git without encryption or environment variable usage.

Authenticated request example

When making API requests to Postmon, your Project API Key must be included for successful authentication. The exact method of inclusion depends on whether you are using an SDK or making direct HTTP requests. Below is an example of an authenticated request using a common method: including the API key in the request body or via an SDK initialization.

Example: Tracking an Event with JavaScript SDK

Postmon provides various SDKs for different programming languages to simplify integration. Using the JavaScript SDK for web applications is a common scenario. The API key is typically passed during the SDK initialization:


<script type="text/javascript">
  (function(p, o, s, t, m, o, n) {
    p['PostmonObject'] = m;
    p[m] = p[m] || function() {
      (p[m].q = p[m].q || []).push(arguments)
    }, p[m].l = 1 * new Date();
    o = s.createElement(t),
    n = s.getElementsByTagName(t)[0];
    o.async = 1;
    o.src = "https://cdn.postmon.io/lib/postmon.min.js";
    n.parentNode.insertBefore(o, n);
  })(window, document, 'script', 'https://cdn.postmon.io/lib/postmon.min.js', 'postmon');

  // Initialize Postmon with your Project API Key
  postmon('init', 'YOUR_PROJECT_API_KEY');

  // Track an event
  postmon('track', 'PageView', {
    'page_path': window.location.pathname,
    'referrer': document.referrer
  });

  // Identify a user
  postmon('identify', 'user-123', {
    'name': 'John Doe',
    'email': '[email protected]'
  });
</script>

In this example, YOUR_PROJECT_API_KEY is your unique identifier. Once initialized, the SDK handles the inclusion of this key in all subsequent tracking and identification calls, abstracting the underlying HTTP request details.

Example: Direct API Call with Python (Server-side)

For server-side integrations or direct API calls, you might send the API key in a header or as part of the JSON payload. For instance, when sending events directly to Postmon's ingestion API, the key is typically included in the request body:


import requests
import json

API_KEY = "YOUR_PROJECT_API_KEY"
POSTMON_API_ENDPOINT = "https://api.postmon.io/v1/event"

# Event data payload
event_data = {
    "api_key": API_KEY,
    "event": "UserSignedUp",
    "properties": {
        "plan": "premium",
        "source": "website"
    },
    "user_id": "new_user_456",
    "timestamp": "2026-05-29T10:00:00Z"
}

headers = {
    "Content-Type": "application/json"
}

response = requests.post(POSTMON_API_ENDPOINT, headers=headers, data=json.dumps(event_data))

if response.status_code == 200:
    print("Event successfully sent!")
else:
    print(f"Failed to send event: {response.status_code} - {response.text}")

In this Python example, the api_key is explicitly included within the JSON payload sent to the Postmon event ingestion endpoint. This demonstrates a common pattern for server-side API key usage when not relying on a specific SDK that abstracts this detail.

Security best practices

Securing your Postmon API keys and ensuring the integrity of your data is paramount. Adhering to security best practices can mitigate risks associated with unauthorized access and data breaches.

  1. Treat API Keys as Sensitive Credentials: Your Postmon API key grants access to your analytics data. Treat it with the same level of care as you would a password or private cryptographic key.
  2. Use Environment Variables for Server-Side Keys: For applications running on servers, never hardcode API keys directly into your source code. Instead, store them as environment variables. This prevents them from being exposed in version control systems and makes it easier to manage different keys for various deployment environments (development, staging, production). For instance, in Node.js, you might access process.env.POSTMON_API_KEY.
  3. Restrict Client-Side Keys: While Postmon's JavaScript SDK requires the API key to be present on the client side for web tracking, understand that any key exposed in client-side code (even obfuscated) can potentially be discovered. For sensitive operations, consider proxying requests through your own backend to keep the API key server-side.
  4. Regular Key Rotation: Periodically rotate your API keys, especially if there's any suspicion of compromise or as part of a routine security policy. Postmon's dashboard allows you to generate new keys and deactivate old ones.
  5. Monitor API Usage: Keep an eye on your Postmon project's API usage patterns. Unusual spikes or unexpected data submissions could indicate unauthorized use of your API key.
  6. Implement HTTPS/TLS: All communication with Postmon's API must occur over HTTPS. This encrypts data in transit, protecting your API key and event data from interception. Postmon enforces HTTPS for all its endpoints, a standard practice for secure web communication as outlined by organizations like the IETF in RFC 2818 for HTTP Over TLS.
  7. Principle of Least Privilege: If Postmon introduces granular API key permissions in the future, only grant your keys the minimum necessary permissions required for their specific function. For example, a key used only for event tracking should not have permissions for data deletion if such an option becomes available.
  8. Secure Development Practices: Ensure your development environment and deployment pipelines are secure. Implement code reviews, static analysis, and vulnerability scanning to prevent credentials from being accidentally exposed or mishandled.

By implementing these practices, developers can significantly enhance the security posture of their Postmon integrations and protect their valuable analytics data.