# cms-edit create taxonomy-from-json — Batch Taxonomy Bootstrap

`create taxonomy-from-json` creates multiple `tagType`, `articleType`, and `tag` entries from a single JSON file. It is the recommended way to bootstrap taxonomy for import scripts and publication workflows.

```bash
cms-edit create taxonomy-from-json --json '{...}' --dry-run
cms-edit create taxonomy-from-json --json '{...}' --if-not-exists
```

Processing order: **tagTypes → articleTypes → tags** (tags depend on tagTypes).

All entries are created as **drafts**. Nothing is published automatically.

**Not transactional:** If the command fails partway through (e.g. a tag fails validation), entries created earlier in the same run remain in the space. Re-run with `--if-not-exists` to continue idempotently, or fix the JSON and run again.

**Not parallel-safe:** `--if-not-exists` is check-then-create. Running two imports concurrently for the same slug can create duplicates. Process items sequentially per slug, or re-run to converge.

---

## JSON schema

```jsonc
{
  "tagTypes": [
    {
      "slug": "presentation-type",
      "name": "Presentation Type",
      "fields": { "show": true }
    }
  ],
  "articleTypes": [
    {
      "slug": "resources/publications",
      "name": "Publications",
      "cmsLabel": "Publications",
      "fields": { "indexed": true, "hidden": false }
    }
  ],
  "tags": [
    {
      "slug": "asco-2025",
      "name": "ASCO 2025",
      "tagTypeSlug": "conference-venue",
      "fields": { "description": "ASCO Annual Meeting 2025" }
    }
  ]
}
```

Each item supports the same field shorthands as single-entry creates. See `cms-edit help fields-taxonomy` for the full field reference and link shorthand table.

| Key | Required on item | Description |
|---|---|---|
| `slug` | Yes | URL slug |
| `name` | Yes | Display name |
| `cmsLabel` | No | CMS label (articleType/tag) |
| `fields` | No | Raw Contentful field values |
| `tagTypeSlug` / `tagTypeId` | Tags only | Parent tagType link |

Top-level link shorthands (`templateId`, `featuredImageId`, `topContentIds`, etc.) can also appear on each item.

---

## Options

| Option | Description |
|---|---|
| `--json <json> or --json-base64 <encoded>` | Path to taxonomy JSON (required) |
| `--if-not-exists` | Skip creation when slug already exists; return existing ID |
| `--dry-run` | Validate all entries and link targets without writing |

---

## Output

Human mode prints a summary per entry. JSON mode (`CMS_EDIT_JSON=1` or `--json-output`):

```json
{
  "ok": true,
  "tagTypes": [{ "id": "...", "slug": "...", "contentType": "tagType", "status": "created" }],
  "articleTypes": [{ "id": "...", "slug": "...", "contentType": "articleType", "status": "existing" }],
  "tags": [{ "id": "...", "slug": "...", "contentType": "tag", "status": "created" }]
}
```

---

## Idempotent import pattern

Combine batch bootstrap with `create … --if-not-exists` and `resolve` for script-friendly imports:

```bash
# One-time taxonomy bootstrap
cms-edit create taxonomy-from-json --json '{...}' --if-not-exists

# Look up IDs in scripts
cms-edit resolve --tag-type-slug presentation-type --json
cms-edit resolve --tag-slug asco-2025 --json

# Add a single entry idempotently
cms-edit create tag --slug new-tag --name "New Tag" --tag-type presentation-type --if-not-exists
```

---

## Related commands

| Command | Purpose |
|---|---|
| `cms-edit create tag-type` | Create one tagType |
| `cms-edit create article-type` | Create one articleType |
| `cms-edit create tag` | Create one tag |
| `cms-edit create … --if-not-exists` | Idempotent single-entry create |
| `cms-edit help fields-taxonomy` | Full field reference |
