> 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/application-security/terraform-workflows/authentication-and-configuration.md).

# Authentication and configuration

Automate your Application Security / ASPM lifecycle using Infrastructure-as-Code. The Cortex Cloud Terraform provider allows platform teams to programmatically manage integrations, business applications, custom rules, and compliance profiles at scale.

**Source of truth**: For the most up-to-date schema, provider versions, and complete resource documentation, always refer to the official [Cortex Cloud Terraform provider registry](https://registry.terraform.io/providers/PaloAltoNetworks/cortexcloud/latest/docs).

## Prerequisites

Before automating your Application Security workflows, you must initialize and authenticate the `cortexcloud` Terraform provider using your tenant's API credentials.

### Provider version requirement

To manage Application Security-specific resources, you must declare the latest provider version (refer to [Cortex Cloud Terraform provider registry](https://registry.terraform.io/providers/PaloAltoNetworks/cortexcloud/latest/docs)).

### Authentication requirement

To authenticate, you must generate a dedicated API key in the Cortex Cloud console under **Settings** → **Configurations** → **API Keys**. For more information, refer to [Manage API keys](/cortex-cloud-runtime-security/onboard-and-configure/deployment-steps-and-checklist/manage-api-keys.md).

The provider requires the following parameters to authenticate:

* `api_url`: The API URL of your Cortex Cloud tenant, formatted as `https://api-{fqdn}`
* `api_key`: Your Cortex Cloud API key
* `api_key_id`: Your Cortex Cloud API key ID (must be a number)
* `api_key_type`: You must set this attribute to **standard** or **advanced** depending on the key you generated to prevent authentication errors. Note that it defaults to `advanced`. It is highly recommend to use an advanced API key level for added security

## **Configuration methods**

You can pass credentials using one of three methods:

* **Provider block parameters**

  ```hcl
  provider "cortexcloud" {
    api_url      = "https://api-{fqdn}"
    api_key      = "your-api-key"
    api_key_id   = 12345
    api_key_type = "advanced"
  }
  ```
* **Environment variables**

  You can set `CORTEXCLOUD_API_URL`, `CORTEXCLOUD_API_KEY`, `CORTEXCLOUD_API_KEY_ID`, and `CORTEXCLOUD_API_KEY_TYPE`.
* **Configuration file**

  A JSON file referenced by the `config_file` attribute.


---

# 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://cortex-docs.paloaltonetworks.com/application-security/terraform-workflows/authentication-and-configuration.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.
