---
title: "Delete User"
method: DELETE
path: "/users/{user_id}"
tags: ["users"]
---

# Delete User

`DELETE /users/{user_id}`

## Request

- Base URL: `https://app.zeno-works.ch` (the document declares no server; this is the origin it was published from)
- URL: `https://app.zeno-works.ch/users/{user_id}`
- Auth: none declared

Delete a user (admin). **Refused while they still pay for a company** (PRE-02).

The FK is `ON DELETE RESTRICT` precisely so this cannot silently unmeter their
companies — but a bare integrity error surfaces as a 500 and tells the caller
nothing. This checks first and names the remedy: transfer the payer, then delete.
The count is safe to disclose here because this route is `require_admin` and
already refuses a company-scoped key outright (ZET-176).

Also **409 for yourself** (:func:`_refuse_self_removal`) and for the last active
administrator (:func:`_guard_last_admin`).

Audited before the row goes: afterwards there is nothing left to name.

## Path parameters

- `user_id` string, required

## Headers

- `authorization` string, nullable

## Cookies

- `access_token` string, nullable

## Response `200`

Successful Response

- MsgResponse: The ``{"msg": "..."}`` envelope — the error contract and many successes.
  - `msg` string, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/zeno-works/apis/zeno-api.md) · [All operations](https://skmtc.dev/zeno-works/apis/zeno-api/llms.txt) · [OpenAPI document](https://skmtc.dev/zeno-works/apis/zeno-api/revisions/1eb93dde146c?raw)
