To access Happi.dev’s API services, you must authenticate using an API key. This key ensures secure communication and proper usage tracking. Below are the steps and details on how to use your API key for authentication.
Generate Your API Key
• Log in to your Happi.dev dashboard.
• Navigate to the API Keys section.
• Generate a new API key or use an existing one.
• Ensure you store this key securely, as it will be required for all API requests.
Include Your API Key in Requests
• Your API key must be included in the headers of each API request.
• You can use either of the following headers to send your API key:
• x-happi-token
• x-happi-key
Example
GET /some-endpoint HTTP/1.1
Host: api.happi.dev
x-happi-token: your_api_key_here
Or
GET /some-endpoint HTTP/1.1
Host: api.happi.dev
x-happi-key: your_api_key_here
Making API Requests
• Every request to Happi.dev’s API endpoints must include your API key in the headers.
• If your API key is missing or invalid, the request will be rejected with a 401 Unauthorized error or 403 Forbidden error
• Ensure that the API key you use has the appropriate permissions for the API endpoint you are accessing.
Security Best Practices
• Keep your API key confidential. Do not share it publicly or in client-side code.
• Rotate your API keys regularly to minimize the risk of unauthorized access.
• Monitor your API usage in the Happi.dev dashboard to detect any suspicious activity.
Restricting API Key by IP Address
For added security, Happi.dev allows you to restrict the usage of your API keys to specific IP addresses. This ensures that only requests originating from trusted IPs can use your API key, protecting your services from unauthorized access.
What is IP Restriction?
- IP restriction allows you to limit the usage of an API key to one or more specified IP addresses.
- Only requests coming from these IPs will be able to successfully authenticate with your API key.
- This feature is particularly useful for controlling access to your APIs when working with sensitive data or when your application is deployed in a secure environment.
How to Set Up IP Restrictions
- Access Your Dashboard: Log in to your Happi.dev dashboard.
- Navigate to API Keys: Go to the API Keys section.
- Configure IP Restrictions:
- Select the API key you wish to restrict.
- Add the IP addresses that are allowed to use this API key.
- You can add multiple IP addresses as needed.
Managing IP Restrictions
You can update, add, or remove IP restrictions at any time from the dashboard.
Ensure that the IP addresses you whitelist are trusted and regularly monitored to maintain security.
By configuring IP restrictions, you enhance the security of your API key, ensuring that only specified IP addresses can access your services. This additional layer of protection is essential for environments where security is a top priority.