Skip to content

Delete an account on request

For: an operator who must delete an account on a request of the person, when the person cannot use the self delete.

What it does: this runbook deletes the account with an audit row. It lists what goes, what stays, and what your app removes.

Do the steps in this order. Each step names what happens when you skip it.

  1. Check the request against your own records first.
    • A delete cannot be undone. Core keeps no copy of the account.
  2. Run authtempo users search <base url> --email <address>. Copy the user id from the ID column.
    • The delete takes a user id, not an address.
  3. Run authtempo users get <base url> <user id>. Make sure that it is the account of the request.
    • The delete question shows the user id only. A wrong id deletes the wrong person.
  4. Use the secret that holds the delete scope.
    • A secret with users only gets 403 operator_required, and the account stays.
  5. Run authtempo users delete <base url> <user id> --reason "<case id>". Type the user id at the question.
    • The reason stays in the audit row after the account is gone. Put the case id of your own system there.
    • The command prints deleted <user id>; audit row <id>, then one line for each organization that went.
  6. On 409 sole_owner, make another member an owner of each organization of the user. Then run the delete again.
    • The platform organization never goes. Its last owner cannot be deleted.
  7. On 409 delete_too_large, delete the organizations that the user alone holds first. Then run the delete again.
    • On D1, the user can also leave each organization that the user owns with another owner.
  8. Run authtempo audit list <base url> --user <user id>. Find the row whose ID is the audit row id of step 5.
    • The row has the action user_delete. It holds the organization ids that went, and no address.
  9. Remove the data of the user in your own app.
    • Core deletes its own rows only. user.afterDelete runs after the commit, so your app can remove its rows there.

The delete runs one transaction with its audit row. A refusal writes nothing and leaves no audit row.

  • The user row and every row of the user go: the identities, the passkeys, the tokens, and the second factor.
  • After the commit, the mailed links of the user go too, the invitation link of an operator create among them.
  • Each organization where the user is the only member goes with the account. Its teams, invitations, tokens, roles, SCIM rows, and SSO setup links and setup sessions go at the next sweep. Until then a setup link of the organization opens nothing, and its setup sessions open no route.
  • The act ends a page of the sessions. The sweep ends the rest with the reason account_deleted.
  • The user gets the notice mail account_deleted at the old address, unless account.notices is false. The notice holds no IP of the operator. A user with no address gets no notice.
  • The audit rows of the user stay. Each holds the user id, the reason, and data, and no address. Core has no retention rule for them, so your app sets one.
  • The audit row of each organization act of the user also keeps the IP and the user agent of that act. Examples are an invitation, a role change, and a token write. This delete and the self delete (POST /user/delete) do not remove them. The owner of the organization still sees them in the organization audit.
  • To erase them, run this statement in user.afterDelete: UPDATE ta_operator_audit SET ip = NULL, user_agent = NULL WHERE actor_kind = 'user' AND actor_id = ?. That hook runs after the commit of each delete, the self delete too. An example on D1, with your database binding as db: hooks: { user: { afterDelete: async ({ user }) => { await db.prepare("UPDATE ta_operator_audit SET ip = NULL, user_agent = NULL WHERE actor_kind = 'user' AND actor_id = ?").bind(user.id).run(); } } }. The rows stay, so the owner still sees each act, with no IP and no user agent.
  • The statement clears each row where the user is the actor. For a former platform operator, that includes the rows of each operator act of the user. The rows stay, but their IP and user agent go. To keep them, do not run the statement for a user who was a platform operator.
  • The controls of the self delete do not apply: account.delete, account.deleteConfirm, and the fresh rule of the person.
  • Each actor gets 100 deletes an hour, on operator-delete:actor:<kind>:<id>. A refused call counts too. A delete cannot be undone, so the count bounds what a leaked secret destroys.
  • Each call also counts on operator-users:ip:<ip>, 600 an hour, with every command of the user tools.
  • On every store, a user who alone holds more than 50 organizations gets delete_too_large before any write.
  • On D1, one invocation sends at most 50 queries on Workers Free. Each organization that the user owns with another owner costs 2 queries, and 1 more query counts the owners of all of them. A plain membership costs none. The operator delete writes no organization audit row. The self delete (POST /user/delete) also writes one leave row in each organization that the user leaves. 1 more query writes all of them, plain memberships too.
  • On D1, a secret deletes a user with 1 solo organization and at most 4 organizations that the user owns with another owner.
  • On D1, a platform operator deletes a user with 1 solo organization and none of those, or with no solo organization and at most 2.
  • On the D1 storage of the compatibility package with the impersonation tool on, the delete reads the user’s impersonation sessions in one more query. There a secret deletes a user with no solo organization and at most 5 organizations that the user owns with another owner. With the tool off, 6 such organizations fit.
  • Postgres, MySQL, SQLite, and memory have no query limit per invocation. There only the count of solo organizations refuses.
  • not_found: no user has the id, or the user tools are off.
  • unauthorized: the secret is wrong, or its hash is not in operator.secrets.
  • operator_required: the entry lacks the scope of the command: users for users, delete for users delete, or audit for audit list.
  • rate_limited: the 600 calls of this hour from this IP, or of this secret, are spent. Or the 100 deletes of this hour of the secret are spent.
  • invalid_body: the reason breaks its rule.
  • sole_owner: the user is the last owner of an organization with other members, or of the platform organization.
  • delete_too_large: the user alone holds more than 50 organizations, or on D1 the delete cannot fit 50 queries.
  • conflict: another change of the user ran at the same time. Run the command again.
  • hook_refused: a before hook of your app refused the delete.
  • hook_failed: a before hook of your app threw another error.