GitHub user dosubot[bot] added a comment to the discussion: assets import

<!-- Answer -->
To import a full set of Superset assets (database, datasources, charts, 
dashboards) via POST /api/v1/assets/import/, your ZIP bundle must have this 
structure and content:

- At the root, include a metadata.yaml file with at least:
  ```yaml
  version: 1.0.0
  type: assets
  ```
- Create top-level folders: databases/, datasets/, charts/, dashboards/. Each 
contains YAML or JSON files for each asset.
- Each asset file must include a uuid, and references to other assets (e.g., 
dataset to database, chart to dataset, dashboard to chart) must use these uuids.
- The import process requires all dependencies: if a dashboard references 
charts, those charts (and their datasets and databases) must be present in the 
bundle, or the import will fail with errors like "Database not found" or "Could 
not find a valid command to import file" 
[[source]](https://github.com/apache/superset/issues/33802) 
[[source]](https://github.com/apache/superset/issues/31443) 
[[source]](https://github.com/apache/superset/discussions/34022).

Example directory tree:
```
your_bundle.zip
├── metadata.yaml
├── databases/
│   └── my_database.yaml
├── datasets/
│   └── my_dataset.yaml
├── charts/
│   └── my_chart.yaml
└── dashboards/
    └── my_dashboard.yaml
```

Minimal example for each asset (YAML or JSON is accepted):

**databases/my_database.yaml**
```yaml
database_name: my_db
sqlalchemy_uri: postgresql://user:pass@host/db
uuid: 11111111-1111-1111-1111-111111111111
version: 1.0.0
```

**datasets/my_dataset.yaml**
```yaml
table_name: my_table
database_uuid: 11111111-1111-1111-1111-111111111111
uuid: 22222222-2222-2222-2222-222222222222
columns: []
metrics: []
version: 1.0.0
```

**charts/my_chart.yaml**
```yaml
slice_name: my_chart
viz_type: big_number
dataset_uuid: 22222222-2222-2222-2222-222222222222
uuid: 33333333-3333-3333-3333-333333333333
params: {}
version: 1.0.0
```

**dashboards/my_dashboard.yaml**
```yaml
dashboard_title: my_dashboard
uuid: 44444444-4444-4444-4444-444444444444
position:
  CHART-1:
    meta:
      chartId: 1
      uuid: 33333333-3333-3333-3333-333333333333
    type: CHART
  DASHBOARD_VERSION_KEY: v2
metadata: {}
version: 1.0.0
```

Upload the ZIP as the formData field in a multipart/form-data request, with 
overwrite as a separate string field ("true" or "false") 
[[source]](https://github.com/apache/superset/issues/33659).

Common pitfalls: missing dependencies, incorrect UUIDs, or missing/incorrect 
metadata.yaml will cause import errors. All referenced assets must be present 
in the bundle, and UUIDs must match across references 
[[source]](https://github.com/apache/superset/issues/33802) 
[[source]](https://github.com/apache/superset/discussions/34022).

For large bundles (over 100MB), use the CLI import tools instead of the API 
[[source]](https://github.com/apache/superset/discussions/34022).

Let me know if you need a more detailed example for any specific asset!


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/e6592bb0-2c0b-4538-afc6-83533ae041d5?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/e6592bb0-2c0b-4538-afc6-83533ae041d5?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/e6592bb0-2c0b-4538-afc6-83533ae041d5?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/e6592bb0-2c0b-4538-afc6-83533ae041d5?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/e6592bb0-2c0b-4538-afc6-83533ae041d5?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/e6592bb0-2c0b-4538-afc6-83533ae041d5?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/e6592bb0-2c0b-4538-afc6-83533ae041d5?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat
 with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&
 nbsp;[![Join 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/34573)

GitHub link: 
https://github.com/apache/superset/discussions/34573#discussioncomment-14015775

----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: 
notifications-unsubscr...@superset.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to