Retention, holds and the audit log
How long records are kept, what keeps them longer, and who did what in the organization.
#Retention and holds
A retention schedule deletes a model's logged decisions, with their explanations and what was recorded as decided, once they are older than the period set for the model or, failing that, for the organization. With no schedule, records are kept until someone deletes them. A hold keeps one decision, or every record of a model, whatever the schedule says, and stops anyone deleting it by hand, until it is released.
A schedule never deletes models, analyses, insights, reason tables or the audit log. It is applied a few times a day, and every deletion is entered in the audit log. Keeping and deleting records describes all of this for compliance teams.
How long to keep records is yours to decide. The shortest period Kaimei accepts is 30 days.
#Retrieve the retention schedule
/v1/retentionAPI key or sessionThe schedule, model by model. Each model has the period that applies to it and where it comes from (source: model, organization or none), how many decisions it holds and when the oldest was logged, what the schedule would delete now (due), and what is under a hold. Anyone in the organization may read it.
Returns
{default, minimum_days, models, holds, last_run_at, covers}. default is the organization's period, or null when records are kept until deleted. keep_days: null on a model with own: true means its records are kept until deleted whatever the organization's period.schedule = client.retention.retrieve()
print(schedule.default.keep_days if schedule.default else "kept until deleted")
for item in schedule.models:
print(item.model.slug, item.keep_days, item.due.decisions, item.held.decisions)curl https://api.kaimei.ai/v1/retention \
-H "Authorization: Bearer $KAIMEI_API_KEY"{
"object": "retention",
"default": {
"keep_days": 760,
"set_by": {
"type": "user",
"user_id": "usr_8c1f0a7be2d94c6f5a3b",
"name": "Dana Lee",
"role": "admin"
},
"set_at": "2026-10-01T09:12:44.208113Z"
},
"minimum_days": 30,
"models": [
{
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer",
"status": "active"
},
"own": false,
"keep_days": 760,
"source": "organization",
"decisions": 18422,
"oldest_at": "2024-09-17T07:49:03.000000Z",
"due": {"decisions": 311, "explanations": 96},
"held": {"model": false, "decisions": 1}
},
{
"model": {
"id": "mdl_7a1c4e9b2d6f8035c1ae",
"slug": "fraud-encoder-v1",
"name": "Fraud screening encoder",
"status": "active"
},
"own": true,
"keep_days": 2557,
"source": "model",
"decisions": 126,
"oldest_at": "2026-09-12T16:12:40.000000Z",
"due": {"decisions": 0, "explanations": 0},
"held": {"model": false, "decisions": 0}
}
],
"holds": {"active": 1},
"last_run_at": "2026-10-31T18:00:07.114920Z",
"covers": "A schedule deletes logged decisions, their explanations and what was recorded as decided for them. It never deletes models, analyses, insights, reason tables or the audit log."
}#Set the organization's period
/v1/retentionSession token onlyDelete records keep_days after they are logged. null goes back to keeping records until someone deletes them.
Nothing is deleted by this call. The schedule is applied a few times a day, and applying it now is a call of its own, so a period can be set, its effect read from due, and corrected before anything is gone. 400 invalid_keep_days below 30 days or above 36,500.
Body parameters
Days a record is kept after it is logged, 30 to 36,500. null removes the period.
Returns
curl -X PUT https://api.kaimei.ai/v1/retention \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"keep_days": 760}'{
"object": "retention",
"default": {
"keep_days": 760,
"set_by": {
"type": "user",
"user_id": "usr_8c1f0a7be2d94c6f5a3b",
"name": "Dana Lee",
"role": "admin"
},
"set_at": "2026-10-01T09:12:44.208113Z"
},
"minimum_days": 30,
"models": [
{
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer",
"status": "active"
},
"own": false,
"keep_days": 760,
"source": "organization",
"decisions": 18422,
"oldest_at": "2024-09-17T07:49:03.000000Z",
"due": {"decisions": 311, "explanations": 96},
"held": {"model": false, "decisions": 1}
},
{
"model": {
"id": "mdl_7a1c4e9b2d6f8035c1ae",
"slug": "fraud-encoder-v1",
"name": "Fraud screening encoder",
"status": "active"
},
"own": true,
"keep_days": 2557,
"source": "model",
"decisions": 126,
"oldest_at": "2026-09-12T16:12:40.000000Z",
"due": {"decisions": 0, "explanations": 0},
"held": {"model": false, "decisions": 0}
}
],
"holds": {"active": 1},
"last_run_at": "2026-10-31T18:00:07.114920Z",
"covers": "A schedule deletes logged decisions, their explanations and what was recorded as decided for them. It never deletes models, analyses, insights, reason tables or the audit log."
}#Give a model its own period
/v1/retention/models/{model}Session token onlykeep_days replaces the organization's period for this model, longer or shorter. null keeps this model's records until someone deletes them, whatever the organization's period.Path parameters
Model id or slug.
Body parameters
30 to 36,500, or null to keep this model's records until deleted.
Returns
curl -X PUT https://api.kaimei.ai/v1/retention/models/fraud-encoder-v1 \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"keep_days": 2557}'{
"object": "retention",
"default": {
"keep_days": 760,
"set_by": {
"type": "user",
"user_id": "usr_8c1f0a7be2d94c6f5a3b",
"name": "Dana Lee",
"role": "admin"
},
"set_at": "2026-10-01T09:12:44.208113Z"
},
"minimum_days": 30,
"models": [
{
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer",
"status": "active"
},
"own": false,
"keep_days": 760,
"source": "organization",
"decisions": 18422,
"oldest_at": "2024-09-17T07:49:03.000000Z",
"due": {"decisions": 311, "explanations": 96},
"held": {"model": false, "decisions": 1}
},
{
"model": {
"id": "mdl_7a1c4e9b2d6f8035c1ae",
"slug": "fraud-encoder-v1",
"name": "Fraud screening encoder",
"status": "active"
},
"own": true,
"keep_days": 2557,
"source": "model",
"decisions": 126,
"oldest_at": "2026-09-12T16:12:40.000000Z",
"due": {"decisions": 0, "explanations": 0},
"held": {"model": false, "decisions": 0}
}
],
"holds": {"active": 1},
"last_run_at": "2026-10-31T18:00:07.114920Z",
"covers": "A schedule deletes logged decisions, their explanations and what was recorded as decided for them. It never deletes models, analyses, insights, reason tables or the audit log."
}#Have a model follow the organization again
/v1/retention/models/{model}Session token onlyRemove the model's own period. It follows the organization's again.
Path parameters
Model id or slug.
Returns
curl -X DELETE https://api.kaimei.ai/v1/retention/models/fraud-encoder-v1 \
-H "Authorization: Bearer $SESSION_TOKEN"{
"object": "retention",
"default": {
"keep_days": 760,
"set_by": {
"type": "user",
"user_id": "usr_8c1f0a7be2d94c6f5a3b",
"name": "Dana Lee",
"role": "admin"
},
"set_at": "2026-10-01T09:12:44.208113Z"
},
"minimum_days": 30,
"models": [
{
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer",
"status": "active"
},
"own": false,
"keep_days": 760,
"source": "organization",
"decisions": 18422,
"oldest_at": "2024-09-17T07:49:03.000000Z",
"due": {"decisions": 311, "explanations": 96},
"held": {"model": false, "decisions": 1}
},
{
"model": {
"id": "mdl_7a1c4e9b2d6f8035c1ae",
"slug": "fraud-encoder-v1",
"name": "Fraud screening encoder",
"status": "active"
},
"own": true,
"keep_days": 2557,
"source": "model",
"decisions": 126,
"oldest_at": "2026-09-12T16:12:40.000000Z",
"due": {"decisions": 0, "explanations": 0},
"held": {"model": false, "decisions": 0}
}
],
"holds": {"active": 1},
"last_run_at": "2026-10-31T18:00:07.114920Z",
"covers": "A schedule deletes logged decisions, their explanations and what was recorded as decided for them. It never deletes models, analyses, insights, reason tables or the audit log."
}#Apply the schedule now
/v1/retention/runSession token onlyDelete what the schedule says is due, and say how much that was, model by model. dry_run=true deletes nothing and says what would be.
For each model with a period, decisions logged before logged_before are deleted with their explanations and what was recorded as decided, in one transaction with an audit log entry that says how many and under which period. A decision under a hold is kept, and a model with a hold on every record is skipped (held: true). Explanations that belong to no logged decision are deleted once they are older than the period themselves.
Query parameters
Count what would be deleted, and delete nothing.
Returns
{dry_run, ran_at, decisions, explanations, models}.curl -X POST https://api.kaimei.ai/v1/retention/run?dry_run=true \
-H "Authorization: Bearer $SESSION_TOKEN"{
"object": "retention_run",
"dry_run": true,
"ran_at": "2026-10-31T22:41:30.004118Z",
"decisions": 311,
"explanations": 96,
"models": [
{
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer"
},
"keep_days": 760,
"source": "organization",
"logged_before": "2024-10-01T22:41:30.004118Z",
"decisions": 311,
"explanations": 96,
"held": false
},
{
"model": {
"id": "mdl_7a1c4e9b2d6f8035c1ae",
"slug": "fraud-encoder-v1",
"name": "Fraud screening encoder"
},
"keep_days": 2557,
"source": "model",
"logged_before": "2019-10-31T22:41:30.004118Z",
"decisions": 0,
"explanations": 0,
"held": false
}
]
}#The Hold object
An instruction to keep records until it is released. A released hold is kept, with who released it and when.
Attributes
hold_…decision, or model for every record the model has logged, now and later.The decision held, for a hold on one.
{id, slug, name}: the model whose records are held, or the held decision's model.Why the records are kept.
Your own reference: a matter or case number.
Whether the hold is in force.
{type, user_id, name, role} of who placed it, as they were then, and when.The same for its release; null while it is in force.
{
"object": "hold",
"id": "hold_5b2e9d1c7a3f4e6b8d0a",
"scope": "decision",
"decision_id": "LOAN/2026/0042",
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer"
},
"reason": "Customer complaint under review",
"matter": "CASE-2026-0117",
"active": true,
"placed_by": {
"type": "user",
"user_id": "usr_3d9a6c1e8b7f4a2d5c0e",
"name": "Riley Counsel",
"role": "reviewer"
},
"placed_at": "2026-10-30T14:02:11.530291Z",
"released_by": null,
"released_at": null
}#Place a hold
/v1/retention/holdsAPI key or sessionKeep one decision's record (decision), or every record a model has logged (model), whatever the retention schedule says. Name exactly one of the two.
While a hold is in force the schedule skips what it covers, deleting the decision or one of its explanations is 409 record_held, and so is deleting the model or the organization. Several holds may cover the same record, one for each matter; it is kept until all are released. A hold moves with its model when the model is transferred.
Members, reviewers, admins and owners may place a hold. 404 decision_not_found when nothing is logged under the id.
Body parameters
A decision id. Either this or model.
A model id or slug, to hold every record it has.
Why, 3 to 1,000 characters.
Your own reference, up to 120 characters.
Returns
201.hold = client.retention.place_hold(
decision="LOAN/2026/0042",
reason="Customer complaint under review",
matter="CASE-2026-0117",
)curl -X POST https://api.kaimei.ai/v1/retention/holds \
-H "Authorization: Bearer $KAIMEI_API_KEY" \
-H "Content-Type: application/json" \
-d '{'decision': 'LOAN/2026/0042', 'reason': 'Customer complaint under review', 'matter': 'CASE-2026-0117'}'{
"object": "hold",
"id": "hold_5b2e9d1c7a3f4e6b8d0a",
"scope": "decision",
"decision_id": "LOAN/2026/0042",
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer"
},
"reason": "Customer complaint under review",
"matter": "CASE-2026-0117",
"active": true,
"placed_by": {
"type": "user",
"user_id": "usr_3d9a6c1e8b7f4a2d5c0e",
"name": "Riley Counsel",
"role": "reviewer"
},
"placed_at": "2026-10-30T14:02:11.530291Z",
"released_by": null,
"released_at": null
}#List holds
/v1/retention/holdsAPI key or sessionHolds in the organization, those in force first, then released ones, newest first.
Query parameters
true for holds in force, false for released ones.Model id or slug.
A decision id: the holds placed on that decision.
1 to 200.
Returns
for hold in client.retention.iterate_holds(active=True):
print(hold.decision_id or hold.model.name, hold.matter, hold.reason)curl "https://api.kaimei.ai/v1/retention/holds?active=true" \
-H "Authorization: Bearer $KAIMEI_API_KEY"{
"object": "list",
"data": [
{
"object": "hold",
"id": "hold_5b2e9d1c7a3f4e6b8d0a",
"scope": "decision",
"decision_id": "LOAN/2026/0042",
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer"
},
"reason": "Customer complaint under review",
"matter": "CASE-2026-0117",
"active": true,
"placed_by": {
"type": "user",
"user_id": "usr_3d9a6c1e8b7f4a2d5c0e",
"name": "Riley Counsel",
"role": "reviewer"
},
"placed_at": "2026-10-30T14:02:11.530291Z",
"released_by": null,
"released_at": null
}
],
"total": 1,
"limit": 50,
"offset": 0,
"has_more": false
}#Release a hold
/v1/retention/holds/{hold_id}/releaseSession token onlyThe hold stops applying and is kept, with who released it and when. What it covered is deleted at the schedule's next run if it is older than the period and no other hold covers it. Releasing a hold twice changes nothing.
Path parameters
Returns
active: false.403 release_not_allowed.curl -X POST https://api.kaimei.ai/v1/retention/holds/hold_5b2e9d1c7a3f4e6b8d0a/release \
-H "Authorization: Bearer $SESSION_TOKEN"{
"object": "hold",
"id": "hold_5b2e9d1c7a3f4e6b8d0a",
"scope": "decision",
"decision_id": "LOAN/2026/0042",
"model": {
"id": "mdl_390bd6d9568f626851ef",
"slug": "credit-risk-v3",
"name": "Credit risk scorer"
},
"reason": "Customer complaint under review",
"matter": "CASE-2026-0117",
"active": false,
"placed_by": {
"type": "user",
"user_id": "usr_3d9a6c1e8b7f4a2d5c0e",
"name": "Riley Counsel",
"role": "reviewer"
},
"placed_at": "2026-10-30T14:02:11.530291Z",
"released_by": {
"type": "user",
"user_id": "usr_3d9a6c1e8b7f4a2d5c0e",
"name": "Riley Counsel",
"role": "reviewer"
},
"released_at": "2026-11-20T10:15:42.007311Z"
}#The audit log
Who did what in the organization, and when. An entry is written in the same transaction as the change it describes, so the log and the change succeed or fail together, and no call edits or deletes an entry. Who and what are copied into it as they were named then, so an entry still reads after the person, the key or the model is gone.
| Group | What is entered |
|---|---|
auth | Signing in (auth.signed_in) and changing a password, in every organization the account can work in. |
api_key | A key created, changed or revoked. Never its secret. |
member, invitation, join_domain | People added and removed, roles changed, invitations sent, accepted and withdrawn, joining by email domain turned on and off. |
organization | The organization created, renamed, its plan or a setting changed. |
model, project | Registered, changed, deleted, forked to another organization, transferred in or out; a model's structure uploaded, replaced or removed. A change says which fields, with the values before and after where they are short. How a model is reached is named and never shown, since it may hold credentials. |
reason_table | A draft saved or discarded, a version approved or retired. |
decision, explanation | A logged decision explained through its record, what was decided recorded, amended or removed, and a decision or an explanation deleted. |
hold | A hold placed or released. |
retention | A period set or removed, and each time the schedule deleted records: how many, of which model, logged before when. |
Logging a prediction, computing an explanation and running an analysis are not entered: each is a record of its own, with its time. Reading is not entered either. The log begins when the organization first runs a Kaimei with an audit log; nothing done before that is in it. Entries are kept for as long as the organization exists, and no retention schedule deletes them.
#The Audit event object
One thing someone did.
Attributes
evt_…When, in UTC.
{type, id, name}. type is user, api_key, or system for something Kaimei did itself: the retention schedule, revoking the keys of someone who left.group.what_happened: model.updated, hold.placed, retention.applied.The part of action before the dot.
The entry in a sentence, without its subject.
{type, id, name}: what it was done to. For a hold or a recorded outcome on one decision, the decision.The model the entry concerns, kept after the model is deleted.
What changed. A change to a model, a key or the organization has changed (the fields), and before and after for values short enough to show. A deletion has what a reader needs to know what is gone: for a decision, when it was logged, how many explanations, the reason given and the record's fingerprint.
The X-Request-Id of the request that made the change.
{
"object": "audit_event",
"id": "evt_91c4e0b7a2d85f3c6e1b",
"at": "2026-10-30T14:02:11.530291Z",
"actor": {
"type": "user",
"id": "usr_3d9a6c1e8b7f4a2d5c0e",
"name": "Riley Counsel ([email protected])"
},
"action": "hold.placed",
"group": "hold",
"summary": "Placed a hold on “LOAN/2026/0042”: Customer complaint under review.",
"target": {
"type": "decision",
"id": "LOAN/2026/0042",
"name": "LOAN/2026/0042"
},
"model_id": "mdl_390bd6d9568f626851ef",
"detail": {
"hold": "hold_5b2e9d1c7a3f4e6b8d0a",
"reason": "Customer complaint under review",
"matter": "CASE-2026-0117"
},
"request_id": "7f0c2a9e41d84b6f9a3e5c1d2b8f6e07"
}#List audit log entries
/v1/audit-logAPI key or sessionEntries, newest first. format=csv returns up to 10,000 matching entries as a spreadsheet, with text that looks like a formula quoted so that opening the file runs nothing.
Query parameters
One action, such as model.updated, or a group, such as model.
Part of a name or an address, whatever its case, or a user's or key's id.
model, decision, api_key, member, reason_table, retention, …With target_type: what was done to one thing, such as one decision.
Model id or slug: entries that concern it.
Entries at or after this moment.
Entries before this moment.
json or csv.1 to 200.
Returns
403 audit_log_not_allowed.# what happened to one decision
for entry in client.audit_log.iterate(target_type="decision", target_id="LOAN/2026/0042"):
print(entry.at, entry.actor.name, entry.summary)
# every change to a model this month, as a table and as a file
changes = client.audit_log.list(action="model", model="credit-risk-v3", since="2026-10-01")
changes.to_frame()
client.audit_log.save_csv("audit-log-october.csv", since="2026-10-01", until="2026-11-01")curl "https://api.kaimei.ai/v1/audit-log?action=model&model=credit-risk-v3" \
-H "Authorization: Bearer $KAIMEI_API_KEY"
# as a spreadsheet
curl "https://api.kaimei.ai/v1/audit-log?format=csv&since=2026-10-01T00:00:00Z" \
-H "Authorization: Bearer $KAIMEI_API_KEY" \
-o audit-log.csv{
"object": "list",
"data": [
{
"object": "audit_event",
"id": "evt_2e7b9f4c1a6d8e0b3c5f",
"at": "2026-10-29T09:47:55.201774Z",
"actor": {
"type": "api_key",
"id": "key_6f0e1d2c3b4a59687a8b",
"name": "API key Release pipeline (km_live_9b2e…)"
},
"action": "model.updated",
"group": "model",
"summary": "Changed the outputs of the model “Credit risk scorer”.",
"target": {
"type": "model",
"id": "mdl_390bd6d9568f626851ef",
"name": "Credit risk scorer"
},
"model_id": "mdl_390bd6d9568f626851ef",
"detail": {
"changed": ["outputs"],
"before": {
"outputs": {
"labels": ["approve", "decline"],
"positive_label": "decline",
"threshold": 0.55
}
},
"after": {
"outputs": {
"labels": ["approve", "decline"],
"positive_label": "decline",
"threshold": 0.5
}
}
},
"request_id": "c41d7e0a9b3f4d268e5a1c7f0b6d2e93"
},
{
"object": "audit_event",
"id": "evt_91c4e0b7a2d85f3c6e1b",
"at": "2026-10-30T14:02:11.530291Z",
"actor": {
"type": "user",
"id": "usr_3d9a6c1e8b7f4a2d5c0e",
"name": "Riley Counsel ([email protected])"
},
"action": "hold.placed",
"group": "hold",
"summary": "Placed a hold on “LOAN/2026/0042”: Customer complaint under review.",
"target": {
"type": "decision",
"id": "LOAN/2026/0042",
"name": "LOAN/2026/0042"
},
"model_id": "mdl_390bd6d9568f626851ef",
"detail": {
"hold": "hold_5b2e9d1c7a3f4e6b8d0a",
"reason": "Customer complaint under review",
"matter": "CASE-2026-0117"
},
"request_id": "7f0c2a9e41d84b6f9a3e5c1d2b8f6e07"
},
…
],
"total": 34,
"limit": 50,
"offset": 0,
"has_more": true
}