# Configure Snowtype sources and output options
> Configure Snowtype code generation with options for output paths, tracker selection, language settings, and custom templates.
> Source: https://docs.snowplow.io/docs/event-studio/implement-tracking/snowtype-config/
> Documentation index: https://docs.snowplow.io/llms.txt

Snowtype reads from the configuration file you created with `snowtype init` to determine which schemas to generate code for, and what language the code should be generated in. You can combine multiple source types in a single configuration.

> **Info: Terminology**
>
> We originally called tracking plans "data products". You'll still find the old term used in some existing APIs and CLI commands.

## Configuration file structure

The configuration file is a JSON object with the following structure:

```json
{
    "organizationId": "a654321b-c111-33d3-e321-1f123456789g",
    "tracker": "@snowplow/browser-tracker",
    "language": "typescript",
    "outpath": "./src/snowtype",
    "dataProductIds": [
      "a123456b-c222-11d1-e123-1f12345678dp"
    ],
    "eventSpecificationIds": [
      "a123456b-c222-11d1-e123-1f123456789g"
    ],
    "dataStructures": ["iglu:com.myorg/custom_web_page/jsonschema/1-1-0"],
    "igluCentralSchemas": ["iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0"],
    "repositories": ["../data-structures"]
}
```

The `organizationId`, `tracker`, `language`, and `outpath` options will be pre-filled based on your answers to the `snowtype init` prompts.

Check out the [configuration reference](/docs/event-studio/implement-tracking/configuration-reference/) page for more details on the available options, including the supported trackers.

## Add sources

Add sources to your configuration manually by editing the file, or with `snowtype patch`. The [command](/docs/event-studio/implement-tracking/command-reference/) will prompt you for the source type and ID, then update your configuration file:

```bash
npx snowtype patch
```

You can also pass in the source details directly:

```bash
# Add event specifications
npx snowtype patch --eventSpecificationIds <id1> <id2>

# Add data products
npx snowtype patch --dataProductIds <id1> <id2>

# Add data structures
npx snowtype patch --dataStructures iglu:com.example/my_entity/jsonschema/1-0-0

# Add Iglu Central schemas
npx snowtype patch --igluCentralSchemas iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0

# Add local schema repositories
npx snowtype patch --repositories ./local-schemas
```

You can disable automatic regeneration in your [configuration file](/docs/event-studio/implement-tracking/snowtype-config/) by setting `regenerateOnPatch` to `false`.

### Tracking plans

A [tracking plan](/docs/event-studio/tracking-plans/) groups related event specifications together. Adding a tracking plan to your configuration generates code for all of its event specifications at once.

To find the tracking plan ID, click **Implement tracking** on the tracking plan page in Console to get the command directly:

