> For the complete documentation index, see [llms.txt](https://docs.snyk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snyk.io/developer-tools/snyk-cli/configure-the-snyk-cli/configure-snyk-cli-to-connect-to-snyk-api.md).

# Configure Snyk CLI to connect to Snyk API

How to configure how the Snyk CLI connects to the Snyk API, including the platform URL and region

## Configure the Snyk platform URL

By default, the Snyk CLI connects to `https://api.snyk.io/`. You can use the following variables to configure your connection.

`SNYK_API`

Specifying this variable sets the API host that will be used for Snyk requests. This is useful for [regional hosting](https://docs.snyk.io/snyk-data-and-governance/regional-hosting-and-data-residency#cli-and-ci-pipeline-urls), on-premise instances, or when you are using a proxy server. If this variable is set with the `http` protocol, the CLI upgrades the requests to `https` unless `SNYK_HTTP_PROTOCOL_UPGRADE` is set to `0`.

`SNYK_HTTP_PROTOCOL_UPGRADE=0`

If you set this variable to the value of `0`, API and CLI requests aimed at `http` URLs are not upgraded to `https`. If the protocol is not set, the default behavior is to upgrade these requests from `http` to `https`. Setting this variable is useful, for example, for reverse proxies.

## Configure CLI Analytics

Learn more in the [Snyk CLI analytics](/developer-tools/snyk-cli/snyk-cli-analytics.md) documentation.

`SNYK_DISABLE_ANALYTICS=1`

Specifying this variable disables all Snyk CLI analytics.

## Configure the authentication method used to log in to the Snyk platform

`SNYK_TOKEN`

Specifying this variable allows you to override the token that may be available in your Snyk configuration settings (`~/.config/configstore/snyk.json`). Use `SNYK_TOKEN` in a CI/CD environment. After setting `SNYK_TOKEN` you can [get started](/developer-tools/snyk-cli/getting-started-with-the-snyk-cli.md) using the CLI.

For information on how to get your account token see [Authenticate the CLI with your account](/developer-tools/snyk-cli/authenticate-to-use-the-cli.md). You can also use a service account to authenticate; for more information see [Service accounts](https://docs.snyk.io/platform-administration/service-accounts/service-accounts). For additional information, see [Authentication for third-party tools](/developer-tools/authentication-for-third-party-tools.md).

`SNYK_OAUTH_TOKEN=<OAuth token>`

Using this variable specifies the OAuth token if required for verification.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snyk.io/developer-tools/snyk-cli/configure-the-snyk-cli/configure-snyk-cli-to-connect-to-snyk-api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
