---
name: metabase_create_card
kind: function
lang: py
domain: infra
version: "1.0.0"
purity: impure
signature: "def metabase_create_card(client: MetabaseClient, name: str, dataset_query: dict, display: str = 'table', collection_id: int = 0, description: str = '') -> dict"
description: "Crea una card/pregunta en Metabase con query SQL nativa o MBQL. Endpoint: POST /api/card."
tags: [metabase, card, question, create, 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: name
    desc: "nombre descriptivo de la pregunta/card"
  - name: dataset_query
    desc: "dict con configuración de query (SQL nativa o MBQL)"
  - name: display
    desc: "tipo de visualización (table, scalar, bar, etc.)"
  - name: collection_id
    desc: "ID de colección donde guardar la card (0=root)"
  - name: description
    desc: "descripción opcional de la card"
output: "dict: objeto card creado con id y toda su configuración"
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/metabase/cards.py"
---

## Ejemplo

```python
card = metabase_create_card(client, "Revenue", {
    "database": 1, "type": "native",
    "native": {"query": "SELECT SUM(total) FROM orders"},
}, display="scalar")
```

## Notas

dataset_query SQL nativo: `{"database": id, "type": "native", "native": {"query": "..."}}`
dataset_query MBQL: `{"database": id, "type": "query", "query": {"source-table": id, ...}}`
