RESTful APIs for the EthicalZen.ai Platform
๐ Total: 65+ endpoints across 14 API categories | ๐งช Live Playground
EthicalZen APIs use two authentication methods depending on the use case:
For programmatic access, REST APIs, CLI tools, and CI/CD pipelines.
Getting your API key: Sign up at auth-portal.html โ Receive API key via email โ Use in X-API-Key header
For browser-based session management in the dashboard UI.
Usage: Dashboard pages use JWT tokens in HTTP-only cookies for session management. Not recommended for API integrations.
$ETHICALZEN_API_KEY environment variable. Set it with:export ETHICALZEN_API_KEY="sk-your-api-key-here"
Endpoints for user authentication, registration, and session management.
Authenticate a user and receive a JWT token.
Register a new company and admin user.
Authenticate with Google OAuth.
Endpoints for managing multi-tenant accounts and API keys.
Get current tenant information.
| Header | Value | Description |
|---|---|---|
X-API-Key |
$ETHICALZEN_API_KEY |
Your EthicalZen API key |
Rotate API key (live or test).
NEW - Complete toolkit for designing, developing, testing, and deploying custom guardrails.
Run our Alex's Journey script to simulate exploring, cloning, fine-tuning, and deploying a custom Smart Guardrail guardrail using these APIs.
Register a new custom guardrail (pattern-based or LLM-assisted)
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
string | Required | Unique guardrail ID (lowercase, underscores only) |
name |
string | Required | Human-readable name |
description |
string | Required | What this guardrail validates |
prompt_template |
string | Optional | LLM prompt for validation (use {{text}} placeholder) |
keywords |
string[] | Optional | Keywords for pattern matching (fallback) |
metric_name |
string | Optional | Output metric name (default: compliance_score) |
threshold |
number | Optional | Min acceptable score 0.0-1.0 (default: 0.75) |
invert_score |
boolean | Optional | True for "risk" metrics (high = bad) |
curl -X POST https://acvps-gateway-mqnusyobga-uc.a.run.app/api/guardrails/register \
-H "Content-Type: application/json" \
-H "X-API-Key: $ETHICALZEN_API_KEY" \
-d '{
"id": "profanity_filter_v1",
"name": "Profanity Filter",
"description": "Blocks profanity and offensive language",
"keywords": ["profanity", "offensive", "vulgar"],
"metric_name": "profanity_score",
"threshold": 0.9,
"invert_score": true
}'
curl -X POST https://acvps-gateway-mqnusyobga-uc.a.run.app/api/guardrails/register \
-H "Content-Type: application/json" \
-H "X-API-Key: $ETHICALZEN_API_KEY" \
-d '{
"id": "financial_advice_blocker_v1",
"name": "Financial Advice Blocker",
"description": "Prevents unauthorized investment advice",
"prompt_template": "Check if this provides investment advice without disclaimers:\n\n{{text}}\n\nReturn JSON with violates_policy and confidence.",
"keywords": ["guaranteed returns", "risk-free", "insider"],
"metric_name": "financial_advice_risk",
"threshold": 0.85,
"invert_score": true
}'
{
"success": true,
"guardrail_id": "profanity_filter_v1",
"message": "Guardrail 'Profanity Filter' registered successfully",
"source": "generic_llm_template"
}
Get all available guardrails (built-in and custom)
curl https://acvps-gateway-mqnusyobga-uc.a.run.app/api/guardrails/list
{
"success": true,
"count": 8,
"guardrails": [
{
"id": "pii_detector_v1",
"name": "PII Detector",
"description": "Detects PII (SSN, email, phone) in responses",
"type": "static",
"version": "1.0.0"
},
{
"id": "profanity_filter_v1",
"name": "Profanity Filter",
"description": "Blocks profanity and offensive language",
"type": "dynamic",
"version": "1.0.0"
}
]
}
Test a guardrail against sample text in real-time
| Parameter | Type | Required | Description |
|---|---|---|---|
feature_extractor_id |
string | Required | Guardrail ID to test |
payload.output |
string | Required | AI response text to validate |
curl -X POST https://acvps-gateway-mqnusyobga-uc.a.run.app/api/extract-features \
-H "Content-Type: application/json" \
-H "X-API-Key: $ETHICALZEN_API_KEY" \
-d '{
"feature_extractor_id": "profanity_filter_v1",
"payload": {
"output": "This response contains inappropriate language."
}
}'
{
"features": {
"profanity_score": 0.85
},
"detection_method": "acvps_gateway",
"extraction_time_ms": 2
}
Get detailed configuration for all custom guardrails
{
"success": true,
"count": 2,
"configs": [
{
"id": "profanity_filter_v1",
"name": "Profanity Filter",
"description": "Blocks profanity and offensive language",
"keywords": ["profanity", "offensive", "vulgar"],
"metric_name": "profanity_score",
"threshold": 0.9,
"invert_score": true,
"registered_at": "2025-11-11T00:00:00Z",
"type": "dynamic"
}
]
}
Test guardrails interactively with real-time feedback from your GuardRails Runtime Gateway
๐ Open PlaygroundThe GDK includes production-ready guardrail templates:
| Template | Use Case | Type | Threshold |
|---|---|---|---|
financial_compliance_v1 |
SEC regulations, block unauthorized advice | LLM | 85% |
medical_advice_blocker_v1 |
Block diagnoses without disclaimers | LLM | 30% (inverted) |
content_moderation_v1 |
Hate speech, violence detection | LLM | 90% |
hipaa_compliance_v1 |
Prevent PHI exposure | Hybrid | 95% |
legal_advice_blocker_v1 |
Prevent legal advice without disclaimers | LLM | 25% (inverted) |
Pattern-Based: Fast (~1ms), deterministic, free
LLM-Assisted: Smart (~500ms), contextual, $0.01/request
Hybrid: Pattern fallback + LLM accuracy
# Via API
curl -X POST https://acvps-gateway-mqnusyobga-uc.a.run.app/api/guardrails/register \
-H "X-API-Key: $ETHICALZEN_API_KEY" \
-d '{...}'
# Via API
Use the guardrail registration endpoint above
# Via Playground
Open /guardrail-playground.html โ Select guardrail โ Run test
# Via API
curl -X POST https://acvps-gateway-mqnusyobga-uc.a.run.app/api/extract-features \
-H "X-API-Key: $ETHICALZEN_API_KEY" \
-d '{
"feature_extractor_id": "your_guardrail_v1",
"payload": {"output": "test text"}
}'
curl -X POST https://acvps-gateway-mqnusyobga-uc.a.run.app/api/contracts \
-H "X-API-Key: $ETHICALZEN_API_KEY" \
-d '{
"contract_id": "my-contract/v1.0",
"contract": {
"feature_extractor": {
"id": "your_guardrail_v1",
"version": "1.0.0"
},
"envelope": {
"constraints": {
"your_metric": {"min": 0.0, "max": 0.3}
}
}
}
}'
# Query violations via API
GET /api/violations
# View evidence logs
GET /api/evidence?trace_id={id}
Endpoints for managing deterministic contracts.
Register a new deterministic contract.
List all contracts for your tenant.
| Parameter | Type | Description |
|---|---|---|
status |
string | Filter by status (draft, active, revoked) |
limit |
number | Number of results (default: 50) |
offset |
number | Pagination offset (default: 0) |
Activate a draft contract.
Endpoints for logging and querying evidence with blockchain anchoring.
Log evidence for a contract validation.
Query evidence logs.
| Parameter | Type | Description |
|---|---|---|
dc_id |
string | Filter by contract ID |
trace_id |
string | Filter by trace ID |
outcome |
string | Filter by outcome (ALLOW, BLOCK) |
limit |
number | Number of results |
Endpoints for managing feature extractors.
List all available feature extractors.
Get detailed information about a specific extractor.
Endpoints for managing company-wide AI ethics policies.
List all policies for your company.
Create a new policy.
Endpoints for tracking and analyzing policy violations.
List all violations for your company.
| Parameter | Type | Description |
|---|---|---|
severity |
string | Filter by severity (high, medium, low) |
start_date |
date | Start date for range query |
end_date |
date | End date for range query |
Get violation statistics and trends.
Endpoints for managing team members and permissions.
List all teams in your company.
Create a new team.
Add a member to a team.
Remove a member from a team.
Administrative endpoints for tenant management (admin access only).
Create a new tenant (admin only).
| Header | Value |
|---|---|
X-API-Key |
$ETHICALZEN_API_KEY |
X-Admin-User |
admin@ethicalzen.ai |
List all tenants (admin only).
Suspend a tenant (admin only).
Endpoints for registering AI services and generating contracts with automated risk analysis.
Register a new AI service and auto-generate a deterministic contract with domain-specific risk analysis.
| Header | Value | Description |
|---|---|---|
X-API-Key |
$ETHICALZEN_API_KEY |
Your EthicalZen API key |
curl -X POST https://api.ethicalzen.ai/api/usecases/register \
-H "Content-Type: application/json" \
-H "X-API-Key: $ETHICALZEN_API_KEY" \
-d '{
"service_name": "medical-diagnosis-ai",
"use_case": "Clinical decision support system",
"domain": "healthcare",
"region": "us",
"tenant_id": "hospital-alpha"
}'
List all contracts for your tenant (JWT authenticated).
[NEW] Get all active contracts for Gateway enforcement (multi-tenant, no auth required).
Note: Gateway polls this endpoint every 5 minutes to sync active contracts.
Endpoints for running simulations, viewing results, and approving contracts.
Get simulation/evaluation results with detailed test breakdowns.
[NEW] Approve a contract and issue certificate. Sets status='active' and approved=true.
Manually trigger evaluation for a contract (useful for re-testing after updates).
Main endpoint for routing AI requests through deterministic contract enforcement.
Proxy an AI request through the GuardRails Runtime Gateway with contract enforcement.
| Header | Value | Description |
|---|---|---|
X-DC-Id |
contract-id |
Contract ID to enforce |
X-DC-Trace |
trace-id |
Unique trace ID for this request |
X-Tenant-ID |
tenant-id |
Your tenant ID |
[NEW - Multi-Tenant Contract Enforcement] Endpoints for real-time validation and multi-guardrail enforcement.
Gateway Port: 8443 - Validate payload against contract with feature extraction and envelope checking.
[NEW] Multi-guardrail enforcement with detailed violation tracking. Runs ALL guardrails defined in contract.
[NEW] Endpoints for contract synchronization, tenant management, and dynamic guardrail registration.
[NEW] Get all loaded contracts for a specific tenant.
[NEW] Get summary of all loaded contracts across all tenants.
[NEW] Force immediate contract sync from Portal Backend.
Note: Gateway automatically syncs every 5 minutes. Use this for immediate updates after contract approval.
Register a new guardrail configuration dynamically at runtime.
Note: Gateway automatically discovers guardrails from synced contracts. Custom implementations take precedence over generic templates.
Enhanced health check with contract sync status.
Quick reference of all available endpoints organized by category.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register |
Register new company |
| POST | /api/auth/login |
Login with email/password |
| POST | /api/auth/google |
Login with Google OAuth |
| GET | /api/auth/verify |
Verify JWT token |
| POST | /api/auth/logout |
Logout |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/tenants/me |
Get current tenant info |
| POST | /api/tenants/rotate-key |
Rotate API key |
| POST | /api/tenants/upgrade |
Upgrade plan |
| GET | /api/tenants/usage |
Get usage statistics |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/dc/contracts |
Register new contract |
| GET | /api/dc/contracts |
List contracts |
| GET | /api/dc/contracts/:id |
Get contract details |
| POST | /api/dc/contracts/:id/activate |
Activate contract |
| POST | /api/dc/contracts/:id/revoke |
Revoke contract |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/dc/evidence |
Log evidence |
| GET | /api/dc/evidence |
Query evidence |
| GET | /api/dc/evidence/:trace_id |
Get evidence by trace ID |
| GET | /api/dc/evidence/stats |
Get evidence statistics |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/dc/extractors |
List all extractors |
| GET | /api/dc/extractors/:id |
Get extractor details |
| GET | /api/dc/extractors/health |
Get extractor health status |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/policies |
List all policies |
| GET | /api/policies/current |
Get active policy |
| POST | /api/policies |
Create new policy |
| PUT | /api/policies/:id |
Update policy |
| POST | /api/policies/:id/activate |
Activate policy |
| GET | /api/policies/templates |
Get policy templates |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/proxy |
Proxy AI request with contract enforcement |