Connect your workflows to the K0nsult governance layer
Full client for K0nsult governance API. Uses native fetch (Node 18+). No external dependencies required.
// K0nsult Node.js Client const K0NSULT_URL = 'https://k0nsult.fly.dev'; // Pre-check before running workflow async function preCheck(workflowId, dataClass, actionType) { const res = await fetch(`${K0NSULT_URL}/api/n8n/pre-check`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ workflow_id: workflowId, data_classification: dataClass, action_type: actionType }) }); return res.json(); } // Log execution result async function logExecution(workflowId, status, durationMs) { const res = await fetch(`${K0NSULT_URL}/api/n8n/execution-log`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ workflow_id: workflowId, status, duration_ms: durationMs }) }); return res.json(); } // Request approval (pause workflow) async function requestApproval(workflowId, reason) { const res = await fetch(`${K0NSULT_URL}/api/n8n/pause-for-approval`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ workflow_id: workflowId, reason }) }); return res.json(); } // Get audit trail async function getAudit(workflowId) { const res = await fetch(`${K0NSULT_URL}/api/n8n/audit/${workflowId}`); return res.json(); } // Example usage (async () => { // 1. Check policy before running const check = await preCheck('invoice-processing', 'financial', 'modify'); console.log('Policy check:', check.decision, 'Risk:', check.risk_score); if (check.decision === 'APPROVE') { // 2. Run your workflow (via n8n or directly) // ... your execution logic ... // 3. Log the result await logExecution('invoice-processing', 'COMPLETED', 3200); } else if (check.decision === 'REVIEW') { // 4. Request human approval const approval = await requestApproval('invoice-processing', 'High-value financial transaction'); console.log('Approval ID:', approval.approval_id); } // 5. Check audit trail const audit = await getAudit('invoice-processing'); console.log('Audit entries:', audit.count); })();
APPROVE, REVIEW, or DENY decisions with a numeric risk_score (0-100). Always check the decision before proceeding with sensitive operations.
Class-based client using the requests library. Install with pip install requests.
import requests K0NSULT_URL = 'https://k0nsult.fly.dev' class K0nsultClient: def __init__(self, base_url=K0NSULT_URL): self.base_url = base_url def pre_check(self, workflow_id, data_class, action_type): r = requests.post(f'{self.base_url}/api/n8n/pre-check', json={ 'workflow_id': workflow_id, 'data_classification': data_class, 'action_type': action_type }) return r.json() def log_execution(self, workflow_id, status, duration_ms): r = requests.post(f'{self.base_url}/api/n8n/execution-log', json={ 'workflow_id': workflow_id, 'status': status, 'duration_ms': duration_ms }) return r.json() def request_approval(self, workflow_id, reason): r = requests.post(f'{self.base_url}/api/n8n/pause-for-approval', json={ 'workflow_id': workflow_id, 'reason': reason }) return r.json() def get_audit(self, workflow_id): r = requests.get(f'{self.base_url}/api/n8n/audit/{workflow_id}') return r.json() def get_policy(self, workflow_id): r = requests.get(f'{self.base_url}/api/n8n/policy/{workflow_id}') return r.json() # Usage client = K0nsultClient() result = client.pre_check('support-triage', 'internal', 'classify') print(f"Decision: {result['decision']}, Risk: {result['risk_score']}")
Quick command-line examples for testing and scripting. Works on Linux, macOS, and Windows (Git Bash / WSL).
# Pre-check: validate workflow before execution curl -X POST https://k0nsult.fly.dev/api/n8n/pre-check \ -H "Content-Type: application/json" \ -d '{"workflow_id":"test","data_classification":"internal","action_type":"classify"}'
# Log execution result to audit trail curl -X POST https://k0nsult.fly.dev/api/n8n/execution-log \ -H "Content-Type: application/json" \ -d '{"workflow_id":"test","status":"COMPLETED","duration_ms":1500}'
# Get audit trail for a workflow
curl https://k0nsult.fly.dev/api/n8n/audit/test# Get policy rules for a workflow
curl https://k0nsult.fly.dev/api/n8n/policy/default
All 12 K0nsult governance API endpoints. Base URL: https://k0nsult.fly.dev
| # | Method | Endpoint | Description | Auth |
|---|---|---|---|---|
| 1 | POST | /api/n8n/pre-check |
Validate workflow against policy before execution | Optional |
| 2 | POST | /api/n8n/execution-log |
Log execution result to immutable audit trail | Optional |
| 3 | POST | /api/n8n/escalate |
Route decision to human review queue | Optional |
| 4 | GET | /api/n8n/policy/:id |
Get policy rules for a specific workflow | None |
| 5 | POST | /api/n8n/audit |
Record immutable audit trail entry | Optional |
| 6 | GET | /api/n8n/audit/:workflowId |
Retrieve full audit trail for a workflow | None |
| 7 | POST | /api/n8n/pause-for-approval |
Pause workflow and request human approval | Optional |
| 8 | GET | /api/n8n/approval/:id |
Check approval status | None |
| 9 | POST | /api/n8n/approve/:id |
Approve a pending workflow | Required |
| 10 | POST | /api/n8n/reject/:id |
Reject a pending workflow | Required |
| 11 | GET | /api/n8n/health |
Health check and system status | None |
| 12 | GET | /api/n8n/metrics |
Governance metrics and statistics | None |
X-K0nsult-Key header. "Optional" endpoints work without auth but provide enhanced features with it. Contact kontakt@k0nsult.dev for API key provisioning.
X-RateLimit-Remaining and X-RateLimit-Reset headers.
/api/n8n/pre-check before every workflow execution. If the response is DENY, halt immediately. If REVIEW, pause and request human approval. Only proceed on APPROVE.
COMPLETED. On failure, log FAILED with error details. This creates a complete audit trail for compliance.
/api/n8n/policy/:id at startup to load rules for each workflow. Cache policies locally with a 5-minute TTL. Use rules to determine data handling, escalation thresholds, and retention periods.