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:
export KORELY_API_KEY=kor_live_...For Node.js 18 or later, see the Node.js tab under Example.
Checked with korely-memory 0.1.28 (Python) and 0.1.17 (Node.js).
The code writes one memory for test-user-1, then erases that end user.
from korely_memory import Korelykorely = Korely()korely.add("I prefer email over phone calls.", user_id="test-user-1")result = korely.delete_all(user_id="test-user-1")print(result.memories_deleted, result.facts_deleted, result.audit_id)You see a line like:
1 0 aud_5f0c2d9e8b7a4c1d9e3f6a2b1c0d4e8f
The numbers are the memories and the facts erased (0 facts if
none were extracted yet), then the audit_id. Save it.
Check the counts every time. A memory count of 1
shows the erasure worked. 0 0 means the id matched nothing: you still
get 200 and a new audit_id, so a typo looks
like success. Match the
user_id exactly, case and spaces included.
Stop writing for that id first. A write after the call creates the end user again.
To check, list the user's memories
(the key also needs memories:read). A wrong id also gives
0, so trust the counts above:
print(korely.get_all(user_id="test-user-1").total) # 0Reference
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_5f0c2d9e8b7a4c1d9e3f6a2b1c0d4e8fWithout --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:
- closed facts;
- memories forgotten earlier with Delete a memory, which stay stored until this call.
Errors
On every error below, nothing was erased. Branch on code; message is for a person.
| Status | Code | When 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 doeskorely delete-all. - Timeouts. Repeat the call. If the first one succeeded, you get zeros and a new
audit_id, and the firstaudit_idcannot be read back. - Keep your receipt. Store the
audit_idand the call time. The audit log (GET /v1/audit?user_id=with the same id and amemories:readkey) has one row for this call, with actionerase, the counts and the pseudonym, but noaudit_id. Deleting one memory or forgetting one fact also writes aneraserow; yours is the one whosemetafield hasendpointset tousers:delete.
Related
- Get facts: the facts that will be erased.
- List users: it can miss some users, 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.