For AI agents: a Markdown version of this page is at https://docs.snowplow.io/docs/event-studio/implement-tracking/install-snowtype.md. The index of all documentation pages is at https://docs.snowplow.io/llms.txt, and the index for this section is at https://docs.snowplow.io/docs/cdi/llms.txt.
Get started with Snowtype
This page walks you through installing Snowtype and connecting it to your Snowplow account.
To use Snowtype, you'll need:
- Node.js version 18 or later
- A Snowplow CDI account
Install Snowtype
Navigate to your project directory and install Snowtype as a development dependency:
- npm
- Yarn
- pnpm
npm install --save-dev @snowplow/snowtype@latest
yarn add --dev @snowplow/snowtype@latest
pnpm add --save-dev @snowplow/snowtype@latest
This adds a local snowtype executable to your project. You can run it with npx, yarn, or pnpm:
npx snowtype --help
The examples on this page use npx. Replace with yarn or pnpm if you prefer.
Authenticate
Snowtype needs to authenticate with Console to read your event specifications and data structures. There are two ways to do it:
- Log in with your browser: for interactive use, when you run Snowtype yourself in a terminal. This is the default.
- Use an API key: for non-interactive use, such as CI, where nobody can sign in.
Log in with your browser
Applies to Snowtype 0.21.0+Latest: 0.21.0Run the login command:
npx snowtype login
The command prints a sign-in link and offers to open it in your browser. If you belong to more than one organization, it asks you to select a default one.
After that, Snowtype uses this login when no API key is set.
Snowplow CLI shares the same login, so you only need to log in with one of the two tools.
To log out, run:
npx snowtype logout
This also logs Snowplow CLI out. It doesn't affect API keys.
Use an API key
For non-interactive use, such as CI, use a Console API key. Create an API key in Console under Settings > Manage organization > View and manage API keys. Snowtype only reads data, so the key needs the View permission on tracking plans and data structures, and nothing else.
You need both the API key and the API key ID.
The recommended approach is to set them as environment variables, either in your shell or in a .env file at the root of your project:
- .env file
- Shell variable
SNOWPLOW_CONSOLE_API_KEY=your-api-key
SNOWPLOW_CONSOLE_API_KEY_ID=your-api-key-id
export SNOWPLOW_CONSOLE_API_KEY=your-api-key
export SNOWPLOW_CONSOLE_API_KEY_ID=your-api-key-id
You can also pass the credentials directly as CLI flags (--apiKey and --apiKeyId), but environment variables are easier to manage and keep credentials out of your command history.
If an API key is set, Snowtype uses it instead of the saved login.
Initialize your project
Run snowtype init to create a configuration file for your project:
npx snowtype init
The command will prompt you for:
- Your organization ID from Console
- The tracker you want to generate code for, e.g.
@snowplow/browser-tracker - The language for that tracker, if applicable, e.g.
typescript - The format (language) you want the configuration file to be in
- The output path where Snowtype should write the generated code
To find your organization ID, go to Console > Settings > Manage organization.
Snowtype saves these choices to a snowtype.config.json file in your project root. You can edit this file directly later, or pass the values as flags to skip the prompts. See the configuration reference for all available options.