Korely

Core operations

Forget a user

Erase everything Korely stores about one end user, for good.

One HTTP request erases every memory and fact of one end user in one project. It erases them from the live database; backups are under Details.

It is the technical step when an end user asks you to erase their data. The rest of your response to that request is up to you.

Terms

The Glossary defines the words used across the docs. This page adds three.

  • Pseudonym: a code like erased:3f9a... that Korely writes in its logs instead of the user id after an erasure. Korely can compute it from the id with its own secret key, so treat it as personal data.
  • Receipt (audit_id): your erasure receipt, aud_ and 32 hex characters. It comes once, in the response, and no call reads it back.
  • Audit log: the list of calls made with your keys (GET /v1/audit).

Quick start

This call deletes for good. Try it on a test end user first.

You need Python 3.9 or later. Install the Python SDK: pip install korely-memory.

You also need an API key with the write permission, memories:write: get a free one in the Quickstart. Set it as an environment variable, which Korely() reads:

Terminal window
export KORELY_API_KEY=kor_live_...

For Node.js 18 or later, see the Node.js tab under Example.

The code writes one memory for test-user-1, counts the end user's memories, erases that end user, and counts again.

from korely_memory import Korely
korely = Korely()
korely.add("I prefer email over phone calls.", user_id="test-user-1")
print(korely.get_all(user_id="test-user-1").total) # before: live memories only
result = korely.delete_all(user_id="test-user-1")
print(result.memories_deleted, result.facts_deleted, result.audit_id)
print(korely.get_all(user_id="test-user-1").total) # after: 0

You see three lines like:

1
1 0 aud_5f0c2d9e8b7a4c1d9e3f6a2b1c0d4e8f
0

The first line is the end user's memories before the erasure. The second holds the memories and the facts erased (0 facts if none were extracted yet), then the audit_id: save it. The third line is the count after.

Check the id before you erase. If the id matches nothing, the call still answers 200 with 0 0 and a new audit_id, so a typo looks like success. Match the user_id exactly, case and spaces included, and look for it in the list of end users (korely.users()): an end user appears there as soon as Korely holds anything of theirs, even when every count is 0 (Korely 1.0.23 and later; before that, an end user with nothing live was left out). A batch not imported yet is not read for that list.

A count of 0 in the first line does not prove the id is wrong. That count lists live memories only: it leaves out memories that were forgotten and end users who only have facts written with POST /v1/facts, and the erasure takes both. If the list shows the id, erase. A count of 0 after the call proves nothing on its own either.

Stop writing for that id first. A write after the call creates the end user again. The count after needs the key to have memories:read too.

Reference

Request

DELETE /v1/users/{end_user}/memories, with the header Authorization: Bearer <key> and a key with memories:write from the project that holds the end user. end_user is the exact user_id, up to 255 characters; in curl, write a space as %20 and / as %2F (the SDKs do it).

Example

Ids and outputs are samples.

from korely_memory import Korely
korely = Korely()
result = korely.delete_all(user_id="customer-4812")
print(result.memories_deleted, result.facts_deleted, result.audit_id)
# 47 12 aud_5f0c2d9e8b7a4c1d9e3f6a2b1c0d4e8f

Without --yes the CLI exits with code 2 and erases nothing.

Response

{
"user_id": "customer-4812",
"memories_deleted": 47,
"facts_deleted": 12,
"erasure": "permanent",
"audit_id": "aud_5f0c2d9e8b7a4c1d9e3f6a2b1c0d4e8f"
}

These counts also include what list calls leave out:

Errors

On every error below, nothing was erased. Branch on code; message is for a person.

StatusCodeWhen it happens
401 invalid_key The key is missing, malformed, unknown, revoked or expired.
403 forbidden The key lacks memories:write, or it is a confined key that does not cover this end user.
422 invalid_request The id is empty, longer than 255 characters, contains a NUL byte, or is an already-erased pseudonym (erased: followed by 32 lowercase hex characters).
429 rate_limit_exceeded Your account hit its rate limit for this minute, hour or day. Retry after Retry-After seconds.
503 unavailable The database is busy with another change to the same data. Retry after Retry-After seconds.

Details

Skip this section on a first try.

  • Also erased. In the same database transaction, the call erases the other names you declared for the user in this project, such as Maria Rossi for the id maria. It also erases the relation words Korely learned from their facts, such as lives in.
  • Not erased. Memories without a user_id, or under another id, stay even if they name the person. Copies outside Korely are yours: your logs and databases, and the model provider that read the text to extract facts.
  • What Korely keeps. A record of the erasure with the counts and the pseudonym, never the content. Encrypted nightly backups keep a copy for up to 35 days.
  • Projects and agents. One call per project, with that project's key; the same id in another project stays intact. The call covers every agent_id, and so does korely delete-all.
  • Timeouts. Repeat the call. If the first one succeeded, you get zeros and a new audit_id, and the first audit_id cannot be read back.
  • Keep your receipt. Store the audit_id and the call time. The audit log (GET /v1/audit?user_id= with the same id and a memories:read key) has one row for this call, with action erase, the counts and the pseudonym, but no audit_id. A memory erased with erase=true also writes an erase row; yours is the one whose meta field has endpoint set to users:delete. One row, with some fields left out:
    {"action": "erase", "user_id": "erased:3f9a...", "target_id": null,
    "meta": {"endpoint": "users:delete", "memories": 47, "facts": 12}}

Related

  • Get facts: the facts that will be erased.
  • List users: it does not list writes made without a user_id or the end users of a batch that is not imported yet, and it returns one page at a time, so build your deletion list from the ids you wrote.
  • Declare a name: give an end user another name, such as a full name for the id.
  • Delete the account: the whole account, with an unconfined admin key of it, so read the warning there first.