# API Key and API Server Search Order Reference If you discover you can’t access a database you think you ought to have access to, check that you’re in the correct environment and using the correct API key. You can verify the td config and environmental variables are consistent with the API key and endpoint you need to access using the appropriate commands for your operating system. With correct permissions, the inability to access a specific database could happen for various reasons. To help determine the reason, it’s helpful to understand the order in which TD Toolbelt searches for the API key and API server: ## Search Order for the API Key 1. Specified on the command line by `td -k` option, which allows you to specify an API key instead of reading the config file 2. `TREASURE_DATA_API_KEY` environment variable 3. `TD_API_KEY` environment variable 4. `TD_API_KEY` in config file which path is specified by `td -c` option 5. `TD_API_KEY` in config file which path is specified by `TREASURE_DATA_CONFIG_PATH` environment variable 6. `TD_API_KEY` in config file which path is specified by `TD_CONFIG_PATH` environment variable 7. `TD_API_KEY` in config file locates at `~/.td/td.conf` ## Search Order for the API Server 1. Specified on the command line by `td -e` option, which allows you to designate an endpoint 2. `TREASURE_DATA_API_SERVER` environment variable 3. `TD_API_SERVER` environment variable 4. `TD_API_SERVER` in config file which path is specified by `td -c` option 5. `TD_API_SERVER` in config file which path is specified by `TREASURE_DATA_CONFIG_PATH` environment variable 6. `TD_API_SERVER` in config file which path is specified by `TD_CONFIG_PATH` environment variable 7. `TD_API_SERVER` in config file locates at `~/.td/td.conf`