---
name: metabase_setup
kind: function
lang: py
domain: infra
version: "1.0.0"
purity: impure
signature: "metabase_setup(base_url: str, admin_email: str, admin_password: str, admin_first_name: str, admin_last_name: str, site_name: str, site_locale: str) -> dict"
description: "Ejecuta el setup inicial de una instancia Metabase nueva via POST /api/setup. Obtiene el setup-token automaticamente y crea el usuario admin con preferencias del sitio."
tags: [metabase, setup, api, infra, pendiente-usar]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: [httpx]
params:
  - name: base_url
    desc: "URL base de Metabase a configurar"
  - name: admin_email
    desc: "correo del usuario administrador a crear"
  - name: admin_password
    desc: "contraseña del administrador"
  - name: admin_first_name
    desc: "nombre del administrador"
  - name: admin_last_name
    desc: "apellido del administrador"
  - name: site_name
    desc: "nombre del sitio Metabase"
  - name: site_locale
    desc: "código de idioma (ej: es, en, fr)"
output: "dict: resultado del setup con session token de administrador"
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/metabase/setup.py"
---

## Ejemplo

```python
from metabase.setup import metabase_setup

result = metabase_setup(
    base_url="http://localhost:3000",
    admin_email="admin@fnregistry.local",
    admin_password="FnRegistry2024!",
    admin_first_name="Lucas",
    admin_last_name="Admin",
    site_name="fn-registry",
    site_locale="es",
)
print(result["id"])  # session token
```

## Notas

Solo funciona en instancias sin configurar (setup-token disponible). Si Metabase ya tiene un usuario, lanza RuntimeError.

El setup-token se obtiene automaticamente de GET /api/session/properties. Una vez usado, Metabase invalida el token.
