# Secrets and variables

It is sometimes the case that tracks needs to be configured differently depending on a particular audience or implementation. To facilitate this, you can add Runtime Parameters when starting tracks.

Runtime parameters are key/value pairs that are injected as environment variables into lifecycle scripts for containers and virtual machines. The values for runtime parameters can be hard coded values, or sensitive values fetched from our [secrets ](https://docs.instruqt.com/sandboxes/runtime/secrets)feature.&#x20;

Currently, runtime parameters can only be configured on track invites. In a future release, we will add runtime parameters to other track start mechanisms, such as the `instruqt track test` command, embeds and hot start.

{% hint style="info" %}
Runtime parameters are only injected during [lifecycle](https://docs.instruqt.com/sandboxes/lifecycle-scripts) script executions and are by default not stored in / accessible via containers or virtual machines.
{% endhint %}

{% hint style="warning" %}
Runtime parameters specified when starting a track via the API will override the values  configured on an invite if there are duplicate keys.\
\
\* If you are making use of [hot start pools](https://docs.instruqt.com/sandboxes/broken-reference) to prestart tracks runtime parameters not be available in the sandbox setup script. Tracks that need to be hot started and make use of runtime parameters should do setup in the first challenges setup script.&#x20;
{% endhint %}

## How to configure runtime parameters

{% tabs %}
{% tab title="🌐 Track Invites" %}

### Add runtime parameters to a track invite via the UI

1. Start by creating an invite or having an existing invite ready to edit, instruction on how to create an invite can be found in the track invites [guide](https://docs.instruqt.com/tracks/share/track-invite-links).
2. If you would like to make use of secrets to inject sensitive credentials into your track ensure you have a secret available by following the secrets [guide](https://docs.instruqt.com/sandboxes/runtime/secrets).
3. Once you have an invite and secret to work with navigate to the edit page of the invite you would like to configure.
4. Below the **Add content** section, click **+Runtime parameters.**\
   ↳ Instruqt shows the *Runtime Parameters **section***.
5. Click the **Add secret** or **Add variable** buttons to add a secret or variable parameters
   * For both options you can define the **Key** of the parameter, which will be the name of the environment variable in the scripts
   * For **Secrets** you can select the secret that will be used
   * For **Variables** you can enter any value
6. To add another parameter, repeat step 5 above.
7. Save your invite by clicking the **save changes** button at the bottom of the page
8. You are now able to make use of the environment variables defined on the invite in you tracks lifecycle scripts. For more information of lifecycle scripts have a look at the [guide](https://docs.instruqt.com/sandboxes/lifecycle-scripts).&#x20;
   {% endtab %}

{% tab title="💻 Instruqt CLI" %}
You can specify runtime parameters and secrets as part of the `instruqt track test` command. To specify runtime variables use the `--runtime-parameters` flag where the value is a comma delimited list of key/value pairs separated by an `=` sign. To specify runtime secrets use the flag where the value is a comma delimited list of key/value pairs separated by an `=` sign and the value part is the name of a secret.&#x20;

The following example sets an environment variable called `USER_ID` to the value `testuser` and an environment variable called `API_KEY` to the value in the configured in the secret named `SECRET_API_KEY`.

```
instruqt track test TEAM/TRACK --runtime-parameters=USER_ID=testuser --runtime-secrets=API_KEY=SECRET_API_KEY
```

{% endtab %}

{% tab title="🌐 Embed" %}
You can specify runtime parameters as part of the URL query parameters for embedded tracks. Any parameters prefixed with `rtp_` will be injected as environment variables where the suffix will be the variable name and the value the variable value. Any parameters prefixed with `rts_` will be injected as environment variables where the suffix is the variable name and the value is the secret from which the sensitive value should be fetched.&#x20;

The following example sets an environment variable called `USER_ID` to the value `testuser` and an environment variable called `API_KEY` to the value in the configured in the secret named `SECRET_API_KEY`.

```
https://play.instruqt.com/embed/TEAM/tracks/EXAMPLE?token=TOKEN&rtp_USER_ID=testuser&rts_API_KEY=SECRET_API_KEY
```

{% endtab %}

{% tab title="🔥 Hot Start" %}
Coming soon ...
{% endtab %}
{% endtabs %}
