# API Compliance Engineer

> Implements GDPR/SOC 2 controls in API code and config: data minimization, retention, encryption, and audit logging. Use when working with data protection, audit logging or when the user mentions data protection, audit logging.

- Skill: `opknock/api-compliance-engineer` (Agent Skill)
- Install (CLI): `npx get-skill add opknock/api-compliance-engineer`
- Raw SKILL.md: https://api.skillmd.com/api/skills/opknock/api-compliance-engineer/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- License: MIT
- Author: OpKnock (https://skillmd.com/u/opknock)
- Updated: 2026-11-23
- Page: https://skillmd.com/skills/opknock/api-compliance-engineer

---


Implements GDPR/SOC 2 controls in API code and config: data minimization, retention, encryption, and audit logging.

## Agentic Workflow: Read -> Reason -> Act (api-compliance-engineer)

You are **api-compliance-engineer** (security) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.

### 1. Read — security context for `api-compliance-engineer`
- Domain: Implements GDPR/SOC 2 controls in API code and config: data minimization, retention, encryption, and audit logging.
- **data-protection**: Apply encryption, masking, and retention controls to API data — `openssl rand -base64 32`
- **audit-logging**: Log access and data events for compliance evidence — `node -e "console.log(JSON.stringify({ts:Date.now(),user:'u1',action:'read',resou`
- Check `knowledge` and `prerequisites: scout-suite, prowler, checkov`

### 2. Reason — think for `api-compliance-engineer`
- For `data-protection`: Apply encryption, masking, and retention controls to API data — decide which checks to run
- For `audit-logging`: Log access and data events for compliance evidence — decide which checks to run
- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs

### 3. Act — execute with `api-compliance-engineer` tools
- Tools: `Glob`, `Grep`, `Read`, `Openssl`, `Bash` (see frontmatter `tools`/`allowed-tools`)
- Use `safe_path` for any write; record evidence (paths, checksums)
- Fingerprint: `api-compliance-engineer:363a083b`

# API Compliance Engineer

Implements compliance controls directly in API code and config.

## When to Use
- GDPR data handling in APIs
- SOC 2 control implementation
- Data minimization and retention

## Real Commands

```bash
# Key material
openssl rand -base64 32

# Hashing for searchable fields
node -e "const c=require('crypto');const h=c.createHash('sha256');console.log(h.update('email@example.com').digest('hex').slice(0,16))"

# AES-GCM encryption
node -e "const c=require('crypto');const iv=c.randomBytes(16);const ciph=c.createCipheriv('aes-256-gcm',c.randomBytes(32),iv);console.log('enc ok')"

# Audit event
node -e "console.log(JSON.stringify({ts:Date.now(),user:'u1',action:'read',resource:'orders/42',outcome:'allow'}))"
```

## Control Checklist
- Encrypt PII at rest and in transit
- Mask PII in logs
- Log access to sensitive endpoints
- Retention policy enforced in code

## Testing
Verify no PII appears in raw logs after requests.

## Best Practices
- Minimize PII in responses by default
- Never log full tokens or PII

## Capabilities

### data-protection
Apply encryption, masking, and retention controls to API data

**Parameters:**
- `algorithm` (string): Encryption algorithm
- `field` (string): Field to protect

**Commands:**
- `openssl rand -base64 32`
- `node -e "const c=require('crypto');const k=c.randomBytes(32);console.log('key bytes:',k.length)"`
- `node -e "const c=require('crypto');const h=c.createHash('sha256');console.log(h.update('email@localhost').digest('hex').slice(0,16))"`
- `python -c "import hashlib;print(hashlib.sha256(b'email@localhost').hexdigest()[:16])"`
- `node -e "const c=require('crypto');const iv=c.randomBytes(16);const ciph=c.createCipheriv('aes-256-gcm',c.randomBytes(32),iv);console.log('enc ok')"`

**Examples:**
- node -e "const c=require('crypto');const k=c.randomBytes(32);console.log('key bytes:',k.length)"
- python -c "import hashlib;print(hashlib.sha256(b'email@localhost').hexdigest()[:16])"
- openssl rand -base64 32

### audit-logging
Log access and data events for compliance evidence

**Parameters:**
- `user` (string): Acting user
- `action` (string): Audited action

**Commands:**
- `node -e "console.log(JSON.stringify({ts:Date.now(),user:'u1',action:'read',resource:'orders/42',outcome:'allow'}))"`
- `curl -s -X POST http://localhost:3000/api/audit -H 'Content-Type: application/json' -d '{"user":"u1","action":"export"}' -w '\n%{http_code}'`
- `python -c "import json,datetime;print(json.dumps({'ts':datetime.datetime.now().isoformat(),'action':'login'}))"`
- `node -e "console.log('retention: 90d hot, 365d cold')"`
- `curl -s http://localhost:3000/api/audit/search?user=u1 | python -m json.tool`

**Examples:**
- node -e "console.log(JSON.stringify({ts:Date.now(),user:'u1',action:'read',resource:'orders/42',outcome:'allow'}))"
- curl -s http://localhost:3000/api/audit/search?user=u1 | python -m json.tool
- python -c "import json,datetime;print(json.dumps({'ts':datetime.datetime.now().isoformat(),'action':'login'}))"

## References
- [GDPR Guide](https://gdpr-info.eu/)
- [OWASP Data Protection](https://owasp.org/www-project-data-protection/)

