Api Key Security
Your API key is the primary credential for accessing Pullbay's data API. Protecting it is essential to prevent unauthorized access to your account, protect your credit balance, and ensure the integrity of your data. This guide covers best practices, emergency procedures, and infrastructure recommendations for securing your Pullbay API keys.
The Importance of API Key Security
Your Pullbay API key grants full access to your account and all associated data. If compromised, an attacker could:
Deplete your credit balance by making unnecessary API requests
Access all data your keys are authorized to retrieve
Impersonate your application or service
Potentially violate data regulations if the attacker misuses the data
Damage your reputation and that of your organization
Proper API key management is not optional—it's a fundamental part of operating a secure data pipeline.
API Key Security Fundamentals
Do's — Security Best Practices
Store keys in environment variables or secret managers
Separates credentials from code
Use different keys for different environments (prod, staging, dev)
Limits blast radius if one key is compromised
Use different keys for different applications or services
Isolates access and simplifies revocation
Use descriptive, systematic key names
Makes it easy to identify which key serves which purpose
Rotate keys periodically (every 90 days)
Reduces the window of exposure if an old key is leaked
Revoke keys immediately if exposed
Prevents continued misuse
Use the minimum number of keys you need
Reduces attack surface and management overhead
Monitor key activity regularly
Detects suspicious usage patterns early
Implement least-privilege access principles
Only grant keys the minimum permissions required
Document your key management process
Ensures consistency across your team
Don'ts — Dangerous Practices to Avoid
Commit API keys to version control (Git, GitHub, etc.)
Once in Git history, the key is exposed forever
Include API keys in client-side code (JavaScript, mobile apps)
Anyone can inspect your app and steal the key
Share API keys via email, Slack, or chat applications
These channels are not secure and create audit trail problems
Use the same API key across all projects and environments
A compromise in one project exposes all of them
Keep unused API keys active
Increases your attack surface and management burden
Log or display API keys in error messages
Logs and error messages may be accessible to unauthorized people
Hard-code API keys in configuration files
Makes key rotation difficult and increases exposure risk
Share keys between team members via insecure methods
Creates a breakdown in access control and auditability
If Your API Key Is Exposed
Immediate Actions (within minutes):
Follow-up Actions (within 24 hours):
Check your credit balance for unexpected charges
Review recent API request logs for any unauthorized data access
Communicate with your team about the incident
Update your incident response and key management procedures
Consider rotating other keys as a precaution
If the key was exposed in a public repository, notify GitHub and other platforms so they can scan and remove it
Long-term Actions (ongoing):
Implement automated secret scanning in your repositories
Set up alerts for unusual API activity
Establish a regular key rotation schedule
Document the incident and lessons learned
API Key Management Features
Multiple API Keys
Pullbay allows you to create and manage multiple API keys within a single account. This is one of your most important security tools.
Use Cases for Multiple Keys:
prod-api-server
Production application
Production
Main data pipeline
prod-data-warehouse
Data warehouse integration
Production
Scheduled ETL jobs
staging-data-pipeline
Staging application testing
Staging
Testing new features
dev-local-testing
Developer laptop testing
Development
Local development
ci-cd-tests
Automated test suite
CI/CD
GitHub Actions, GitLab CI
partner-integration
Third-party partner access
Production
Partner API access
Benefits of Multiple Keys:
Isolation: If one key is compromised, only the associated service is affected
Accountability: You can track which key is used for which requests
Auditability: Different keys can have different activity logs
Easy Revocation: Revoke a specific key without disrupting other services
Least Privilege: Each key can be associated with specific monitoring and restrictions
Team Organization: Different team members can manage different keys
How to Create Multiple Keys:
Log into your Pullbay account
Go to "Settings" → "API Keys"
Click "Generate New API Key"
Enter a descriptive name following your naming convention
Review the key details and copy it immediately
Store it securely in your secret manager or environment variable system
Test the key by making a test API request
Document the key's purpose and which service uses it
Key Rotation Without Downtime
The ability to rotate keys without downtime is essential for production systems. Pullbay supports multiple active keys simultaneously, allowing you to rotate keys safely.
The Zero-Downtime Rotation Process:
Step-by-Step Rotation Guide:
Deployment
Duration: 30-60 minutes
Update your environment variables or secret manager with the new key
Deploy the updated configuration to all your services
For containerized deployments, restart containers with new config
For serverless, redeploy functions
For scheduled jobs, ensure the next scheduled run uses the new key
Verification
Duration: 15-30 minutes
Make test requests to verify your services work with the new key
Monitor your API dashboard for new key requests
Check error rates and latencies—they should remain normal
Confirm all expected services are using the new key
Look for any failed requests or connection errors
Example Rotation Timeline:
Important Notes:
Pullbay supports multiple active keys, so there's no cutoff moment—both keys work during transition
You can take your time verifying everything works before revoking the old key
If something goes wrong during deployment, the old key still works as a fallback
Always keep the old key active until you're 100% certain the new key is in use everywhere
Key Naming Conventions
A systematic naming convention makes it easy to identify which key serves which purpose and simplifies management.
Recommended Naming Pattern:
Example Keys:
prod-api-server
Production
API Server
Main application
Real-time data requests
prod-data-warehouse
Production
Data Warehouse
ETL job
Scheduled data collection
staging-web-app
Staging
Web App
Testing
Feature testing
staging-notebooks
Staging
Notebooks
Analysis
Data science analysis
dev-local-testing
Development
Local Dev
Personal
Developer laptop
ci-cd-github-actions
CI/CD
GitHub
Automated tests
Test suite runner
ci-cd-gitlab-ci
CI/CD
GitLab
Automated tests
Alternative CI/CD
partner-acme-corp
Production
Partner
Third-party
Partner integration
archive-2025-retired
Archive
Archive
Rotated out
Old key (to be deleted)
Benefits of This Convention:
At a glance: You know the environment, service, and purpose
Searchability: Easy to filter keys in your dashboard
Documentation: The name serves as self-documentation
Security: Clear ownership and responsibility for each key
Automation: Scripts can parse key names to determine handling
Naming Rules:
Use lowercase letters, numbers, and hyphens only
Avoid special characters that may cause parsing issues
Keep names under 50 characters for readability
Include environment as first component for clarity
Include service/app as second component
Add descriptive suffix if needed for clarity
Don't include the actual key value in the name (obviously)
Don't include personally identifiable information in key names
Activity Logging and Monitoring
Pullbay logs all API requests made with your keys. This activity log is crucial for security monitoring and troubleshooting.
What Pullbay Logs
For each API request, Pullbay records:
Timestamp
When the request was made (UTC)
API Key
Which key was used (last 8 characters visible)
Endpoint
Which data endpoint was requested
Request Status
Success, rate limit, authentication error, etc.
Results Returned
Number of results in the response
Credits Consumed
How many credits the request cost
User Agent
Your application's HTTP user agent string
Request ID
Unique identifier for the request (for debugging)
Response Time
How long the request took to complete
Accessing Activity Logs
In the Pullbay Dashboard:
Log into your Pullbay account
Go to "Monitoring" → "Activity Log"
Filter by:
Date range (today, last 7 days, last 30 days, custom)
Specific API key
Endpoint
Status (success, error, rate limited)
Export activity as CSV for analysis
Set up alerts for unusual patterns
Programmatic Access:
Coming soon—API endpoint for querying activity logs programmatically.
Detecting Suspicious Activity
Watch your activity logs for these red flags:
Sudden spike in request volume
Compromised key or runaway code
Check the key and application immediately
Requests from unexpected geographic locations
Key leaked to unauthorized party
Revoke key if not explained
Failed authentication errors in high volume
Attacker trying random keys
Monitor for additional signs of compromise
Requests to endpoints your app doesn't use
Attacker exploring your data
Investigate what data was accessed
Usage at unusual times (middle of night, weekends)
Unauthorized access
Compare to your known usage patterns
Requests from unexpected user agents
Unauthorized application or script
Identify the user agent and take action
Activity on a "disabled" or "rotated" key
Key not properly revoked or stored insecurely
Revoke the key immediately
Example: If your application only requests app store reviews but you see requests to a different endpoint, that's a sign your key may be compromised.
Setting Up Monitoring Alerts
In your Pullbay account, configure alerts for:
Credit threshold alerts: Notify you when credits fall below a certain amount
Unusual activity alerts: Sudden spike in request volume above your baseline
Key compromise alerts: Failed authentication attempts, requests outside expected hours
Rate limit alerts: When approaching or hitting rate limits
Error rate alerts: Spike in failed requests
Configure these in Settings → Alerts → API Key Monitoring.
Infrastructure Recommendations by Deployment Level
Secure API key management depends on your deployment context. Here are recommendations for different scenarios.
Production Environment — Secret Manager (Recommended)
For production systems, use a dedicated secret management service:
AWS Secrets Manager:
Google Secret Manager:
HashiCorp Vault:
Azure Key Vault:
Benefits:
Centralized key management and rotation
Detailed audit logs of all key access
Encryption at rest and in transit
Fine-grained access control (who can access which secrets)
Automatic key rotation support
Integration with your infrastructure as code
Audit logging and access control policies
When to Use:
All production deployments
Any environment with sensitive data
Enterprise deployments requiring audit trails
Regulated industries (finance, healthcare, etc.)
Simple Setups — Environment Variables
For development and simple deployments, environment variables offer a good balance of simplicity and security.
Store API Key as Environment Variable:
Load in Python:
Load in Node.js:
Load in PHP:
Key Rules for Environment Variables:
NEVER commit .env files to version control
Create .env.example with placeholders
Document environment variables in your README
Then add your Pullbay API key:
Load early in your application startup
Load environment variables before using them
Fail fast if required variables are missing
Validate that the API key format is correct
Use environment-specific variables
When to Use Environment Variables:
Development and testing
Simple applications with few dependencies
Containerized deployments (Docker, Kubernetes)
Simple cloud deployments (Heroku, AWS Lambda)
Any scenario where a secret manager is not available
CI/CD Pipelines — Platform Secret Storage
CI/CD platforms (GitHub Actions, GitLab CI, Jenkins, etc.) have built-in secret management.
GitHub Actions:
To Add the Secret to GitHub:
Go to your GitHub repository
Settings → Secrets and variables → Actions
Click "New repository secret"
Name:
PULLBAY_API_KEY_PRODValue: (paste your API key)
Click "Add secret"
GitLab CI:
To Add the Secret to GitLab:
Go to your GitLab project
Settings → CI/CD → Variables
Click "Add variable"
Key:
PULLBAY_API_KEY_PRODValue: (paste your API key)
Check "Protect variable" to limit visibility
Click "Add variable"
Jenkins:
CI/CD Secret Management Best Practices:
Use separate secrets per environment
Limits exposure if one secret is compromised
Mark secrets as "protected" or "masked"
Prevents accidental exposure in logs
Limit secret access to specific jobs/branches
Reduces unauthorized access risk
Rotate CI/CD secrets regularly
Prevents long-term exposure
Use short-lived credentials if available
Reduces the window of exposure
Audit secret access logs
Detects unauthorized access attempts
Don't echo secrets in logs
Prevents accidental exposure
Clean up artifacts that may contain secrets
Prevents leakage through build artifacts
Important: Even though secrets are protected, never trust that they can't be exposed. Always assume CI/CD environments can be compromised and use the principle of least privilege.
Code Examples — Secure Key Loading
Here are production-ready examples for loading your API key securely in common languages.
Python
With environment variables:
With AWS Secrets Manager:
Node.js
With environment variables:
With AWS Secrets Manager:
PHP
With environment variables:
With Google Cloud Secret Manager:
Frequently Asked Questions
Have questions about API key security? Contact Pullbay support or read our Getting Started guide for more information.