# last_owner_required: Declared 409, raised in the database
URL: https://emailforagents.ai/docs/errors/last_owner_required
Summary: The membership change would remove or revoke the only remaining active owner of the workspace, leaving nobody able to administer it. What triggers it in the implementation, and how to resolve it.

## last_owner_required

Declared 409 Don’t retry Database only

The membership change would remove or revoke the only remaining active owner of the workspace, leaving nobody able to administer it.

### How to fix it

1. Add another active owner first, then revoke the original. The trigger only needs one other active owner with a different identity to exist at the moment of the write. Members can’t be changed through the API or the console today, so this is an operator change: ask support for it.
2. To wind a workspace down entirely, use the deletion job rather than removing the owner. Deletion is a lifecycle state on the workspace, not a membership change.
3. Do not retry. The condition is structural and identical on every attempt.

### Which rule fired

This is enforced by a BEFORE UPDATE OR DELETE trigger on workspace_memberships, not by application code. When a row with role owner and status active is deleted, or moved from active to revoked, the trigger looks for another active owner in the same workspace with a different identity. If there is none, it raises last_owner_required with SQLSTATE restrict_violation and the statement aborts. Because the rule lives in the database, it holds for every path that writes that table, including one that forgot to check. No API route returns it.

| In the Postgres error | Means |
| --- | --- |
| `last_owner_required` | Deleting, or revoking, the last workspace_memberships row with role owner and status active. |

**Why it works this way:** Placing this in a trigger rather than in a service method is the decision worth noting. An ownerless workspace is unrecoverable without operator intervention, so the guarantee is put where no code path can route around it, including a future one.

### Example

UPDATE workspace_memberships SET status = 'revoked' → restrict_violation

```
ERROR:  last_owner_required
SQLSTATE: 23001 (restrict_violation)
```

### Often confused with

[permission_denied](https://emailforagents.ai/docs/errors/permission_denied)
