> ## 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 Service

> gRPC API reference for ApplicationService - CRUD operations for Argo CD applications

# Application Service

Application Service API performs CRUD actions against application resources.

## Service Definition

**Package:** `application`

**Service:** `ApplicationService`

The ApplicationService provides comprehensive management capabilities for Argo CD applications, including creation, updates, synchronization, rollback, and resource management.

## RPC Methods

### List

Returns list of applications.

**Request:** `ApplicationQuery`

<ParamField path="name" type="string">
  The application's name
</ParamField>

<ParamField path="refresh" type="string">
  Forces application reconciliation if set to 'hard'
</ParamField>

<ParamField path="projects" type="string[]">
  The project names to restrict returned list applications
</ParamField>

<ParamField path="resourceVersion" type="string">
  When specified with a watch call, shows changes that occur after that particular version of a resource
</ParamField>

<ParamField path="selector" type="string">
  The selector to restrict returned list to applications only with matched labels
</ParamField>

<ParamField path="repo" type="string">
  The repoURL to restrict returned list applications
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `ApplicationList`

**REST Endpoint:** `GET /api/v1/applications`

***

### Get

Returns an application by name.

**Request:** `ApplicationQuery`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `Application`

**REST Endpoint:** `GET /api/v1/applications/{name}`

***

### Create

Creates an application.

**Request:** `ApplicationCreateRequest`

<ParamField path="application" type="Application" required>
  The application to create
</ParamField>

<ParamField path="upsert" type="bool">
  Whether to create or update the application if it already exists
</ParamField>

<ParamField path="validate" type="bool">
  Whether to validate the application before creating
</ParamField>

**Response:** `Application`

**REST Endpoint:** `POST /api/v1/applications`

***

### Update

Updates an application.

**Request:** `ApplicationUpdateRequest`

<ParamField path="application" type="Application" required>
  The application to update
</ParamField>

<ParamField path="validate" type="bool">
  Whether to validate the application before updating
</ParamField>

<ParamField path="project" type="string">
  The project name
</ParamField>

**Response:** `Application`

**REST Endpoint:** `PUT /api/v1/applications/{application.metadata.name}`

***

### Delete

Deletes an application.

**Request:** `ApplicationDeleteRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="cascade" type="bool">
  Whether to cascade delete resources
</ParamField>

<ParamField path="propagationPolicy" type="string">
  The deletion propagation policy (Foreground, Background, or Orphan)
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

<ParamField path="project" type="string">
  The project name
</ParamField>

**Response:** `ApplicationResponse`

**REST Endpoint:** `DELETE /api/v1/applications/{name}`

***

### Sync

Syncs an application to its target state.

**Request:** `ApplicationSyncRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="revision" type="string">
  The revision to sync to
</ParamField>

<ParamField path="dryRun" type="bool">
  Whether to perform a dry run
</ParamField>

<ParamField path="prune" type="bool">
  Whether to prune resources
</ParamField>

<ParamField path="strategy" type="SyncStrategy">
  The sync strategy to use
</ParamField>

<ParamField path="resources" type="SyncOperationResource[]">
  The specific resources to sync
</ParamField>

<ParamField path="manifests" type="string[]">
  Additional manifests to sync
</ParamField>

<ParamField path="syncOptions" type="SyncOptions">
  Sync options
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

<ParamField path="revisions" type="string[]">
  Revisions for multi-source applications
</ParamField>

**Response:** `Application`

**REST Endpoint:** `POST /api/v1/applications/{name}/sync`

***

### Rollback

Rollbacks an application to a previous revision.

**Request:** `ApplicationRollbackRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="id" type="int64" required>
  The history ID to rollback to
</ParamField>

<ParamField path="dryRun" type="bool">
  Whether to perform a dry run
</ParamField>

<ParamField path="prune" type="bool">
  Whether to prune resources
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `Application`

**REST Endpoint:** `POST /api/v1/applications/{name}/rollback`

***

### Watch

Returns stream of application change events.

**Request:** `ApplicationQuery`

**Response:** Stream of `ApplicationWatchEvent`

**REST Endpoint:** `GET /api/v1/stream/applications`

***

### GetManifests

Returns application manifests.

**Request:** `ApplicationManifestQuery`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="revision" type="string">
  The revision to get manifests for
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

<ParamField path="noCache" type="bool">
  Whether to bypass the cache
</ParamField>

**Response:** `ManifestResponse`

**REST Endpoint:** `GET /api/v1/applications/{name}/manifests`

***

### UpdateSpec

Updates an application spec.

**Request:** `ApplicationUpdateSpecRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="spec" type="ApplicationSpec" required>
  The new application spec
</ParamField>

