---
name: metabase_list_document_comments
kind: function
lang: py
domain: infra
version: "1.0.0"
purity: impure
signature: "def metabase_list_document_comments(client: MetabaseClient, document_id: int, *, include_resolved: bool = True, include_deleted: bool = False) -> list[dict]"
description: "Lista los comentarios de un document (threads, anclajes por bloque UUID, reacciones). Endpoint no documentado: GET /api/comment?target_type=document&target_id=:id."
tags: [metabase, document, comments, api, python]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: [httpx]
params:
  - name: client
    desc: "instancia autenticada de MetabaseClient"
  - name: document_id
    desc: "ID del document del que listar comentarios"
  - name: include_resolved
    desc: "si False, filtra comentarios con is_resolved=True"
  - name: include_deleted
    desc: "si False, filtra comentarios soft-deleted (deleted_at != null)"
output: "list[dict]: cada dict con id, content (arbol ProseMirror), creator, creator_id, target_type, target_id, child_target_id (UUID de bloque anclado o null), parent_comment_id (para threads), is_resolved, deleted_at, reactions, created_at, updated_at"
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/metabase/documents.py"
---

## Ejemplo

```python
comments = metabase_list_document_comments(client, 29, include_resolved=False)
for c in comments:
    author = c["creator"]["common_name"]
    # content es ProseMirror — aplanar si quieres texto plano
    text = "".join(n["text"] for n in _walk(c["content"]) if n.get("type") == "text")
    anchor = c["child_target_id"] or "doc"
    print(f'{author} @ {anchor}: {text}')
```

## Notas

**Endpoint no documentado** en la API publica de Metabase — descubierto inspeccionando trafico. target_type solo acepta el enum `"document"` en v0.59.

**Anclaje por bloque**: cuando un usuario comenta sobre un parrafo concreto en la UI, Metabase inyecta un `attrs._id` UUID en ese parrafo y guarda ese UUID en `child_target_id`. Si editas el parrafo vía YAML sin preservar el `_id`, el comentario queda huerfano.

**Threads**: los comentarios que responden a otros tienen `parent_comment_id` apuntando al padre.
