> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/api-reference/software-delivery-agent-apis/infrastructure-as-code-management.md).

# Infrastructure as Code Management

Manage IaCM workspaces, variable sets, module and provider registries, and Ansible resources with the Harness Infrastructure as Code Management API.

The Infrastructure as Code Management (IaCM) API manages the workspaces that run your OpenTofu and Terraform code, the variables they use, and the private registries they pull modules and providers from.

## Request basics

* **API key token**: Send it in the `x-api-key` header on every request. Go to [Manage API keys](https://developer.harness.io/harness-platform/use-harness-platform/automation/api/add-and-manage-api-keys) to create a key and token.
* **Account ID**: Send it in the `Harness-Account` header on every request, rather than as a query parameter.
* **Organization and project IDs**: Most endpoints take them as the `org` and `project` path parameters. Go to [Organizations and projects](https://developer.harness.io/harness-platform/use-harness-platform/organizations-and-projects) to find these identifiers.
* **Base URL**: Send requests to `https://app.harness.io/gateway/iacm`, followed by the endpoint path.

## Example request

List the workspaces in a project:

```bash
curl "https://app.harness.io/gateway/iacm/api/orgs/ORG_ID/projects/PROJECT_ID/workspaces" \
  -H "x-api-key: $HARNESS_API_KEY" \
  -H "Harness-Account: ACCOUNT_ID"
```

Replace `ACCOUNT_ID`, `ORG_ID`, and `PROJECT_ID` with your own values, and set `HARNESS_API_KEY` to your API key token.

## Find an endpoint

Endpoint paths are relative to the base URL.

* **Workspaces**: The unit IaCM runs. A workspace holds your code location, state, variables, and the connector to your cloud. List workspaces with `GET /api/orgs/{org}/projects/{project}/workspaces`. Go to [Workspaces](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces) to create and manage workspaces.
* **Variable sets**: Reusable groups of variables, secrets, and connectors that you attach to many workspaces at once. List a project's variable sets with `GET /api/orgs/{org}/projects/{project}/configuration-variable-sets`. Go to [Variable Sets](https://developer.harness.io/infrastructure-as-code-management/platform/iacm-connectors-variables/variable-sets) to create and attach a variable set.
* **Workspace templates**: Preset workspace settings that teams start from, so new workspaces follow the same standards. Create a template with `POST /api/orgs/{org}/projects/{project}/workspace/templates`. Go to [Workspace templates](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/workspace-templates) to create a workspace template.
* **Module registry**: A private registry for OpenTofu and Terraform modules that your workspaces can reference. List modules with `GET /api/modules` and register one with `POST /api/modules`. Go to [Module Registry](https://developer.harness.io/infrastructure-as-code-management/registry/module-registry) to register a module.
* **Provider registry**: A private registry for OpenTofu and Terraform providers. List providers with `GET /api/providers`. Go to [Provider Registry](https://developer.harness.io/infrastructure-as-code-management/registry/provider-registry) to publish a provider.
* **Executions and approvals**: Plan and apply runs for a workspace, and the approvals that gate them. List runs with `GET /api/orgs/{org}/projects/{project}/executions` and approvals with `GET /api/orgs/{org}/projects/{project}/approvals`. Go to [Approval Step](https://developer.harness.io/infrastructure-as-code-management/platform/iacm-pipelines/content/approval-step) to add an approval step.
* **Drift remediation**: Detecting differences between your code and the live infrastructure, and proposing fixes. Read a workspace's drift settings with `GET /api/orgs/{org}/projects/{project}/workspaces/{workspace}/drift-config`, and the project's remediation settings with `GET /api/orgs/{org}/projects/{project}/remediation/config`. Go to [Drift Detection and Ephemeral Workspaces](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/drift-ephemeral-workspaces) to set up drift detection.
* **Costs and insights**: Estimated cost changes and resource insights for each workspace. List estimated costs with `GET /api/orgs/{org}/projects/{project}/costs`. Go to [Cost Estimation](https://developer.harness.io/infrastructure-as-code-management/platform/workspaces/cost-estimation) to turn on cost estimation.
* **Ansible**: Inventories and playbooks for configuring the machines your infrastructure creates. List playbooks with `GET /api/ansible/playbook` and recent runs with `GET /api/ansible/activities`. Go to [Get Started With Ansible](https://developer.harness.io/infrastructure-as-code-management/use-iacm/configuration-management/get-started) to set up your first inventory and playbook.