![Tracking plan page in Snowplow Console showing the Implement tracking button, which opens a modal with the npx snowtype generate command pre-filled with the tracking plan\&#39;s dataProductIds argument](/assets/images/dp-track-544c276d1535553cf5f930f697af85ad.png)

You can also copy the ID from the URL bar and add it to the `dataProductIds` array in your configuration file. The ID is the last part of the URL after `/data-products/`:

![Browser address bar with the tracking plan UUID highlighted in a red box (52461212-9ea0-4d90-a695-e524c62f7198), with a red arrow pointing to it](/assets/images/dp-id-6c8bd5e400425daa6c524a48efdc129e.png)

```json
{
  "dataProductIds": ["dp-id-1", "dp-id-2"]
}
```

### Event specifications

You can add individual [event specifications](/docs/event-studio/tracking-plans/event-specifications/) if you don't need the full tracking plan. Find the event specification ID on its page in Console. The ID is the last part of the URL after `/event-specifications/`:

![Event specification page in Snowplow Console with the browser URL bar showing the event specification ID as the last segment of the path after /event-specifications/](/assets/images/es-id-0a3367afcd71c89c002445c58795d483.png)

Add the ID to the `eventSpecificationIds` array in your configuration file:

```json
{
  "eventSpecificationIds": ["es-id-1", "es-id-2"]
}
```

### Data structures

To generate code for a specific [data structure](/docs/fundamentals/schemas/), you need its schema tracking URI. Find it on the data structure page in Console, under the **Overview** tab:

![Data structure overview page in Console with the Schema tracking URI field highlighted in a red box, showing iglu.snowplowanalytics.console/data\_structures/jsonschema/1-0-0](/assets/images/ds-url-c93e327627928eba0a66750da09b833a.png)

Add the URI to the `dataStructures` array in your configuration file:

```json
{
  "dataStructures": [
    "iglu:com.example/my_event/jsonschema/1-0-0"
  ]
}
```

### Iglu Central schemas

[Iglu Central](http://iglucentral.com/) hosts schemas that you can use in your tracking. Find the schema tracking URI on the Iglu Central website under **General Information**:

![Iglu Central schema details for button\_click with the Schema tracking URL field highlighted in a red box, showing iglu.snowplowanalytics.snowplow/button\_click/jsonschema/1-0-0](/assets/images/iglu-url-99a7c2aae4d2cd5f818c9dfa1605804a.png)

Add the URI to the `igluCentralSchemas` array in your configuration file:

```json
{
  "igluCentralSchemas": [
    "iglu:com.snowplowanalytics.snowplow/web_page/jsonschema/1-0-0"
  ]
}
```

### Local data structure repositories

If you manage schemas locally using [Snowplow CLI](/docs/api-reference/snowplow-cli/data-structures/), you can point Snowtype at your local repository paths. Add them to the `repositories` array:

```json
{
  "repositories": ["./schemas"]
}
```

You can pass in the path to the data structures directly, or the Snowplow CLI directory root.

```json
// This is fine
"repositories": ["./my-snowplow-tracking"]

// This also works
"repositories": ["./my-snowplow-tracking/data-structures"]

// This won't do anything
"repositories": ["./my-snowplow-tracking/data-products"]
```

Provide the path relative to the location of your configuration file.

### Local tracking plans

Applies to **Snowtype 0.20.0+**[Latest: 0.21.0](/docs/api-reference/versions/#feature-availability-by-version "The latest Snowtype version is 0.21.0")

If you manage tracking plans as code with [Snowplow CLI](/docs/api-reference/snowplow-cli/tracking-plans/), Snowtype can generate code from the tracking plan files in your repository. Add their paths to the `localDataProducts` array, and add the data structures their event specifications reference to `repositories`:

```json
{
  "tracker": "@snowplow/browser-tracker",
  "language": "typescript",
  "outpath": "./src/tracking",
  "repositories": ["./data-structures"],
  "localDataProducts": ["./data-products"],
  "igluCentralSchemas": [],
  "dataStructures": [],
  "eventSpecificationIds": [],
  "dataProductIds": []
}
```

Each path can be a directory or a single file, relative to the location of your configuration file. Snowtype reads every JSON and YAML file under a directory, uses the ones that declare `resourceType: data-product`, and follows their `$ref` links to source applications. `snowtype patch` has no option for `localDataProducts`, so edit the configuration file directly.

Snowtype reads the files in the format [Snowplow CLI](/docs/api-reference/snowplow-cli/tracking-plans/) writes them, for example when you run `snowplow-cli dp download`.

For the fields Snowtype reads from each event specification, see [local tracking plan fields](/docs/event-studio/implement-tracking/configuration-reference/#local-tracking-plan-fields).

Snowtype doesn't connect to Console, and doesn't need Console credentials, when the configuration lists `localDataProducts` and no `dataStructures`, `eventSpecificationIds`, or `dataProductIds`.

Run `snowtype generate` to write the code. When Snowtype generates only from your repository, it warns that it doesn't check schemas against the environments they're deployed to, and it doesn't create a `.snowtype-lock.json` file:

```bash
npx snowtype generate
```

```text
✔: Valid configuration found
⚠ Warning: Generating from local definitions only. Schemas are not checked against the environments they are deployed to.
✔: Code generated, writing...
```

To combine local tracking plans with tracking plans from Console, also list the Console tracking plan IDs in `dataProductIds`. Snowtype then connects to Console and needs Console credentials. It generates code for the event specifications from both sources, and pins only the event specifications from Console in `.snowtype-lock.json`.

Each event specification must come from one place only. A tracking plan downloaded with Snowplow CLI keeps its Console IDs, so list it either in `localDataProducts` or in `dataProductIds`, not in both.

To confirm in CI that the committed code matches your tracking plan files, run [`snowtype check`](/docs/event-studio/implement-tracking/command-reference/#check).

## Troubleshooting

These errors stop `snowtype generate` and `snowtype check` for a configuration that lists `localDataProducts`. Each item gives the error message, then the fix:

- ``Required API key credentials not detected. Run `snowtype login` to sign in, or refer to https://docs.snowplow.io/docs/collecting-data/code-generation/using-the-cli/#authenticating-with-the-console``: the configuration connects to Console, and Snowtype found no login and no API key. [Authenticate](/docs/event-studio/implement-tracking/install-snowtype/#authenticate) with `snowtype login` or a Console API key, or change the configuration so that it generates only from [local tracking plans](/docs/event-studio/implement-tracking/snowtype-config/#local-tracking-plans) and doesn't need Console credentials.
- `An event specification in a local data product does not declare its version: Sign up. Add a version to it in the data product file, matching the version the platform holds.`: run `snowplow-cli dp validate --fix`, which adds the missing `version` to the tracking plan file.
- `A schema referenced by a local event specification is not among the repositories or the Iglu Central schemas the configuration declares: iglu:com.example/missing/jsonschema/1-0-0, referenced by "Sign up"`: add the data structure to a path in `repositories`, or add its URI to `igluCentralSchemas`.
- `The same event specification is reached more than once, from Console or from more than one local data product: Sign up`: list each tracking plan in one place only, either in `dataProductIds` or in one file under `localDataProducts`.