<ParamField path="validate" type="bool">
  Whether to validate the spec before updating
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `ApplicationSpec`

**REST Endpoint:** `PUT /api/v1/applications/{name}/spec`

***

### Patch

Patches an application.

**Request:** `ApplicationPatchRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="patch" type="string" required>
  The patch to apply
</ParamField>

<ParamField path="patchType" type="string" required>
  The patch type (json, merge, or strategic)
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `Application`

**REST Endpoint:** `PATCH /api/v1/applications/{name}`

***

### ResourceTree

Returns resource tree for an application.

**Request:** `ResourcesQuery`

<ParamField path="applicationName" type="string" required>
  The application's name
</ParamField>

<ParamField path="namespace" type="string">
  Filter by namespace
</ParamField>

<ParamField path="name" type="string">
  Filter by resource name
</ParamField>

<ParamField path="version" type="string">
  Filter by API version
</ParamField>

<ParamField path="group" type="string">
  Filter by API group
</ParamField>

<ParamField path="kind" type="string">
  Filter by resource kind
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `ApplicationTree`

**REST Endpoint:** `GET /api/v1/applications/{applicationName}/resource-tree`

***

### WatchResourceTree

Returns stream of application resource tree updates.

**Request:** `ResourcesQuery`

**Response:** Stream of `ApplicationTree`

**REST Endpoint:** `GET /api/v1/stream/applications/{applicationName}/resource-tree`

***

### GetResource

Returns a single application resource.

**Request:** `ApplicationResourceRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="namespace" type="string">
  The resource's namespace
</ParamField>

<ParamField path="resourceName" type="string" required>
  The resource's name
</ParamField>

<ParamField path="version" type="string" required>
  The API version
</ParamField>

<ParamField path="group" type="string">
  The API group
</ParamField>

<ParamField path="kind" type="string" required>
  The resource kind
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `ApplicationResourceResponse`

<ResponseField name="manifest" type="string">
  The resource manifest in YAML or JSON format
</ResponseField>

**REST Endpoint:** `GET /api/v1/applications/{name}/resource`

***

### PatchResource

Patches a single application resource.

**Request:** `ApplicationResourcePatchRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="namespace" type="string">
  The resource's namespace
</ParamField>

<ParamField path="resourceName" type="string" required>
  The resource's name
</ParamField>

<ParamField path="version" type="string" required>
  The API version
</ParamField>

<ParamField path="group" type="string">
  The API group
</ParamField>

<ParamField path="kind" type="string" required>
  The resource kind
</ParamField>

<ParamField path="patch" type="string" required>
  The patch to apply
</ParamField>

<ParamField path="patchType" type="string" required>
  The patch type
</ParamField>

**Response:** `ApplicationResourceResponse`

**REST Endpoint:** `POST /api/v1/applications/{name}/resource`

***

### DeleteResource

Deletes a single application resource.

**Request:** `ApplicationResourceDeleteRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="namespace" type="string">
  The resource's namespace
</ParamField>

<ParamField path="resourceName" type="string" required>
  The resource's name
</ParamField>

<ParamField path="version" type="string" required>
  The API version
</ParamField>

<ParamField path="group" type="string">
  The API group
</ParamField>

<ParamField path="kind" type="string" required>
  The resource kind
</ParamField>

<ParamField path="force" type="bool">
  Whether to force delete
</ParamField>

<ParamField path="orphan" type="bool">
  Whether to orphan the resource
</ParamField>

**Response:** `ApplicationResponse`

**REST Endpoint:** `DELETE /api/v1/applications/{name}/resource`

***

### PodLogs

Returns stream of log entries for the specified pod.

**Request:** `ApplicationPodLogsQuery`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="namespace" type="string">
  The pod's namespace
</ParamField>

<ParamField path="podName" type="string">
  The pod's name
</ParamField>

<ParamField path="container" type="string">
  The container name
</ParamField>

<ParamField path="sinceSeconds" type="int64">
  Logs since N seconds ago
</ParamField>

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

<ParamField path="follow" type="bool">
  Whether to follow the log stream
</ParamField>

<ParamField path="filter" type="string">
  Filter pattern for logs
</ParamField>

<ParamField path="previous" type="bool">
  Whether to get logs from previous container instance
</ParamField>

**Response:** Stream of `LogEntry`

<ResponseField name="content" type="string">
  The log content
</ResponseField>

<ResponseField name="timeStampStr" type="string">
  The timestamp of the log entry
</ResponseField>

<ResponseField name="podName" type="string">
  The pod name
</ResponseField>

<ResponseField name="last" type="bool">
  Whether this is the last log entry
</ResponseField>

