> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/argoproj/argo-cd/llms.txt
> Use this file to discover all available pages before exploring further.

# Application API

> CRUD operations and management for Argo CD Application resources

## Overview

The Application Service API provides comprehensive CRUD operations for Application resources. Applications represent the desired state of a Kubernetes application managed by Argo CD.

**Base Path:** `/api/v1/applications`

**gRPC Service:** `application.ApplicationService`

## Application Resource

An Application defines the source repository, destination cluster, and sync policies.

### Application Spec

<ParamField path="source" type="ApplicationSource">
  Reference to the location of manifests or chart (single-source)

  <Expandable title="ApplicationSource fields">
    <ResponseField name="repoURL" type="string" required>
      URL to the Git or Helm repository
    </ResponseField>

    <ResponseField name="path" type="string">
      Directory path within Git repository
    </ResponseField>

    <ResponseField name="targetRevision" type="string">
      Git branch, tag, or commit SHA / Helm chart version
    </ResponseField>

    <ResponseField name="chart" type="string">
      Helm chart name (for Helm repos)
    </ResponseField>

    <ResponseField name="helm" type="ApplicationSourceHelm">
      Helm-specific options (values, parameters, etc.)
    </ResponseField>

    <ResponseField name="kustomize" type="ApplicationSourceKustomize">
      Kustomize-specific options
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="sources" type="ApplicationSource[]">
  Multiple sources for multi-source applications
</ParamField>

<ParamField path="destination" type="ApplicationDestination" required>
  Target Kubernetes cluster and namespace

  <Expandable title="ApplicationDestination fields">
    <ResponseField name="server" type="string">
      Kubernetes API server URL (e.g., `https://kubernetes.default.svc`)
    </ResponseField>

    <ResponseField name="name" type="string">
      Cluster name (alternative to server)
    </ResponseField>

    <ResponseField name="namespace" type="string" required>
      Target namespace for deployment
    </ResponseField>
  </Expandable>
</ParamField>

<ParamField path="project" type="string" required>
  Project name (use "default" if not specified)
</ParamField>

<ParamField path="syncPolicy" type="SyncPolicy">
  Sync policy configuration

  <Expandable title="SyncPolicy fields">
    <ResponseField name="automated" type="AutomatedSyncPolicy">
      Automated sync settings (prune, selfHeal, allowEmpty)
    </ResponseField>

    <ResponseField name="syncOptions" type="string[]">
      Sync options (e.g., "CreateNamespace=true")
    </ResponseField>

    <ResponseField name="retry" type="RetryStrategy">
      Retry configuration for failed syncs
    </ResponseField>
  </Expandable>
</ParamField>

### Example Application

```yaml theme={null}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: guestbook
  namespace: argocd
spec:
  project: default
  source:
    repoURL: https://github.com/argoproj/argocd-example-apps
    targetRevision: HEAD
    path: guestbook
  destination:
    server: https://kubernetes.default.svc
    namespace: guestbook
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
    syncOptions:
    - CreateNamespace=true
```

## API Operations

### List Applications

Retrieve a list of applications.

```bash theme={null}
GET /api/v1/applications
```

<ParamField query="projects" type="string[]">
  Filter by project names
</ParamField>

<ParamField query="selector" type="string">
  Label selector (e.g., `app=myapp,env=prod`)
</ParamField>

<ParamField query="repo" type="string">
  Filter by repository URL
</ParamField>

<ParamField query="appNamespace" type="string">
  Filter by application namespace
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl https://argocd-server/api/v1/applications?projects=default \
    -H "Authorization: Bearer $TOKEN"
  ```

  ```go Go theme={null}
  import applicationpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"

  appClient := applicationpkg.NewApplicationServiceClient(conn)
  apps, err := appClient.List(ctx, &applicationpkg.ApplicationQuery{
      Projects: []string{"default"},
  })
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://argocd-server/api/v1/applications",
      params={"projects": ["default"]},
      headers={"Authorization": f"Bearer {token}"}
  )
  apps = response.json()
  ```
</CodeGroup>

### Get Application

Retrieve a specific application by name.

```bash theme={null}
GET /api/v1/applications/{name}
```

<ParamField path="name" type="string" required>
  Application name
</ParamField>

<ParamField query="refresh" type="string">
  Force refresh from Git ("normal" or "hard")
</ParamField>

<ParamField query="project" type="string">
  Project filter for validation
</ParamField>

<ParamField query="appNamespace" type="string">
  Application namespace
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl https://argocd-server/api/v1/applications/guestbook \
    -H "Authorization: Bearer $TOKEN"
  ```

  ```go Go theme={null}
  app, err := appClient.Get(ctx, &applicationpkg.ApplicationQuery{
      Name: "guestbook",
  })
  ```
