| name | apollo-security-basics |
| description | Apply Apollo.io API security best practices.
Use when securing Apollo integrations, managing API keys,
or implementing secure data handling.
Trigger with phrases like "apollo security", "secure apollo api",
"apollo api key security", "apollo data protection".
|
| allowed-tools | Read, Grep, Bash(curl:*) |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
Apollo Security Basics
Overview
Implement security best practices for Apollo.io API integrations including key management, data protection, and access controls.
API Key Security
Never Hardcode Keys
const apiKey = 'sk_live_abc123...';
const apiKey = process.env.APOLLO_API_KEY;
if (!process.env.APOLLO_API_KEY) {
throw new Error('APOLLO_API_KEY environment variable is required');
}
Secure Storage
APOLLO_API_KEY=your-api-key-here
.env
.env.local
.env.*.local
*.key
Key Rotation
interface KeyConfig {
primary: string;
secondary?: string;
rotateAt?: Date;
}
class ApiKeyManager {
private config: KeyConfig;
constructor() {
this.config = {
primary: process.env.APOLLO_API_KEY!,
secondary: process.env.APOLLO_API_KEY_SECONDARY,
rotateAt: process.env.APOLLO_KEY_ROTATE_AT
? new Date(process.env.APOLLO_KEY_ROTATE_AT)
: undefined,
};
}
getActiveKey(): string {
if (this.config.rotateAt && new Date() > this.config.rotateAt) {
if (this.config.secondary) {
return this.config.secondary;
}
.();
}
..;
}
(: ): <> {
{
response = axios.(, {
: { : key },
});
response. === ;
} {
;
}
}
(): <> {
(!..) {
();
}
isValid = .(..);
(!isValid) {
();
}
.();
.. = ..;
.. = ;
}
}
Network Security
HTTPS Only
const apolloClient = axios.create({
baseURL: 'https://api.apollo.io/v1',
timeout: 30000,
});
IP Allowlisting
Data Protection
PII Handling
const PII_FIELDS = ['email', 'phone', 'personal_email', 'mobile_phone'];
function redactPII(data: any, fields: string[] = PII_FIELDS): any {
if (!data) return data;
if (Array.isArray(data)) {
return data.map((item) => redactPII(item, fields));
}
if (typeof data === 'object') {
const result: any = {};
for (const [key, value] of Object.entries(data)) {
if (fields.includes(key) && typeof value === 'string') {
result[key] = redactForLogging(value);
} else {
result[key] = redactPII(value, fields);
}
}
return result;
}
return data;
}
function redactForLogging(value: string): string {
(value.()) {
[local, domain] = value.();
;
}
;
}
.(, (contactData));
Secure Logging
import pino from 'pino';
const logger = pino({
redact: {
paths: [
'api_key',
'apiKey',
'*.api_key',
'*.email',
'*.phone',
'headers.authorization',
],
censor: '[REDACTED]',
},
});
apolloClient.interceptors.request.use((config) => {
logger.info({
type: 'apollo_request',
method: config.method,
url: config.url,
bodyKeys: config.data ? Object.keys(config.data) : [],
});
return config;
});
Data Retention
interface CacheConfig {
ttlMinutes: number;
maxEntries: number;
}
class SecureCache {
private cache = new Map<string, { data: any; expiresAt: number }>();
private config: CacheConfig;
constructor(config: CacheConfig) {
this.config = config;
setInterval(() => this.cleanup(), 60000);
}
set(key: string, data: any): void {
if (this.cache.size >= this.config.maxEntries) {
const oldest = [...this.cache.entries()].sort(
() => a[]. - b[].
)[];
(oldest) ..(oldest[]);
}
..(key, {
data,
: .() + .. * * ,
});
}
(: ): | {
entry = ..(key);
(!entry) ;
(.() > entry.) {
..(key);
;
}
entry.;
}
(): {
now = .();
( [key, entry] ..()) {
(now > entry.) {
..(key);
}
}
}
(): {
..();
}
}
apolloCache = ({
: ,
: ,
});
Access Control
Role-Based API Key Usage
const API_KEYS = {
readonly: process.env.APOLLO_API_KEY_READONLY,
standard: process.env.APOLLO_API_KEY_STANDARD,
admin: process.env.APOLLO_API_KEY_ADMIN,
};
function getApiKeyForOperation(operation: string): string {
const readOnlyOps = ['search', 'enrich', 'get'];
const adminOps = ['delete', 'bulk_update'];
if (adminOps.some((op) => operation.includes(op))) {
return API_KEYS.admin!;
}
if (readOnlyOps.some((op) => operation.includes(op))) {
return API_KEYS.readonly!;
}
return API_KEYS.standard!;
}
Security Checklist
Pre-Deployment
Production
Compliance
Output
- Secure API key management
- PII redaction for logging
- Data retention controls
- Role-based access patterns
- Security audit checklist
Error Handling
| Issue | Mitigation |
|---|
| Key exposure | Immediate rotation |
| PII in logs | Implement redaction |
| Unauthorized access | Audit and revoke |
| Data breach | Follow incident response |
Resources
Next Steps
Proceed to apollo-prod-checklist for production deployment.