Back to blog
SendexAPIAPI keyssecurityemail APIscoped keysemail securitytransactional email

How to Create Scoped API Keys in SendexAPI for Enhanced Security

SendexMarch 31, 2026
Photo by Sasun Bughdaryan on Unsplash
Photo by Sasun Bughdaryan on Unsplash

In today's digital landscape, security is paramount, especially when it comes to handling sensitive data and critical services like email. SendexAPI understands this and offers a robust feature to help you enhance your email security: scoped API keys. This guide will walk you through the process of creating and using scoped API keys in SendexAPI to protect your email sending infrastructure.

What are Scoped API Keys?

Scoped API keys are specialized API keys that grant limited access to specific functionalities or resources within your SendexAPI account. Unlike a full-access API key, which can perform any action, scoped keys are restricted to a predefined set of permissions, domains, and even expiration dates. This significantly reduces the risk of unauthorized access and potential damage if a key is compromised.

Why Use Scoped API Keys?

  • Enhanced Security: Limit the potential damage from compromised keys by restricting their access.
  • Principle of Least Privilege: Grant only the necessary permissions for each application or service using your API.
  • Domain Restriction: Restrict keys to specific domains, preventing unauthorized use from other sources.
  • Expiration Dates: Set expiration dates for temporary access or to enforce key rotation.
  • Compliance: Meet security compliance requirements by implementing granular access controls.

Step-by-Step Guide: Creating Scoped API Keys in SendexAPI

Follow these steps to create scoped API keys in your SendexAPI account:

  1. Log in to Your SendexAPI Dashboard: Access your SendexAPI account at Dashboard.
  2. Navigate to API Keys: Find the "API Keys" section in your account settings. This is where you'll manage all your API keys, including creating new ones.
  3. Click "Create New Key": Initiate the process of creating a new API key.
  4. Choose Key Type: Select the "Scoped Key" option. This will allow you to define specific permissions and restrictions.
  5. Set Permissions: Specify the actions this key is allowed to perform. For example, you can create a "Send-Only" key that can only send emails but cannot access other account information or settings. This aligns with the principle of least privilege.
  6. Restrict Domains (Optional): If you want to limit the key's usage to specific domains, enter the allowed domains. This prevents unauthorized use from other sources. Domain restriction is key to email deliverability and preventing abuse.
  7. Set Expiration Date (Optional): Define an expiration date for the key. This is useful for temporary access or to enforce regular key rotation. After the expiration date, the key will automatically become invalid.
  8. Name Your Key: Give your key a descriptive name that reflects its purpose. This will help you easily identify and manage your keys later.
  9. Generate Key: Once you've configured all the settings, click the "Generate Key" button.
  10. Copy and Securely Store the Key: The generated API key will be displayed. Important: Copy the key and store it in a secure location. This key will not be shown again. If you lose the key, you'll need to generate a new one.
  11. Test the Key: Verify that the new scoped API key works as expected by using it in your application or service. Ensure that it can perform the allowed actions and that unauthorized actions are blocked.

Powered by Sendex

The email API built for developers.

Start sending with Sendex in minutes — reliable delivery powered by Amazon SES.

Try for free →

Example Scenarios for Scoped API Keys

  • Third-Party Marketing Tool: Create a send-only key with domain restrictions for a marketing automation platform.
  • Internal Reporting System: Generate a key with read-only access to email statistics for an internal reporting dashboard.
  • Mobile Application: Issue a temporary key with limited sending capabilities for a mobile application.
  • Specific Microservice: Restrict a key to only accessing the specific endpoints required by your service.

Managing Your Scoped API Keys

The SendexAPI dashboard provides tools for managing your API keys, including:

  • Listing Keys: View all your API keys, their types, permissions, and expiration dates.
  • Revoking Keys: Immediately invalidate a key if it's compromised or no longer needed. This is critical for security incident response.
  • Editing Keys: Modify the settings of existing keys, such as permissions, domain restrictions, or expiration dates. Note: You cannot retrieve a key after it has been generated. You can only revoke or edit its settings.

Best Practices for Scoped API Key Security

To maximize the security benefits of scoped API keys, follow these best practices:

  • Never Store Keys in Publicly Accessible Locations: Avoid storing API keys in code repositories, configuration files, or client-side code.
  • Use Environment Variables: Store API keys in environment variables and access them from your application code.
  • Implement Key Rotation: Regularly rotate your API keys, especially for sensitive applications. Consider using short expiration dates for highly critical keys.
  • Monitor API Key Usage: Track API key usage to detect any suspicious activity. SendexAPI provides logs and analytics to help you monitor API activity.
  • Revoke Unused Keys: If you have API keys that are no longer in use, revoke them immediately.
  • Clearly Define Permissions: Carefully consider the necessary permissions for each key and grant only the minimum required access.
  • Monitor Delivery Webhooks: Use Delivery Webhooks) to track email delivery status and identify potential issues.

Common Pitfalls to Avoid

  • Using Full-Access Keys Everywhere: Avoid using full-access API keys when scoped keys are sufficient.
  • Hardcoding Keys in Code: Never hardcode API keys directly into your application code.
  • Sharing Keys Across Multiple Applications: Use separate keys for each application or service to isolate potential security breaches.
  • Ignoring Key Expiration: Failing to set or monitor key expiration dates can lead to security vulnerabilities.
  • Neglecting API Key Rotation: Infrequent key rotation increases the risk of compromised keys being used for malicious purposes.

Integrating Scoped Keys in Your Applications

Using a scoped API key in your code is straightforward. Just replace your existing API key with the new scoped one. Here's an example using curl, similar to the example in the Mastering SendexAPI: A Comprehensive Guide to Sending Your First Email post. Supposing your scoped key is sk_live_scoped123 and only has send permissions:

curl -X POST https://api.sendex.io/v1/emails \
 -H "Authorization: Bearer sk_live_scoped123" \
 -H "Content-Type: application/json" \
 -d '{
  "from": "[email protected]",
  "to": "[email protected]",
  "subject": "Your order is confirmed",
  "html": "<h1>Thanks for your order!</h1>"
}'

Attempting to use this key for other operations, such as retrieving contact lists, will result in an authorization error.

SendexAPI: Security-Focused Email API

SendexAPI prioritizes security to ensure your email communications are safe and reliable. Beyond scoped API keys, SendexAPI offers features like Domain Verification (DKIM, SPF, DMARC setup), and Delivery Webhooks) to enhance your email deliverability and security posture. By implementing these security measures, you can protect your brand reputation and ensure the integrity of your email communications.

Conclusion

Creating and using scoped API keys in SendexAPI is a simple yet powerful way to enhance the security of your email sending infrastructure. By limiting access to specific functionalities and resources, you can significantly reduce the risk of unauthorized access and potential damage. Follow the steps and best practices outlined in this guide to implement scoped API keys effectively and protect your SendexAPI account.

Ready to get started? Sign up for SendexAPI today and take advantage of our pay-per-use pricing model, which ensures you only pay for what you send. You'll get 100 free emails to start. Create scoped API keys and experience the enhanced security and control they provide.

Sendex

Start sending email today

Reliable email API powered by Amazon SES — set up in minutes, built for scale.

How to Create Scoped API Keys in SendexAPI for Enhanced Security — Sendex Blog — Sendex