---
name: metabase_delete_membership
kind: function
lang: py
domain: infra
version: "1.0.0"
purity: impure
signature: "def metabase_delete_membership(client: MetabaseClient, membership_id: int) -> None"
description: "Elimina una membresía de grupo en Metabase por su membership_id. Endpoint: DELETE /api/permissions/membership/:id. NO acepta user_id+group_id — requiere el membership_id exacto."
tags: [metabase, permissions, membership, groups, users, delete, api, python]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
params:
  - name: client
    desc: "instancia autenticada de MetabaseClient con permisos de superusuario"
  - name: membership_id
    desc: "ID numérico de la membresía a eliminar. Obtenerse vía metabase_list_memberships — no es el user_id ni el group_id"
output: "None: sin valor de retorno. Lanza HTTPStatusError 404 si la membresía no existe"
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/metabase/permissions.py"
---

## Ejemplo

```python
# Primero obtener el membership_id via list_memberships
all_memberships = metabase_list_memberships(client)
group_members = all_memberships.get("3", [])
membership_id = next(m["membership_id"] for m in group_members if m["user_id"] == 5)
metabase_delete_membership(client, membership_id)
```

## Notas

La API de Metabase no expone DELETE por user_id+group_id. El `membership_id` es distinto de ambos y debe obtenerse vía `metabase_list_memberships`. Esta función no bloquea el borrado de membresías en grupos del sistema (All Users, Administrators) — es responsabilidad del caller verificarlo.