**REST Endpoint:** `GET /api/v1/applications/{name}/pods/{podName}/logs`

***

### TerminateOperation

Terminates the currently running operation.

**Request:** `OperationTerminateRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `OperationTerminateResponse`

**REST Endpoint:** `DELETE /api/v1/applications/{name}/operation`

***

### ManagedResources

Returns list of managed resources.

**Request:** `ResourcesQuery`

**Response:** `ManagedResourcesResponse`

<ResponseField name="items" type="ResourceDiff[]">
  List of managed resources with their diff status
</ResponseField>

**REST Endpoint:** `GET /api/v1/applications/{applicationName}/managed-resources`

***

### ListResourceEvents

Returns a list of event resources.

**Request:** `ApplicationResourceEventsQuery`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="resourceNamespace" type="string">
  The resource's namespace
</ParamField>

<ParamField path="resourceName" type="string">
  The resource's name
</ParamField>

<ParamField path="resourceUID" type="string">
  The resource's UID
</ParamField>

**Response:** `EventList`

**REST Endpoint:** `GET /api/v1/applications/{name}/events`

***

### ListResourceActions

Returns list of available resource actions.

**Request:** `ApplicationResourceRequest`

**Response:** `ResourceActionsListResponse`

<ResponseField name="actions" type="ResourceAction[]">
  List of available actions for the resource
</ResponseField>

**REST Endpoint:** `GET /api/v1/applications/{name}/resource/actions`

***

### RunResourceActionV2

Runs a resource action with parameters.

**Request:** `ResourceActionRunRequestV2`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="namespace" type="string">
  The resource's namespace
</ParamField>

<ParamField path="resourceName" type="string" required>
  The resource's name
</ParamField>

<ParamField path="version" type="string" required>
  The API version
</ParamField>

<ParamField path="group" type="string">
  The API group
</ParamField>

<ParamField path="kind" type="string" required>
  The resource kind
</ParamField>

<ParamField path="action" type="string" required>
  The action name to run
</ParamField>

<ParamField path="resourceActionParameters" type="ResourceActionParameters[]">
  Parameters for the action
</ParamField>

**Response:** `ApplicationResponse`

**REST Endpoint:** `POST /api/v1/applications/{name}/resource/actions/v2`

***

### GetApplicationSyncWindows

Returns sync windows of the application.

**Request:** `ApplicationSyncWindowsQuery`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `ApplicationSyncWindowsResponse`

<ResponseField name="activeWindows" type="ApplicationSyncWindow[]">
  Currently active sync windows
</ResponseField>

<ResponseField name="assignedWindows" type="ApplicationSyncWindow[]">
  All assigned sync windows
</ResponseField>

<ResponseField name="canSync" type="bool">
  Whether the application can sync now
</ResponseField>

**REST Endpoint:** `GET /api/v1/applications/{name}/syncwindows`

***

### RevisionMetadata

Returns the metadata for a specific revision.

**Request:** `RevisionMetadataQuery`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="revision" type="string" required>
  The revision to get metadata for
</ParamField>

<ParamField path="appNamespace" type="string">
  The application's namespace
</ParamField>

**Response:** `RevisionMetadata`

**REST Endpoint:** `GET /api/v1/applications/{name}/revisions/{revision}/metadata`

***

### ListLinks

Returns the list of all application deep links.

**Request:** `ListAppLinksRequest`

<ParamField path="name" type="string" required>
  The application's name
</ParamField>

<ParamField path="namespace" type="string">
  The application's namespace
</ParamField>

**Response:** `LinksResponse`

<ResponseField name="items" type="LinkInfo[]">
  List of deep links
</ResponseField>

**REST Endpoint:** `GET /api/v1/applications/{name}/links`

***

## gRPC Example

```go theme={null}
import (
    "context"
    "google.golang.org/grpc"
    applicationpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/application"
)

// Create a gRPC connection
conn, err := grpc.Dial("argocd-server:443", grpc.WithInsecure())
if err != nil {
    log.Fatal(err)
}
defer conn.Close()

// Create application service client
client := applicationpkg.NewApplicationServiceClient(conn)

// List applications
apps, err := client.List(context.Background(), &applicationpkg.ApplicationQuery{
    Projects: []string{"default"},
})
if err != nil {
    log.Fatal(err)
}

// Get a specific application
app, err := client.Get(context.Background(), &applicationpkg.ApplicationQuery{
    Name: "my-app",
})
if err != nil {
    log.Fatal(err)
}

// Sync an application
syncReq := &applicationpkg.ApplicationSyncRequest{
    Name: "my-app",
    Prune: true,
}
app, err = client.Sync(context.Background(), syncReq)
if err != nil {
    log.Fatal(err)
}
```
