Saltar al contenido principal

Metabase Dashboard API - Quick Reference

Quick copy-paste cURL commands for all endpoints.

Setup

export API_URL="http://localhost:4000"
export TOKEN="YOUR_FIREBASE_ID_TOKEN"
export BUSINESS_ID="your-business-uuid"
export DASHBOARD_ID="your-dashboard-uuid"

Embed URL Endpoints

curl -X GET "${API_URL}/reports/dashboard/sales-dashboard/embed-url?businessId=${BUSINESS_ID}" \
-H "Authorization: Bearer ${TOKEN}"

Get Embed URL by Numeric ID

curl -X GET "${API_URL}/reports/dashboard/3/embed-url?businessId=${BUSINESS_ID}" \
-H "Authorization: Bearer ${TOKEN}"

CRUD Endpoints

Create Dashboard

curl -X POST "${API_URL}/reports/dashboard" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"code": "inventory-dashboard",
"name": "Inventory Dashboard",
"description": "Dashboard showing inventory metrics",
"icon": "inventory_2",
"isActive": true,
"createdBy": "user-uuid"
}'

List All Dashboards

# Basic
curl -X GET "${API_URL}/reports/dashboard?page=1&size=10" \
-H "Authorization: Bearer ${TOKEN}"

# With search
curl -X GET "${API_URL}/reports/dashboard?search=sales&page=1&size=10" \
-H "Authorization: Bearer ${TOKEN}"

# With business filter
curl -X GET "${API_URL}/reports/dashboard?businessId=${BUSINESS_ID}&page=1&size=10" \
-H "Authorization: Bearer ${TOKEN}"

# With sorting
curl -X GET "${API_URL}/reports/dashboard?orderBy=name&order=asc&page=1&size=10" \
-H "Authorization: Bearer ${TOKEN}"

# With role filter (explicit)
curl -X GET "${API_URL}/reports/dashboard?role=admin&page=1&size=10" \
-H "Authorization: Bearer ${TOKEN}"

# With role and business filter
curl -X GET "${API_URL}/reports/dashboard?role=admin&businessId=${BUSINESS_ID}&page=1&size=10" \
-H "Authorization: Bearer ${TOKEN}"

Get Dashboard by Code

curl -X GET "${API_URL}/reports/dashboard/code/sales-dashboard" \
-H "Authorization: Bearer ${TOKEN}"

Get Dashboard by UUID

curl -X GET "${API_URL}/reports/dashboard/${DASHBOARD_ID}" \
-H "Authorization: Bearer ${TOKEN}"

Update Dashboard

curl -X PATCH "${API_URL}/reports/dashboard/${DASHBOARD_ID}" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "Updated Name",
"description": "Updated description",
"updatedBy": "user-uuid"
}'

Delete Dashboard

curl -X DELETE "${API_URL}/reports/dashboard/${DASHBOARD_ID}" \
-H "Authorization: Bearer ${TOKEN}"

Query Parameters Reference

Pagination

  • page - Page number (default: 1)
  • size - Items per page (default: 10, 0 = all)

Filtering

  • businessId - Filter by business UUID
  • search - Search in name, code, description
  • role - Filter by user role (e.g., admin, owner, accountant). If not provided, uses authenticated user's role automatically. If no role available, returns all active dashboards.

Sorting

  • orderBy - Field to sort by: name, code, createdAt
  • order - Sort direction: asc or desc

Dashboard Instance Management

Get All Instances

curl -X GET "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instances" \
-H "Authorization: Bearer ${TOKEN}"

Get Single Instance

# Staging
curl -X GET "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instance/staging" \
-H "Authorization: Bearer ${TOKEN}"

# Production
curl -X GET "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instance/production" \
-H "Authorization: Bearer ${TOKEN}"

Create Instance

# Staging
curl -X POST "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instance/staging" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"dashboardId": "uuid",
"environment": "staging",
"metabaseDashboardId": 3,
"isActive": true,
"updatedBy": "user-uuid"
}'

# Production
curl -X POST "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instance/production" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"dashboardId": "uuid",
"environment": "production",
"metabaseDashboardId": 5,
"isActive": true,
"updatedBy": "user-uuid"
}'

Update Instance

# Staging
curl -X PATCH "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instance/staging" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"metabaseDashboardId": 7,
"isActive": true,
"updatedBy": "user-uuid"
}'

# Production
curl -X PATCH "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instance/production" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"metabaseDashboardId": 10,
"isActive": true,
"updatedBy": "user-uuid"
}'

Delete Instance

# Staging
curl -X DELETE "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instance/staging" \
-H "Authorization: Bearer ${TOKEN}"

# Production
curl -X DELETE "${API_URL}/reports/dashboard/${DASHBOARD_ID}/instance/production" \
-H "Authorization: Bearer ${TOKEN}"