Tenant Isolation
Every API request is scoped to a single tenant. Cross-tenant data access is architecturally prevented at the query layer. How it works:- Tenant resolution — Each request resolves a
tenantIdfrom either the JWT session (user.tenantId) or theX-Tenant-Idheader (for API key auth). API key authentication binds the tenant to the key itself, ignoring anyX-Tenant-Idheader to prevent spoofing. - Database validation — The resolved tenant ID is validated against the
Tenanttable in the database. If the tenant does not exist, the request is rejected with403 Forbidden. The system fails closed: if the database is unreachable during validation, the request is denied. - Query enforcement — A tenant-filter helper injects
tenantIdinto every databasewhereclause. A scoped-query wrapper provides find / create / update / delete primitives that automatically include the tenant filter. Calling these helpers without atenantIdthrows an error. - Single-tenant mode — For self-hosted deployments, set
SINGLE_TENANT_MODE=trueto bypass tenant resolution and usetenantId: "default"for all requests.
Every database query in every API route passes through tenant filtering. There is no “admin bypass” that returns data across tenants.
Audit Logging
All entity mutations (create, update, delete) are recorded in an immutable audit log with a cryptographic integrity chain.What Gets Logged
Every write operation on platform entities produces an audit record with the following fields:Immutability
Audit logs cannot be modified or deleted through the API. The audit log endpoint explicitly rejects DELETE, PUT, and PATCH requests with a405 Method Not Allowed response:
“Audit logs are immutable and cannot be deleted.”
Resilience
The audit system uses a circuit breaker pattern. If the database becomes temporarily unavailable, audit events are buffered in memory (up to 500 events) and flushed when connectivity is restored. A per-tenant mutex prevents hash chain forks from concurrent writes.Querying Audit Logs
X-Tenant-Id or session cookie. Requires admin role.
Query parameters:
Response:
Audit Verification
Each audit log entry includes a SHA-256 integrity hash computed over its contents and the hash of the previous entry, forming a cryptographic chain. Tampering with any record breaks the chain from that point forward.How the Hash Chain Works
- Each audit record’s hash is computed as:
SHA-256(action + entityType + entityId + entityName + changes + userId + userName + tenantId + requestId + prevHash) - The first record in the chain uses
"genesis"as the previous hash. - Each subsequent record references the
integrityHashof the record before it.
Verification Endpoint
X-Tenant-Id or session cookie. Requires admin role.
Query parameters:
Response:
hash_mismatch— The recomputed hash does not match the storedintegrityHash. The record’s contents were modified after creation.chain_link_mismatch— The record’sprevHashdoes not match theintegrityHashof the preceding record. A record was inserted or deleted in the middle of the chain.
Audit Export
Bulk export of audit logs for regulatory reporting and SOC 2 evidence collection.X-Tenant-Id or session cookie. Requires admin role. Rate limited to 10 requests per minute.
Query parameters:
The
csv format returns the export as a downloadable file with a Content-Disposition header.
You can also verify chain integrity through the export endpoint:
DSAR (Data Subject Access Requests)
The DSAR endpoint supports GDPR right-of-access and right-to-erasure requests. DSAR processing is asynchronous — the API accepts the request immediately and processes it in the background via a job queue.Submitting a DSAR
X-Tenant-Id or session cookie. Requires admin role. Rate limited to 10 requests per minute.
Parameters:
Response (202 Accepted):
Checking DSAR Status
PII Masking
Data pipelines include two built-in transforms for protecting sensitive data before it reaches analytics tables or export targets.Hash Transform
Replaces field values with a one-way cryptographic hash. Useful for pseudonymization where you need consistent identifiers without exposing the original value. Configuration:- Fields to Hash — One or more source fields to hash
- Algorithm —
SHA-256(recommended),SHA-512, or legacy MD5
Mask PII Transform
Applies pattern-based masking that preserves partial information for operational use while hiding sensitive details. Masking patterns are applied automatically based on detected data formats:
Configuration:
- Fields to Mask — One or more source fields to apply masking to
When to Use
- Before loading to analytics — Mask PII fields in your ETL pipeline before data lands in reporting tables
- Before export — Hash or mask sensitive fields before sending data to external systems
- Pseudonymization — Use the hash transform to create consistent non-reversible identifiers for analytics
Data Retention
Configurable retention policies control how long different classes of data are kept. Retention configs are per-tenant and per-data-class.Retention Config Endpoint
admin role.
Creating or Updating a Retention Policy
Data classes:
The Settings UI’s Legal Hold switch (Settings > Retention) applies
legalHold: true/false to every class above in one save — a single platform-wide hold for the tenant. Placing a hold on one class only is possible via a direct API call.
Retention policy changes are themselves audit-logged with action retention_config.upsert (or retention_config.legal_hold when a legal hold is applied).
Encryption
Data in Transit
All connections to the KaireonAI platform are over HTTPS. The playground deployment atplayground.kaireonai.com enforces TLS.
Data at Rest
- Connector credentials — The
authConfigfield on connector records stores sensitive connection parameters (passwords, API keys, access tokens). These are stored as encrypted JSON in the database. - API keys — Platform API keys (
krn_prefix) are validated against hashed values in the database.
Session Security
Authentication uses JWT-based sessions via NextAuth. Session tokens are HTTP-only cookies with secure flags in production.India: DPDPA Compliance
KaireonAI supports compliance with India’s Digital Personal Data Protection Act, 2023 (DPDPA), which governs the processing of digital personal data of Indian residents. Penalties for non-compliance can reach up to INR 250 crore (~$30M).How KaireonAI Maps to DPDPA Requirements
India Data Residency
For deployments requiring data to remain within India (RBI/SEBI regulated entities), deploy KaireonAI to AWSap-south-1 (Mumbai) region:
- Database: Use RDS PostgreSQL in
ap-south-1with automated backups within the same region - Application: Deploy via App Runner or ECS in
ap-south-1 - No cross-region replication: Configure single-region to ensure no data leaves India
TRAI DND Compliance
The Telecom Regulatory Authority of India maintains a Do Not Disturb (DND) registry. KaireonAI’s suppression engine supports DND compliance:- Contact policies can enforce channel-level suppressions (block SMS/calls to DND-registered numbers)
- Outcome-based suppression automatically stops contacting customers who repeatedly opt out
- Cross-channel caps prevent exceeding frequency limits across SMS, email, and push channels
DPDPA Erasure Coverage
The GDPR erasure endpoint (POST /api/v1/gdpr/erasure) deletes the following customer data:
Related
Authentication
User authentication, API keys, and session management
Audit Logs API
Full API reference for audit log endpoints
Data Platform
Connectors, schemas, and data pipelines