> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/cortex-xsiam/reference-and-developer-docs/cortex-cli/authenticate-credentials.md).

# Authenticate credentials

Configure credentials before running Cortex CLI. The installer does not save them.

Choose the method that fits your workflow:

* Use a configuration file for persistent local authentication.
* Use environment variables for CI/CD pipelines.
* Use command-line flags for one-off commands or overrides.

{% hint style="warning" %}
Do not commit API keys or credential files to source control.
{% endhint %}

### Configuration file

Use a `cortex.env` file for persistent local authentication. Cortex CLI reads this file automatically from your home or current working directory.

The file uses `KEY=VALUE` pairs.

#### macOS and Linux

Create `~/cortex.env` and restrict access to it.

```shell
cat > ~/cortex.env << EOF
CORTEX_API_BASE_URL=https://api-<TENANT>.xdr.us.paloaltonetworks.com
CORTEX_API_KEY=<YOUR_API_KEY>
CORTEX_API_KEY_ID=<YOUR_KEY_ID>
EOF
chmod 600 ~/cortex.env
```

#### Windows

Create `cortex.env` in your user profile.

```powershell
$configPath = "$env:USERPROFILE\cortex.env"
@"
CORTEX_API_BASE_URL=https://api-<TENANT>.xdr.us.paloaltonetworks.com
CORTEX_API_KEY=<YOUR_API_KEY>
CORTEX_API_KEY_ID=<YOUR_KEY_ID>
"@ | Out-File -FilePath $configPath -Encoding UTF8
```

### Environment variables

Use environment variables for CI/CD pipelines. Store values in your CI/CD platform's secret store.

| Variable name         | Description                                                                 |
| --------------------- | --------------------------------------------------------------------------- |
| `CORTEX_API_BASE_URL` | Your tenant URL (such as <https://api-example.xdr.us.paloaltonetworks.com>) |
| `CORTEX_API_KEY`      | The secret key token                                                        |
| `CORTEX_API_KEY_ID`   | The ID associated with the key                                              |

#### macOS and Linux

```shell
export CORTEX_API_BASE_URL="https://api-<TENANT>.xdr.us.paloaltonetworks.com"
export CORTEX_API_KEY="<YOUR_API_KEY>"
export CORTEX_API_KEY_ID="<YOUR_KEY_ID>"
```

#### Windows

```powershell
$env:CORTEX_API_BASE_URL="https://api-<TENANT>.xdr.us.paloaltonetworks.com"
$env:CORTEX_API_KEY="<YOUR_API_KEY>"
$env:CORTEX_API_KEY_ID="<YOUR_KEY_ID>"
```

### Command-line flags

Use flags for one-off scans or to override configured credentials. Place global flags before the module name.

```shell
cortexcli --api-base-url <URL> --api-key <KEY> --api-key-id <ID> code scan ...
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/cortex-xsiam/reference-and-developer-docs/cortex-cli/authenticate-credentials.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
