> 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/gitops.md).

# GitOps

Manage GitOps agents, applications, clusters, and repositories with the Harness GitOps API.

The GitOps API manages Harness GitOps, which uses Argo CD to keep the state of your Kubernetes clusters in line with the manifests in Git.

## 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, organization, and project IDs**: Send `accountIdentifier`, `orgIdentifier`, and `projectIdentifier` as query parameters to set the scope of the agent or application you are working with. 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/gitops`, followed by the endpoint path.

## Example request

List the GitOps agents in a project:

```bash
curl "https://app.harness.io/gateway/gitops/api/v1/agents?accountIdentifier=ACCOUNT_ID&orgIdentifier=ORG_ID&projectIdentifier=PROJECT_ID" \
  -H "x-api-key: $HARNESS_API_KEY"
```

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.

* **Agents**: The Harness GitOps Agent you install in a cluster. It runs Argo CD and connects it to Harness. List agents with `GET /api/v1/agents`. Go to [Agents](https://developer.harness.io/continuous-delivery/use-gitops/gitops-entities/agents) to install an agent.
* **Applications**: The link between a source of manifests in Git and a destination cluster and namespace. List applications with `POST /api/v1/applications`, and sync one with `POST /api/v1/agents/{agentIdentifier}/applications/{request.name}/sync`. Go to [Applications](https://developer.harness.io/continuous-delivery/use-gitops/application) to create an application.
* **ApplicationSets**: Templates that generate many applications at once, for example one per cluster. List them with `POST /api/v1/applicationsets` and read one with `GET /api/v1/applicationset/{identifier}`. Go to [ApplicationSets](https://developer.harness.io/continuous-delivery/use-gitops/applicationsets) to create an ApplicationSet.
* **Clusters**: The Kubernetes clusters an agent can deploy to. List an agent's clusters with `GET /api/v1/agents/{agentIdentifier}/clusters`. Go to [Clusters](https://developer.harness.io/continuous-delivery/use-gitops/gitops-entities/clusters) to add a cluster.
* **Repositories and repository credentials**: The Git and Helm repositories that hold your manifests, and the credentials used to read them. List an agent's repositories with `GET /api/v1/agents/{agentIdentifier}/repositories`, and add credentials with `POST /api/v1/agents/{agentIdentifier}/repocreds`. Go to [Repositories](https://developer.harness.io/continuous-delivery/use-gitops/gitops-entities/repositories) to add a repository.
* **Argo CD projects and project mappings**: Argo CD projects and how they map to Harness projects. Read the mappings with `GET /api/v1/agents/{agentIdentifier}/appprojectsmapping`. Go to [Manage ArgoCD projects](https://developer.harness.io/continuous-delivery/use-gitops/gitops-entities/projects/manage-projects) to manage Argo CD projects.
