Retention, holds and the audit log

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

GET/v1/retentionAPI key or session

The 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"
200 OKResponse
{
  "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

PUT/v1/retentionSession token only

Delete 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

keep_daysinteger | nullrequired

Days a record is kept after it is logged, 30 to 36,500. null removes the period.

Returns

The retention schedule.
An owner or admin sets the schedule, signed in. An API key cannot.
curl -X PUT https://api.kaimei.ai/v1/retention \
  -H "Authorization: Bearer $SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"keep_days": 760}'
200 OKResponse
{
  "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

PUT/v1/retention/models/{model}Session token only
keep_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

modelstringrequired

Model id or slug.

Body parameters

keep_daysinteger | nullrequired

30 to 36,500, or null to keep this model's records until deleted.

Returns

The retention schedule.
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}'
200 OKResponse
{
  "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

DELETE/v1/retention/models/{model}Session token only

Remove the model's own period. It follows the organization's again.

Path parameters

modelstringrequired

Model id or slug.

Returns

The retention schedule.
curl -X DELETE https://api.kaimei.ai/v1/retention/models/fraud-encoder-v1 \
  -H "Authorization: Bearer $SESSION_TOKEN"
200 OKResponse
{
  "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

POST/v1/retention/runSession token only

Delete 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

dry_runbooleanoptionaldefault false

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"
200 OKResponse
{
  "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

idstring
hold_…
scopestring
decision, or model for every record the model has logged, now and later.
decision_idstring | null

The decision held, for a hold on one.

modelobject
{id, slug, name}: the model whose records are held, or the held decision's model.
reasonstring

Why the records are kept.

matterstring | null

Your own reference: a matter or case number.

activeboolean

Whether the hold is in force.

placed_by / placed_at
{type, user_id, name, role} of who placed it, as they were then, and when.
released_by / released_at

The same for its release; null while it is in force.

The Hold object
{
  "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

POST/v1/retention/holdsAPI key or session

Keep 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

decisionstringoptional

A decision id. Either this or model.

modelstringoptional

A model id or slug, to hold every record it has.

reasonstringrequired

Why, 3 to 1,000 characters.

matterstringoptional

Your own reference, up to 120 characters.

Returns

The Hold. 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'}'
201 CreatedResponse
{
  "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

GET/v1/retention/holdsAPI key or session

Holds in the organization, those in force first, then released ones, newest first.

Query parameters

activebooleanoptional
true for holds in force, false for released ones.
modelstringoptional

Model id or slug.

decisionstringoptional

A decision id: the holds placed on that decision.

limitintegeroptionaldefault 50

1 to 200.

offsetintegeroptionaldefault 0

Returns

A page of Holds.
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"
200 OKResponse
{
  "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

POST/v1/retention/holds/{hold_id}/releaseSession token only

The 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

hold_idstringrequired

Returns

The Hold, with active: false.
A reviewer, admin or owner releases a hold, signed in. A member's session, or an API key, gets 403 release_not_allowed.
curl -X POST https://api.kaimei.ai/v1/retention/holds/hold_5b2e9d1c7a3f4e6b8d0a/release \
  -H "Authorization: Bearer $SESSION_TOKEN"
200 OKResponse
{
  "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.

GroupWhat is entered
authSigning in (auth.signed_in) and changing a password, in every organization the account can work in.
api_keyA key created, changed or revoked. Never its secret.
member, invitation, join_domainPeople added and removed, roles changed, invitations sent, accepted and withdrawn, joining by email domain turned on and off.
organizationThe organization created, renamed, its plan or a setting changed.
model, projectRegistered, 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_tableA draft saved or discarded, a version approved or retired.
decision, explanationA logged decision explained through its record, what was decided recorded, amended or removed, and a decision or an explanation deleted.
holdA hold placed or released.
retentionA 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

idstring
evt_…
attimestamp

When, in UTC.

actorobject
{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.
actionstring
group.what_happened: model.updated, hold.placed, retention.applied.
groupstring

The part of action before the dot.

summarystring

The entry in a sentence, without its subject.

targetobject
{type, id, name}: what it was done to. For a hold or a recorded outcome on one decision, the decision.
model_idstring | null

The model the entry concerns, kept after the model is deleted.

detailobject

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.

request_idstring | null

The X-Request-Id of the request that made the change.

The Audit event object
{
  "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

GET/v1/audit-logAPI key or session

Entries, 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

actionstringoptional

One action, such as model.updated, or a group, such as model.

actorstringoptional

Part of a name or an address, whatever its case, or a user's or key's id.

target_typestringoptional
model, decision, api_key, member, reason_table, retention, …
target_idstringoptional

With target_type: what was done to one thing, such as one decision.

modelstringoptional

Model id or slug: entries that concern it.

sincetimestampoptional

Entries at or after this moment.

untiltimestampoptional

Entries before this moment.

formatstringoptionaldefault "json"
json or csv.
limitintegeroptionaldefault 50

1 to 200.

offsetintegeroptionaldefault 0

Returns

A page of Audit events, or the CSV.
Owners, admins and reviewers read the log. An API key reads it when the person who created it may. Anyone else gets 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
200 OKResponse
{
  "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
}