</CodeGroup>

### Create Application

Create a new application.

```bash theme={null}
POST /api/v1/applications
```

<ParamField body="application" type="Application" required>
  Complete Application resource definition
</ParamField>

<ParamField body="upsert" type="boolean">
  Update if already exists (default: false)
</ParamField>

<ParamField body="validate" type="boolean">
  Validate before creating (default: true)
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://argocd-server/api/v1/applications \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "metadata": {
        "name": "guestbook"
      },
      "spec": {
        "project": "default",
        "source": {
          "repoURL": "https://github.com/argoproj/argocd-example-apps",
          "path": "guestbook",
          "targetRevision": "HEAD"
        },
        "destination": {
          "server": "https://kubernetes.default.svc",
          "namespace": "guestbook"
        }
      }
    }'
  ```

  ```go Go theme={null}
  app, err := appClient.Create(ctx, &applicationpkg.ApplicationCreateRequest{
      Application: &v1alpha1.Application{
          ObjectMeta: metav1.ObjectMeta{
              Name: "guestbook",
          },
          Spec: v1alpha1.ApplicationSpec{
              Project: "default",
              Source: &v1alpha1.ApplicationSource{
                  RepoURL:        "https://github.com/argoproj/argocd-example-apps",
                  Path:           "guestbook",
                  TargetRevision: "HEAD",
              },
              Destination: v1alpha1.ApplicationDestination{
                  Server:    "https://kubernetes.default.svc",
                  Namespace: "guestbook",
              },
          },
      },
  })
  ```

  ```yaml YAML (via kubectl) theme={null}
  kubectl apply -f - <<EOF
  apiVersion: argoproj.io/v1alpha1
  kind: Application
  metadata:
    name: guestbook
    namespace: argocd
  spec:
    project: default
    source:
      repoURL: https://github.com/argoproj/argocd-example-apps
      targetRevision: HEAD
      path: guestbook
    destination:
      server: https://kubernetes.default.svc
      namespace: guestbook
  EOF
  ```
</CodeGroup>

### Update Application

Update an existing application.

```bash theme={null}
PUT /api/v1/applications/{application.metadata.name}
```

<ParamField body="application" type="Application" required>
  Updated Application resource
</ParamField>

<ParamField body="validate" type="boolean">
  Validate before updating
</ParamField>

### Update Application Spec

Update only the application spec.

```bash theme={null}
PUT /api/v1/applications/{name}/spec
```

<ParamField path="name" type="string" required>
  Application name
</ParamField>

<ParamField body="spec" type="ApplicationSpec" required>
  Updated specification
</ParamField>

### Patch Application

Partially update an application.

```bash theme={null}
PATCH /api/v1/applications/{name}
```

<ParamField path="name" type="string" required>
  Application name
</ParamField>

<ParamField body="patch" type="string" required>
  JSON patch or merge patch content
</ParamField>

<ParamField body="patchType" type="string" required>
  Patch type: "json", "merge", or "strategic"
</ParamField>

**Example:**

```bash theme={null}
curl -X PATCH https://argocd-server/api/v1/applications/guestbook \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "patch": "{\"spec\":{\"syncPolicy\":{\"automated\":{\"prune\":true}}}}",
    "patchType": "merge"
  }'
