# Add custom schemas to Snowplow Micro
> Connect Snowplow Micro to Iglu registries or add schemas directly. Point Micro to Console registries, Iglu Server, or mount local schema files for custom event validation.
> Source: https://docs.snowplow.io/docs/testing/snowplow-micro/local/schemas/
> Documentation index: https://docs.snowplow.io/llms.txt

One of the benefits of using Snowplow is that you can design your own schemas for your events.

> **Tip:** See [our explanation](/docs/fundamentals/schemas/) on what schemas are for and what they look like.

To track an event with a custom schema, you would need code like this (using the [Browser tracker](/docs/sources/web-trackers/custom-tracking-using-schemas/) as an example):

```js
import { trackSelfDescribingEvent } from '@snowplow/browser-tracker';

trackSelfDescribingEvent({
  event: {
    schema: 'iglu:com.example/my-schema/jsonschema/1-0-0',
    data: {
        ...
    }
  }
});
```

For Micro to understand this event, it will need to know about `com.example/my-schema/jsonschema/1-0-0` or any other relevant schemas. There are two ways you can achieve this:

- **Point Micro to an Iglu registry that contains your schemas.** This is a good option if you use Snowplow [Console](/docs/event-studio/data-structures/) UI or [API](/docs/event-studio/programmatic-management/data-structures-api/) to create schemas, or if you have deployed your own Iglu registry.
- **Add schemas to Micro directly.** This can be handy for quickly testing a schema.

Whichever approach you choose, you can use the [the API](/docs/api-reference/snowplow-micro/api/#microiglu) to check if Micro is able to reach your schemas (replace `com.example` and `my-schema` as appropriate).

```bash
curl localhost:9090/micro/iglu/com.example/my-schema/jsonschema/1-0-0
```

> **Tip: Micro in Console**
>
> If you are [running Micro through Console](/docs/testing/snowplow-micro/console/), it automatically integrates with your development Iglu Server, so you don’t need to follow these steps.

## Pointing Micro to an Iglu registry

Place your Iglu registry URL and API key (if any) into two [environment variables](https://en.wikipedia.org/wiki/Environment_variable): `MICRO_IGLU_REGISTRY_URL` and `MICRO_IGLU_API_KEY`.

Make sure to fully spell out the URL, including the protocol (`http://` or `https://`). For most Iglu registries, including those provided by Snowplow CDI, the URL will end with `/api` — make sure to include that part too, for example: `https://com-example.iglu.snplow.net/api`. [Static registries](/docs/api-reference/iglu/iglu-repositories/static-repo/), such as `https://iglucentral.com`, are an exception — you don’t need to append `/api` to the URL.

> **Tip:** If you use Snowplow CDI, you can find your Iglu resolver URLs and create Iglu Server keys in Console under **Settings** > **Manage organization** > **View and manage API keys**.

The following Docker command will pick up the environment variables and pass them to Micro:

```bash
 export MICRO_IGLU_REGISTRY_URL=https://com-example.iglu.snplow.net/api
export MICRO_IGLU_API_KEY=abcdef123456


docker run -p 9090:9090 \
-e MICRO_IGLU_REGISTRY_URL \
-e MICRO_IGLU_API_KEY \
snowplow/snowplow-micro:4.7.0
```

This will ensure Micro uses your Iglu registry, in addition to [Iglu Central](/docs/api-reference/iglu/iglu-repositories/#iglu-central).

For more flexibility, see [Advanced usage](/docs/testing/snowplow-micro/local/advanced-usage/#adding-custom-iglu-resolver-configuration).

## Adding schemas directly to Micro

> **Note: Limitations**
>
> This method doesn't work for [marking schemas as superseded](/docs/event-studio/data-structures/superseding-and-patching/#mark-a-schema-as-superseded).

Structure your schema file or files like so:

```text
schemas
└── com.example
    └── my-schema
        └── jsonschema
            ├── 1-0-0
            └── 1-0-1
```

> **Note:** This folder structure is significant. Also note that the schema files must be named `1-0-0`, `1-0-1`, and so on, **not** `1-0-0.json` or `1-0-1.json`.

Next, you will need to place the schemas in `/config/iglu-client-embedded/` inside the container.

```bash
docker run -p 9090:9090 \
--mount type=bind,source=$(pwd)/schemas,destination=/config/iglu-client-embedded/schemas \
snowplow/snowplow-micro:4.7.0
```

> **Tip:** You can read more about bind mounts in the [Docker documentation](https://docs.docker.com/storage/bind-mounts/).

Alternatively, if you are running Micro as a Java application, place your schemas — using the same structure as above — in `some-directory/iglu-client-embedded` on your machine (`iglu-client-embedded` must be called exactly that) and use the following command:

```bash
java -cp micro-4.7.0.jar:some-directory com.snowplowanalytics.snowplow.micro.Main
```
