> For the complete documentation index, see [llms.txt](https://guide.fariaedu.com/professional-learning-community-mbpy/6VBx07Zj330EYGI5zHno/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.fariaedu.com/professional-learning-community-mbpy/6VBx07Zj330EYGI5zHno/tutorials/configuration.md).

# Configuration

Use configuration to set up API keys for a school (or multiple schools)

### Getting Started

After installation, the next step is to enable mbpy to use a school's API key. In ManageBac, create a token with at least read permissions for all endpoints, and copy the token value. Then:

```
mbpy config new
```

{% hint style="info" %}
Does it say command not found? If you just installed it, you'll need to open a new terminal window.
{% endhint %}

You will then be promopted to enter the subdomain, and the token.

When complete, enter the following:

```
mbpy config show
```

The above command reports all configuration information:

```
                               mbpy configuration
                             ╷
  name                       │ value
╺━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
  subdomain                  │ demo
╶────────────────────────────┼──────────────────────────────────────────────────╴
  token (last 4 digits)      │ daa0
╶────────────────────────────┼──────────────────────────────────────────────────╴
  Root Directory             │ ~/some/path/here
╶────────────────────────────┼──────────────────────────────────────────────────╴
  Scripts Directory          │ ~/some/path/here/mbpy/scripts
╶────────────────────────────┼──────────────────────────────────────────────────╴
  Path to config file        │ ~/some/path/here/mbpy/conf/demo.py
╶────────────────────────────┼──────────────────────────────────────────────────╴
  Path to database           │ ~/some/path/here/mbpy/data/demo.db
╶────────────────────────────┼──────────────────────────────────────────────────╴
```

Configuration complete! Learn how to pull data from the API by heading over to "Importing":

{% content-ref url="/pages/-MjF0nf5JJZgfjVJ-jnG" %}
[Importing](/professional-learning-community-mbpy/6VBx07Zj330EYGI5zHno/tutorials/overview.md)
{% endcontent-ref %}

### Switching schools

Whenever mbpy starts up, it uses the indicated configuration file, whose contents include the API token given for `mbpy config new`.&#x20;

{% hint style="info" %}
Security note: The API token is stored in plain text in the configuration file. Access to this file should be restricted.
{% endhint %}

If you set up more than one school, and need to switch schools, you can use the following command:

```
mbpy config use subdomain
```

That will tell mbpy to use the configuration file associated with the subdomain name you previously input.

To see a list of all subdomains available:

```
mbpy config list
```

#### Expliciit configuration

The above demonstrates how to use "implicit" configuration, where `mbpy config use` selects the subdomain, and then every subsequent `mbpy` command uses that configuration (until `mbpy config use` is invoked).&#x20;

If you would prefer to explicitly indicate which subdoman, you can set the `MBPY_SUBDOMAIN` variable:

```
mbpy --subdomain abc …
```

That will instruct mbpy to use the configuration file, the same as if you first did `mbpy config use abc`.
