Authentication overview
ZeroBounce secures access to its email validation and verification services primarily through the use of API keys. This method provides a straightforward yet effective way for applications to authenticate with the ZeroBounce API, allowing developers to integrate email validation capabilities into their software via the ZeroBounce API reference. API keys function as a unique identifier and secret token that applications present with each request to prove their identity.
The ZeroBounce API supports both real-time individual email validation and bulk file processing, with all interactions requiring a valid API key. This system helps prevent unauthorized access to services and ensures that usage is tracked accurately against the associated ZeroBounce account as described in the ZeroBounce documentation. The API key model aligns with common practices for RESTful API authentication, offering a balance of ease of implementation and security as detailed in Google Cloud authentication guidance.
Supported authentication methods
ZeroBounce exclusively utilizes API keys for authentication across its services. This approach simplifies the authentication process for developers while maintaining a necessary level of security for API access. The API key is a long, unique string that acts as both an identifier for your application and a secret for authentication.
When making requests to the ZeroBounce API, the API key must be included in the request. For the ZeroBounce API, this is typically done by passing the API key as a query parameter in the URL for GET requests or within the request body for POST requests, depending on the specific endpoint being accessed. All communications with the ZeroBounce API are also secured using HTTPS/TLS encryption to protect the API key and data in transit as recommended for secure web communication.
The following table summarizes the authentication method:
| Method | When to Use | Security Level |
|---|---|---|
| API Key | All API calls (real-time validation, bulk processing, data enrichment) | Standard. Requires secure handling (storage, transmission) to prevent compromise. |
ZeroBounce provides official SDKs for various programming languages, including JavaScript, PHP, Python, Ruby, .NET, Java, Go, and Node.js as listed in the ZeroBounce API documentation. These SDKs abstract the details of API key inclusion, simplifying the integration process for developers by providing methods to configure the API key once and reuse it for subsequent requests.
Getting your credentials
To obtain your ZeroBounce API key, you must have an active ZeroBounce account. The API key is generated and managed within your user dashboard.
- Create a ZeroBounce Account: If you do not already have one, register for a ZeroBounce account on their official website. ZeroBounce offers a free tier with 100 credits per month, which allows you to generate and test your API key.
- Log In to Your Dashboard: Access your ZeroBounce account dashboard using your registered email and password.
- Navigate to API Keys Section: Within the dashboard, locate the section dedicated to API keys or API settings. This is typically found under 'Integrations', 'API', or 'Settings'.
- Generate Your API Key: Follow the instructions to generate a new API key. ZeroBounce typically provides a single primary API key for your account. Ensure you copy this key immediately upon generation, as it may not be displayed again for security reasons, or only partially shown.
- Copy and Securely Store Your Key: Once generated, copy your API key. It is critical to store this key securely. Do not hardcode it directly into your application's source code, commit it to public version control systems, or expose it in client-side code where it can be inspected. Recommended practices for API key storage include using environment variables, configuration files that are not publicly accessible, or dedicated secret management services.
- Revoke and Regenerate (If Needed): If your API key is ever compromised or you need to cycle keys for security reasons, the ZeroBounce dashboard provides options to revoke existing keys and generate new ones.
For detailed, step-by-step instructions with screenshots, refer to the official ZeroBounce documentation on API key management.
Authenticated request example
This section demonstrates how to authenticate a request to the ZeroBounce API using an API key. The example uses the ZeroBounce Email Validation API endpoint, which performs a real-time check on a single email address.
HTTP GET Request (cURL)
When making a GET request, the API key is typically passed as a query parameter. Replace YOUR_API_KEY with your actual ZeroBounce API key and [email protected] with the email address you wish to validate.
curl -X GET \
'https://api.zerobounce.net/v2/validate?api_key=YOUR_API_KEY&[email protected]&ip_address=127.0.0.1' \
-H 'Accept: application/json'
In this example, api_key=YOUR_API_KEY is the parameter that authenticates your request. The ip_address parameter is optional but recommended for improved accuracy, representing the IP address from which the email registered or last interacted.
Python SDK Example
Using one of ZeroBounce's official SDKs simplifies the authentication process. The Python SDK, for instance, allows you to configure your API key when initializing the client.
import zerobounce
# Configure your API key
zerobounce.api_key = 'YOUR_API_KEY'
# Validate an email address
email_to_validate = '[email protected]'
ip_address = '127.0.0.1' # Optional: provide client's IP for better accuracy
try:
response = zerobounce.validate(email_to_validate, ip_address)
if response.status == 'valid':
print(f"Email {email_to_validate} is valid. Status: {response.sub_status}")
else:
print(f"Email {email_to_validate} is not valid. Status: {response.status}, Sub-status: {response.sub_status}")
# Access other response attributes
print(f"Domain: {response.domain}")
print(f"Suggestion: {response.suggestion}")
except zerobounce.exceptions.ZeroBounceAPIError as e:
print(f"An API error occurred: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
In the Python example, zerobounce.api_key = 'YOUR_API_KEY' sets the authentication credential globally for the SDK client. Subsequent calls to zerobounce.validate() will automatically include this API key in the request without explicit inclusion in each method call. This method is generally preferred over manual HTTP requests when an SDK is available, as it handles request formatting, error handling, and other complexities.
Security best practices
Securing your ZeroBounce API key is crucial to prevent unauthorized access to your account and services. Adhering to established security practices for API keys helps protect your data and control your usage costs. The following guidelines are recommended:
-
Never Hardcode API Keys: Do not embed your API key directly within your application's source code. Hardcoding keys makes them difficult to rotate and exposes them if your codebase is ever compromised or publicly accessible.
-
Use Environment Variables: Store API keys in environment variables on your server or in your local development environment. This keeps the keys out of your codebase and allows for easy rotation without code changes. For example, in a Linux/macOS environment, you might set
export ZEROBOUND_API_KEY="YOUR_API_KEY". -
Utilize Secret Management Services: For production environments, consider using dedicated secret management services such as AWS Secrets Manager as outlined in AWS documentation, Google Secret Manager as described by Google Cloud, or Azure Key Vault as detailed in Microsoft Azure documentation. These services provide secure storage, versioning, and access control for sensitive credentials.
-
Restrict Access to Keys: Limit who has access to your API keys. Only individuals or systems that absolutely require access should be granted it. Implement strong access controls for any systems hosting these keys.
-
Use HTTPS/TLS for All API Communication: All interactions with the ZeroBounce API should occur over HTTPS (TLS). This encrypts the data in transit, protecting your API key and other sensitive information from eavesdropping during network communication.
-
Regularly Rotate API Keys: Periodically rotate your API keys. This practice minimizes the window of exposure if a key is compromised. ZeroBounce's dashboard typically provides functionality to revoke old keys and generate new ones.
-
Monitor API Usage: Keep an eye on your API usage through the ZeroBounce dashboard. Unexplained spikes in usage could indicate a compromised API key being used for unauthorized purposes. Set up alerts if available.
-
Avoid Client-Side Exposure: Never embed your ZeroBounce API key directly into client-side code (e.g., JavaScript in a web browser or mobile application). Client-side code is easily inspected, making the key vulnerable to extraction and misuse.
-
Implement Server-Side Proxies: If client-side applications need to interact with the ZeroBounce API, route requests through a secure server-side proxy. The proxy can then inject the API key securely before forwarding the request to ZeroBounce. This keeps the API key hidden from the client.
-
Use IP Whitelisting (if available): If ZeroBounce offers IP whitelisting for API keys (check their documentation for availability), configure it to allow requests only from your application's known server IP addresses. This adds an extra layer of security, preventing unauthorized access even if the API key is stolen, unless the attacker is also originating from a whitelisted IP.