Authentication overview

Webhook Relay utilizes a token-based authentication system to secure API access and client-side operations. This system ensures that all interactions with the platform, whether through its REST API, CLI, or client SDKs, are authorized and performed by legitimate users or applications. The core of this system involves API keys and client tokens, which act as digital credentials to verify identity and grant permissions.

When making API calls or establishing tunnels with Webhook Relay, these credentials are included in requests to validate the caller's identity against the registered account. This approach aligns with common practices for securing web APIs, where a secret token or key is presented with each request to prove authenticity and authorize the requested action. For comprehensive details on API interactions, refer to the official Webhook Relay API reference.

Supported authentication methods

Webhook Relay primarily supports authentication through API keys for programmatic access and client tokens for establishing tunnels and using CLI tools. These methods are designed to provide flexible and secure access to the platform's features.

Method When to Use Security Level
API Key Programmatic access to the Webhook Relay REST API (e.g., managing buckets, inspecting messages, creating destinations). High (requires secure handling and storage)
Client Token Establishing tunnels with the CLI or SDKs, forwarding webhooks to local development environments. High (requires secure handling and storage)

Both API keys and client tokens are secret credentials that grant significant access to your Webhook Relay account. They should be treated with the same level of security as passwords. The platform's security mechanisms, such as HTTPS for all communications, help protect these credentials during transit. The IETF's OAuth 2.0 framework, while not directly implemented as the primary authentication method for Webhook Relay's API, provides a broader context for understanding token-based authentication and authorization flows in web services.

Getting your credentials

To interact with Webhook Relay's API or establish tunnels, you need to generate API keys and client tokens from your account dashboard. These credentials are tied to your user account and provide the necessary authorization.

Generating an API Key

  1. Log in to your Webhook Relay dashboard.
  2. Navigate to the API Tokens section.
  3. Click on the button to Create a new API Token.
  4. Provide a descriptive name for your token (e.g., "My Application API").
  5. The generated API key (key) and secret (secret) will be displayed. Copy these immediately, as the secret will not be shown again.
  6. These credentials are used for authenticating requests to the Webhook Relay REST API.

Generating a Client Token

  1. From your Webhook Relay dashboard, go to the Tokens section (distinct from API Tokens).
  2. Click Create a new Token.
  3. Assign a meaningful name (e.g., "Local Dev Tunnel").
  4. The generated client token will be displayed. Copy it, as it will not be retrievable later.
  5. This token is used with the Webhook Relay CLI or SDKs to establish tunnels and forward webhooks.

It is crucial to store these credentials securely and avoid hardcoding them directly into your application's source code. Environment variables or secure configuration management systems are recommended for handling these sensitive values.

Authenticated request example

This example demonstrates how to authenticate with the Webhook Relay API using an API key and secret. The API key and secret are typically sent as HTTP Basic Authentication credentials. This method involves encoding the key and secret and including them in the Authorization header.

cURL Example (API Key Authentication)

To list your Webhook Relay buckets using the API, you would make a GET request to the /buckets endpoint, authenticating with your API key and secret:

curl -u "YOUR_API_KEY:YOUR_API_SECRET" \
  https://api.webhookrelay.com/v1/buckets

Replace YOUR_API_KEY and YOUR_API_SECRET with the actual credentials obtained from your dashboard. The -u flag in cURL automatically handles the Basic Authentication encoding and header construction.

Node.js Example (Client Token Authentication for Tunneling)

When using a client token with the Webhook Relay Node.js SDK to establish a tunnel, the token is passed during client initialization:

const { RelayClient } = require('@webhookrelay/client');

const client = new RelayClient({
  token: process.env.WEBHOOK_RELAY_TOKEN // Load token from environment variable
});

client.connect().then(() => {
  console.log('Webhook Relay client connected');
}).catch(err => {
  console.error('Connection failed:', err);
});

This Node.js snippet illustrates passing the client token securely via an environment variable, a recommended practice for handling sensitive information in applications. More examples for other languages like Go, Python, and Ruby are available in the Webhook Relay documentation.

Security best practices

Properly securing your authentication credentials is paramount to maintaining the integrity and confidentiality of your Webhook Relay account and data. Adhering to these best practices can mitigate common security risks:

  • Use Environment Variables: Never hardcode API keys or client tokens directly into your source code. Instead, load them from environment variables during runtime. This prevents credentials from being exposed in version control systems or publicly accessible repositories. For cloud deployments, consider using secret management services provided by platforms like AWS Secrets Manager or Google Cloud Secret Manager.
  • Principle of Least Privilege: Grant only the necessary permissions to each API key or client token. If a token only needs to forward webhooks, it should not have permissions to delete buckets or modify account settings. This limits the damage an attacker can inflict if a credential is compromised.
  • Regular Rotation: Periodically rotate your API keys and client tokens. This practice reduces the window of opportunity for an attacker to use a compromised credential. Establish a rotation schedule (e.g., quarterly or semi-annually) and automate the process where possible.
  • Secure Storage: Store credentials in secure locations. For local development, use .env files that are excluded from version control. In production environments, rely on dedicated secret management solutions.
  • Monitor Usage: Regularly review your API and client token usage logs within the Webhook Relay dashboard. Unusual activity, such as a sudden spike in requests from an unexpected location or unusual API calls, could indicate a compromised credential.
  • HTTPS Everywhere: Always ensure that all communication with the Webhook Relay API and services uses HTTPS. This encrypts data in transit, protecting your credentials and webhook payloads from eavesdropping.
  • Avoid Public Exposure: Never expose your API keys or client tokens in client-side code, public repositories, or logs. Treat them as highly sensitive information.

By implementing these security measures, developers can significantly enhance the security posture of their Webhook Relay integrations and protect their data from unauthorized access.