Enterprise Security: Compliance, Credentials, and Data
Healthcare, finance, and legal teams cannot send data to third-party APIs unless those APIs are certified compliant. Claude Code in regulated environments must guarantee: data is never logged or stored, credentials are rotated regularly, network access is isolated, and audit trails are immutable.
This guide covers enterprise security: zero-data retention (ZDR) setup, HIPAA and regulatory compliance, credential rotation, network isolation, data residency, audit logging, key management, and PII handling. You'll learn to configure Claude Code so it meets SOC 2, HIPAA, PCI-DSS, and GDPR requirements. For the self-hosted deployment model that supports full network isolation, see self-hosted Claude Code deployment; for spend controls that complement access controls, see cost analytics and budget limits.
Zero Data Retention (ZDR) Setup
Zero-data retention means Anthropic API receives requests but doesn't log, store, or use the data for training. This is required for healthcare, legal, and finance where your inputs are protected information.
Enable ZDR via an API parameter: anthropic-beta: disable-message-logging. Anthropic logs nothing about your requests—not inputs, not outputs, not model choice. Your data is used only to generate a response, then discarded.
Configure your gateway to always add this header. Audit: log that every request is sent with ZDR enabled. If a request is missing the header, reject it.
Quick reference
- ZDR header: 'anthropic-beta: disable-message-logging' sent with every request.
- API logs: Anthropic does not store your requests/responses if ZDR is enabled.
- Local logs: Claude Code instances can log (to your system, not Anthropic); configure as needed.
- Audit: track that ZDR header is present; alert if missing.
- Verification: periodic audit to confirm ZDR is enabled in production.
Remember this
Always send 'anthropic-beta: disable-message-logging' header; audit that it's present on every request; configure gateway to enforce.
HIPAA and Regulatory Compliance
HIPAA (healthcare), SOC 2, PCI-DSS (payments), and GDPR (data privacy) all have overlapping requirements: encryption, audit logs, access control, and incident response.
Claude Code must meet these via:
1. Encryption in transit (TLS 1.3) and at rest (AES-256). 2. Access controls: only authorized users can run code. 3. Audit logs: immutable record of all access and actions. 4. Incident response: process to detect, respond, and report breaches. 5. Regular audits: third-party assessment.
Work with your legal/compliance team. Most will have a Security Questionnaire (SF-635, SOC 2 checklist, HIPAA Risk Assessment). Map Claude Code deployment to each requirement.
Quick reference
- HIPAA: requires Business Associate Agreement (BAA) with API provider; ZDR must be enabled.
- SOC 2 Type II: third-party audit of your controls; shows you have strong security posture.
- PCI-DSS: if handling payment data, encryption and access control required.
- GDPR: data residency, right to deletion, Data Protection Impact Assessment (DPIA).
- Questionnaire: compliance team provides detailed checklist; you answer and provide evidence.
Remember this
Enable ZDR; use TLS 1.3 and AES-256; maintain 7-year audit logs; implement MFA and role-based access; respond to incidents within 4 hours.
Credential Rotation Patterns
API keys, SSH keys, database passwords—all credentials must rotate every 90 days. Rotation ensures: (1) leaked keys expire automatically, (2) no single key is used forever, (3) you practice recovery (important if you need emergency rotation).
Implement a credential rotation schedule: new credential issued 7 days before expiry, both old and new work, after grace period (7 days), old one is deleted. Test rotation on a non-prod system first.
Automate: a scheduled job (GitHub Actions, K8s CronJob) rotates credentials, updates systems, and logs the action.
Quick reference
- Rotation interval: 90 days for API keys, 30 days for temporary tokens.
- Grace period: 7 days where old and new both work (overlap period).
- Testing: dry-run rotation weekly on test environment.
- Automation: CronJob or GitHub Action triggers rotation; alerts on failure.
- Rollback: if rotation fails, alert immediately; manual restore from backup.
Remember this
Rotate API keys every 90 days; automate via CI/CD; test rotation on non-prod first; maintain 7-day grace period where old and new both work.
Network Isolation: VPC and Private Links
Regulated data must not cross the public internet. Use VPCs (Virtual Private Cloud) and private links to keep traffic isolated.
For AWS: Claude Code runs in a private subnet (no internet gateway). To reach Anthropic API, use AWS PrivateLink (Anthropic provides an endpoint). All traffic stays on AWS network, never touches the public internet.
For on-prem: isolated network segment, firewall rules restrict traffic, and a bastion host or VPN gateway provides controlled access.
Audit: log all network connections. Alert if data exits your network.
Quick reference
- VPC: isolate Claude Code runners in private subnet; use NAT gateway if needed for egress.
- PrivateLink: private endpoint for Anthropic API; no public internet access.
- Firewall rules: only allow outbound HTTPS to Anthropic API; block everything else.
- Bastion host: if on-prem, jump host for remote access; SSH only, no RDP.
- Network logging: VPC Flow Logs capture all network traffic; review for anomalies.
Remember this
Use VPC private subnets and PrivateLink to keep data off the public internet; firewall rules restrict egress; network logs detect anomalies.
Data Residency and Regional Deployment
GDPR, PIPEDA (Canada), and others mandate that personal data stays in-region. If you process EU citizens' data, it must reside in the EU. Canadian data must stay in Canada.
Deploy Claude Code regions that match your data residency rules. Use Anthropic's regional API endpoints (if available) or self-hosted runners in approved regions.
At the gateway, check user's data classification and enforce routing: "This user's data is classified EU-PII; route to eu-west-1 endpoint only."
Quick reference
- Data classification: tag requests as PII, PHI (health), financial, or public.
- Residency rules: define which regions can process each classification.
- Gateway routing: check classification; reject if non-compliant region.
- Audit: log data flow; verify no misclassified data leaves intended region.
- Backup: replicate only to approved regions; never cross borders.
Remember this
Classify data; enforce residency rules at the gateway; route to approved regions only; audit for misclassified data.
Audit Logging and Compliance Events
Audit logs are the source of truth for compliance. They must be: immutable (can't be changed), comprehensive (every access logged), and archived (retained for 7+ years).
Log: who accessed what, when, from where, with what result, and what changed. Store in a write-once system (AWS S3 with Object Lock, or Splunk with immutable indexing).
Compliance teams query these logs during audits. Include: timestamp, user ID, resource, action, outcome, error (if any).
Quick reference
- Immutability: use S3 Object Lock (WORM) or equivalent; can't be deleted.
- Retention: 7 years for most regulations; configure archive policies.
- Content: timestamp, user_id, action, resource, outcome, error_details, ip_address.
- Real-time alerts: suspicious patterns (rapid repeated failures, after-hours access).
- Tamper detection: cryptographic signatures; audit logs that check in.
Remember this
Log every access with timestamp, user, action, resource, outcome; store immutably in S3 with Object Lock; retain 7 years; audit suspicious patterns.
Key Management: AWS KMS and Azure Key Vault
Encryption keys must not be stored in code or on disk. Use AWS KMS (Key Management Service) or Azure Key Vault to store and rotate keys. The service manages key lifecycle and provides audit trails.
When Claude Code needs a key (e.g., API key, TLS cert), it requests from KMS/Key Vault. The service decrypts and returns the key. This is more secure than storing keys locally.
For multi-region: replicate keys across regions for failover. Ensure replication is audited.
Quick reference
- AWS KMS: centralized key management; audit with CloudTrail; encrypt at rest and in transit.
- Azure Key Vault: similar to KMS; manage certs, keys, and secrets.
- Encryption: data encrypted with KMS key; only KMS can decrypt (requires IAM permissions).
- Audit: every decrypt request logged; alert on unusual access patterns.
- Rotation: automatic or manual; old keys archived; new keys take effect immediately.
Remember this
Store all secrets in AWS KMS or Azure Key Vault; never hardcode in code or config; rotate automatically; audit every access.
PII Handling and Redaction
Personally Identifiable Information (PII)—names, emails, phone numbers, SSNs—must be redacted before sending to Claude or logging. Implement redaction at the gateway: scan incoming requests for PII patterns, remove or mask before forwarding.
Redaction patterns: Social Security Number (9 digits), phone number (10 digits), email (name@domain), credit card (16 digits).
For GDPR/CCPA: if a user requests data deletion, purge all logs and responses mentioning them.
Quick reference
- Redaction: scan request for PII; replace with [SSN], [PHONE], [EMAIL], [CC].
- Logging: log the fact that PII was redacted, but not the PII itself.
- Deletion: if user requests erasure, delete all traces (logs, caches, backups after retention).
- False positives: redaction can be over-eager (e.g., order number looks like CC); tune thresholds.
- Unmasking: auditors may need to see unredacted data; use a separate, more restricted log.
Remember this
Redact PII patterns (SSN, email, phone, CC) before sending to Claude; log redaction fact, not the PII; implement right-to-deletion for GDPR.
Key takeaway
Enterprise security in Claude Code means: zero-data retention to protect privacy, compliance controls for regulated industries, credential rotation to limit exposure, network isolation to prevent data exfiltration, audit logging for forensics, and key management for secrets.
Start with ZDR enabled by default. Add HIPAA/SOC 2 controls if your industry requires. Layer in network isolation and audit logging. As you scale, automate credential rotation and implement key management.
Security isn't a feature; it's a requirement. Build it in from the start.
Next: combine security with cost management to ensure you're tracking not only spend, but also compliance and risk.
Polo Khan
Lead Author & Systems ArchitectSoftware engineer and distributed systems architect specializing in backend scalability, cloud-native infrastructure, databases, and AI engineering workflows. Author and maintainer of Core Concept Learning.
Related Articles
Explore this topic