LiyaEngine Docs

Data Retention

Configure how long sessions, messages, embeddings, and audit logs are retained, and enable automatic PII redaction.

Dashboard

dataRetentionConfig controls data lifecycle across all tenant data. Every tenant starts with the defaults below. An admin can change some of them from Settings → Data retention in the dashboard, or with PATCH /dashboard/account/data-retention (see Changing retention settings): the run, event, session and message windows, what runs and traces store, and two switches for redacting health and financial identifiers. The other windows have no endpoint yet. auto_redact_pii is toggled through a separate top-level piiProtection field (see PII handling below), not by sending a dataRetentionConfig block.


Schema

{
  "dataRetentionConfig": {
    "session_retention_days": 30,
    "message_retention_days": 90,
    "artifact_retention_days": 365,
    "embedding_retention_days": 365,
    "audit_log_retention_days": 730,
    "auto_redact_pii": true,
    "pii_retention_days": 7
  }
}

Retention periods

FieldDefaultWhat it removes
session_retention_days30AI sessions idle for this long, with their messages
message_retention_days90Individual messages, even in a session still in use
artifact_retention_days365Files and generated content attached to sessions
embedding_retention_days365Vectors derived from conversations (session summaries). Never knowledge base content
audit_log_retention_days730Compliance audit log entries, 2 years by default
pii_retention_days7The text of messages where PII was detected but not redacted (see below)
correction_retention_days365The text of corrections your app reported (question, reply, correct answer, note). The record that a conversation counted against a passage stays, so flag counts do not change

A nightly job applies each window per workspace. Flagged and error/critical-severity audit entries are kept regardless of age. Setting a field to null disables that window, and the data is kept until you delete it.

Knowledge base content is never expired

Documents you upload, content from connectors, and the embeddings made from them are your content. They are removed when you delete them, not when a retention window passes. embedding_retention_days applies only to vectors the platform derived from conversations.

How deletion is switched on

Deletion of conversation data, artifacts, conversation embeddings, PII text and trace detail is enabled per deployment. Until a category is enabled, the nightly job reports what it would remove and removes nothing, because the first run acts on everything already past its window. Audit-log retention is always applied. Ask your account team which categories are enabled for your workspace.


Changing retention settings

An admin can read and change these settings. Send only the fields you want to change.

GET   https://api.liyaengine.ai/dashboard/account/data-retention
PATCH https://api.liyaengine.ai/dashboard/account/data-retention
Authorization: Bearer <dashboard_jwt>
Content-Type: application/json

{ "session_retention_days": 14, "redact_financial_identifiers": true }
FieldDefaultValues
workflow_run_retention_days90Whole days, 1 to 3650. Finished workflow runs, their steps and approval requests.
workflow_event_retention_days30 (7 with minimal run storage)Whole days, 1 to 3650. Events other workflows subscribe to.
agent_run_retention_days90Whole days, 1 to 3650. Finished agent runs, their steps and idle sessions.
session_retention_days30Whole days, 1 to 3650. Same meaning as in the table above.
message_retention_days90Whole days, 1 to 3650. Same meaning as in the table above.
run_storagefullfull keeps a workflow run's input and each step's result. minimal keeps when it ran, which steps ran and whether they worked, and only the names and types of the data, never the values.
trace_storagenullfull, minimal, or null. null follows session memory: full traces while it is on, minimal while it is off.
redact_healthcare_identifiersfalsetrue or false. See below.
redact_financial_identifiersfalsetrue or false. See below.

The response is the settings after the change, plus conversation_retention_enforced: whether this deployment deletes conversation data when its windows pass, or only reports what it would delete (see How deletion is switched on). A value that is not valid returns 400 with the code INVALID_RETENTION and a message naming the field, and so does a request that changes nothing. Every change is written to the audit log. The change applies to requests from now on.


Traces and plan windows

Every request produces a trace, and a trace is a stored message or an agent or workflow run. Your plan sets how long traces are kept and shown:

PlanTrace window
Free7 days
Core30 days
Pro, Teams1 year
EnterpriseNo plan maximum
  • Shorter plans (Free, Core). The Trace Explorer and the Traces API show nothing older than the window, and older trace detail (timed steps, retrieved chunks, agent steps and guardrail issues) is removed when trace-detail deletion is enabled. The message itself, with its tokens and cost, stays until message_retention_days.
  • Longer plans (Pro, Teams). A stored message or run is kept at least as long as the plan's window, even if you configured a shorter session_retention_days, message_retention_days or run window. Configured windows can lengthen retention, never shorten it below the plan's promise.
  • Enterprise. The plan imposes no limit, so your configured windows apply. The window is set in your agreement.

To store no message text at all, use minimal capture or per-request consent flags (below).


PII handling

auto_redact_pii

When true, PII detected in messages (names, email addresses, phone numbers, national IDs) is automatically redacted before storage. Default: true.

Redacted fields are replaced with [REDACTED] markers. The original content is never stored.

To change this from the dashboard API, send a top-level piiProtection boolean — not a nested dataRetentionConfig.auto_redact_pii field:

PATCH https://api.liyaengine.ai/dashboard/account/config
Authorization: Bearer <dashboard_jwt>
Content-Type: application/json

{ "piiProtection": false }

pii_retention_days

Automatic redaction removes PII before storage, and is on by default. If a workspace turns it off, messages in which PII was detected are stored as written. After pii_retention_days (default 7), the text of those messages is replaced with its redacted form and the message is marked redacted. The message itself stays, so the conversation and its metrics survive. Setting this short keeps PII from being retained beyond what is operationally necessary.


Redacting health and financial identifiers

Automatic PII redaction covers social security numbers, card numbers, email addresses, US-format phone numbers and dates of birth written as MM/DD/YYYY. Two more sets are off by default and are switched on per workspace, because they are broader and a workspace that does not need them would see false matches.

SettingAlso redacts
redact_healthcare_identifiersMember and subscriber IDs, medical record numbers, NPIs, claim and authorization numbers, Medicare IDs, street addresses, state and ZIP, and dates in any format.
redact_financial_identifiersIBANs, and passport numbers.

An identifier is matched by its shape, or after its label. A passport number is recognised only when it is introduced as one ("passport number X1234567"), so an order or transaction ID is never taken for it, and a healthcare number is matched after "member ID", "MRN" or "claim #". Names are caught only when the optional machine-learning classifier is on.

A switch applies in every place the workspace redacts text:

  • Before the model reads a message, when the guardrail policy's PII mode is redact. A policy set to flag records the identifier and lets it through.
  • Stored messages the nightly job scrubs: the text of a message where personal data was detected but not redacted is redacted after pii_retention_days.
  • Action parameters and responses, when the guardrail policy sanitizes them (sanitize_parameters, sanitize_response).
  • Drafts built from past conversations by self-healing: flagged passages, corrections, trace-to-case drafts, knowledge drafts and answer checks.

The guardrail templates for financial services and healthcare recommend the matching switch, and applying a template does not turn it on.


Individual requests can override retention behaviour at the user level using the consent field:

{
  "input": { "user_id": "usr_123", ... },
  "consent": {
    "allow_data_storage": false,
    "allow_session_memory": false,
    "allow_embeddings": false,
    "allow_analytics": true,
    "data_retention_days": 1
  }
}

When allow_data_storage: false, the request is processed but no messages or session data are persisted. Useful for privacy-sensitive workflows or when a user has opted out of data storage.


Compliance

  • Audit logs are immutable and tamper-evident
  • All data is scoped by tenant_id — no data is shared between tenants
  • GDPR data subject access requests and deletion requests should be handled via the admin API or by contacting support

On this page