```

### Delete Application

Delete an application.

```bash theme={null}
DELETE /api/v1/applications/{name}
```

<ParamField path="name" type="string" required>
  Application name
</ParamField>

<ParamField query="cascade" type="boolean">
  Delete application resources (default: true)
</ParamField>

<ParamField query="propagationPolicy" type="string">
  Kubernetes propagation policy: "foreground", "background", or "orphan"
</ParamField>

<ParamField query="appNamespace" type="string">
  Application namespace
</ParamField>

<CodeGroup>
  ```bash Delete with cascade theme={null}
  curl -X DELETE "https://argocd-server/api/v1/applications/guestbook?cascade=true" \
    -H "Authorization: Bearer $TOKEN"
  ```

  ```bash Delete without cascade (keep resources) theme={null}
  curl -X DELETE "https://argocd-server/api/v1/applications/guestbook?cascade=false" \
    -H "Authorization: Bearer $TOKEN"
  ```
</CodeGroup>

## Sync Operations

### Sync Application

Trigger a sync operation to deploy the application.

```bash theme={null}
POST /api/v1/applications/{name}/sync
```

<ParamField path="name" type="string" required>
  Application name
</ParamField>

<ParamField body="revision" type="string">
  Target revision to sync (default: spec.targetRevision)
</ParamField>

<ParamField body="prune" type="boolean">
  Delete resources not in Git
</ParamField>

<ParamField body="dryRun" type="boolean">
  Preview sync without applying changes
</ParamField>

<ParamField body="strategy" type="SyncStrategy">
  Sync strategy (hook, apply)
</ParamField>

<ParamField body="resources" type="SyncOperationResource[]">
  Specific resources to sync
</ParamField>

<ParamField body="syncOptions" type="string[]">
  Sync options (e.g., "PruneLast=true")
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://argocd-server/api/v1/applications/guestbook/sync \
    -H "Authorization: Bearer $TOKEN" \
    -d '{
      "prune": true,
      "dryRun": false
    }'
  ```

  ```go Go theme={null}
  app, err := appClient.Sync(ctx, &applicationpkg.ApplicationSyncRequest{
      Name:  "guestbook",
      Prune: true,
  })
  ```
</CodeGroup>

### Terminate Operation

Cancel a running sync operation.

```bash theme={null}
DELETE /api/v1/applications/{name}/operation
```

### Rollback Application

Rollback to a previous revision.

```bash theme={null}
POST /api/v1/applications/{name}/rollback
```

<ParamField path="name" type="string" required>
  Application name
</ParamField>

<ParamField body="id" type="int64" required>
  History ID to rollback to
</ParamField>

<ParamField body="prune" type="boolean">
  Prune resources during rollback
</ParamField>

<ParamField body="dryRun" type="boolean">
  Preview rollback
</ParamField>

## Resource Operations

### Get Resource

Get a specific resource managed by the application.

```bash theme={null}
GET /api/v1/applications/{name}/resource
```

<ParamField query="namespace" type="string">
  Resource namespace
</ParamField>

<ParamField query="resourceName" type="string" required>
  Resource name
</ParamField>

<ParamField query="version" type="string" required>
  API version (e.g., "v1")
</ParamField>

<ParamField query="group" type="string">
  API group (empty for core)
</ParamField>

<ParamField query="kind" type="string" required>
  Resource kind (e.g., "Deployment")
</ParamField>

### Delete Resource

Delete a specific resource.

```bash theme={null}
DELETE /api/v1/applications/{name}/resource
```

### Patch Resource

Patch a specific resource.

```bash theme={null}
POST /api/v1/applications/{name}/resource
```

## Monitoring & Observability

### Get Resource Tree

Get the application's resource hierarchy.

```bash theme={null}
GET /api/v1/applications/{applicationName}/resource-tree
```

### Watch Resource Tree

Stream resource tree updates.

```bash theme={null}
GET /api/v1/stream/applications/{applicationName}/resource-tree
```

### Get Pod Logs

Stream logs from application pods.

```bash theme={null}
GET /api/v1/applications/{name}/pods/{podName}/logs
```

<ParamField query="container" type="string">
  Container name
</ParamField>

<ParamField query="follow" type="boolean">
  Stream logs
</ParamField>

<ParamField query="tailLines" type="int64">
  Number of lines to tail
</ParamField>

<ParamField query="sinceSeconds" type="int64">
  Logs from last N seconds
</ParamField>

### Watch Applications

Stream application change events.

```bash theme={null}
GET /api/v1/stream/applications
```

## Next Steps

<CardGroup cols={2}>
  <Card title="ApplicationSet API" icon="layer-group" href="/api/applicationset">
    Manage ApplicationSets
  </Card>

  <Card title="Project API" icon="folder" href="/api/appproject">
    Configure projects for applications
  </Card>
</CardGroup>
