# Sync syncs an application to its target state

`POST /api/v1/applications/{name}/sync`

Authentication (security requirement alternatives):

```json
[
  {
    "bearer": []
  }
]
```

- bearer: apiKey, header Authorization. A token sent as `Authorization: Bearer <token>`. [API Docs](https://sourcey-argocd.pages.dev/developer-guide/api-docs/index.md#authorization) shows how to get one.

Parameters:

- `name` (path, string, required)
  Type: string

Request body: application/json (required)

Type: object

Schema: [applicationApplicationSyncRequest](https://sourcey-argocd.pages.dev/api/models/applicationapplicationsyncrequest/index.md)

- `appNamespace` (optional)
  Type: string

- `dryRun` (optional)
  Type: boolean

- `infos` (optional)
  Type: array
  
  Items:
    Reference: [v1alpha1Info](https://sourcey-argocd.pages.dev/api/models/v1alpha1info/index.md); Type: object

- `manifests` (optional)
  Type: array
  
  Items:
    Type: string

- `name` (optional)
  Type: string

- `project` (optional)
  Type: string

- `prune` (optional)
  Type: boolean

- `resources` (optional)
  Type: array
  
  Items:
    Reference: [v1alpha1SyncOperationResource](https://sourcey-argocd.pages.dev/api/models/v1alpha1syncoperationresource/index.md); Type: object
    
    SyncOperationResource contains resources to sync.

- `retryStrategy` (optional)
  Reference: [v1alpha1RetryStrategy](https://sourcey-argocd.pages.dev/api/models/v1alpha1retrystrategy/index.md); Type: object

- `revision` (optional)
  Type: string

- `revisions` (optional)
  Type: array
  
  Items:
    Type: string

- `sourcePositions` (optional)
  Type: array
  
  Items:
    Type: string, int64

- `strategy` (optional)
  Reference: [v1alpha1SyncStrategy](https://sourcey-argocd.pages.dev/api/models/v1alpha1syncstrategy/index.md); Type: object

- `syncOptions` (optional)
  Reference: [applicationSyncOptions](https://sourcey-argocd.pages.dev/api/models/applicationsyncoptions/index.md); Type: object

Responses:

- 200: A successful response.

Content type: application/json

Type: object

Schema: [v1alpha1Application](https://sourcey-argocd.pages.dev/api/models/v1alpha1application/index.md)

- `metadata` (optional)
  Reference: [v1ObjectMeta](https://sourcey-argocd.pages.dev/api/models/v1objectmeta/index.md); Type: object
  
  ObjectMeta is metadata that all persisted resources must have, which includes all objects
  users must create.

- `operation` (optional)
  Reference: [v1alpha1Operation](https://sourcey-argocd.pages.dev/api/models/v1alpha1operation/index.md); Type: object

- `spec` (optional)
  Reference: [v1alpha1ApplicationSpec](https://sourcey-argocd.pages.dev/api/models/v1alpha1applicationspec/index.md); Type: object
  
  ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision.

- `status` (optional)
  Reference: [v1alpha1ApplicationStatus](https://sourcey-argocd.pages.dev/api/models/v1alpha1applicationstatus/index.md); Type: object

- default: An unexpected error response.

Content type: application/json

Type: object

Schema: [runtimeError](https://sourcey-argocd.pages.dev/api/models/runtimeerror/index.md)

- `code` (optional)
  Type: integer, int32

- `details` (optional)
  Type: array
  
  Items:
    Reference: [protobufAny](https://sourcey-argocd.pages.dev/api/models/protobufany/index.md); Type: object

- `error` (optional)
  Type: string

- `message` (optional)
  Type: string

## Examples

### cURL

```bash
curl -X POST 'https://argocd.example.com/api/v1/applications/string/sync' \
  -H 'Authorization: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "appNamespace": "string",
  "dryRun": true,
  "infos": [
    {
      "name": "string",
      "value": "string"
    }
  ],
  "manifests": [
    "string"
  ],
  "name": "string",
  "project": "string",
  "prune": true,
  "resources": [
    {
      "group": "string",
      "kind": "string",
      "name": "string",
      "namespace": "string"
    }
  ],
  "retryStrategy": {
    "backoff": {
      "duration": "string",
      "factor": 0,
      "maxDuration": "string"
    },
    "limit": 0,
    "refresh": true
  },
  "revision": "string",
  "revisions": [
    "string"
  ],
  "sourcePositions": [
    "string"
  ],
  "strategy": {
    "apply": {
      "force": true
    },
    "hook": {
      "syncStrategyApply": {
        "force": true
      }
    }
  },
  "syncOptions": {
    "items": [
      "string"
    ]
  }
}'
```

### JavaScript

```javascript
const body = `{
  "appNamespace": "string",
  "dryRun": true,
  "infos": [
    {
      "name": "string",
      "value": "string"
    }
  ],
  "manifests": [
    "string"
  ],
  "name": "string",
  "project": "string",
  "prune": true,
  "resources": [
    {
      "group": "string",
      "kind": "string",
      "name": "string",
      "namespace": "string"
    }
  ],
  "retryStrategy": {
    "backoff": {
      "duration": "string",
      "factor": 0,
      "maxDuration": "string"
    },
    "limit": 0,
    "refresh": true
  },
  "revision": "string",
  "revisions": [
    "string"
  ],
  "sourcePositions": [
    "string"
  ],
  "strategy": {
    "apply": {
      "force": true
    },
    "hook": {
      "syncStrategyApply": {
        "force": true
      }
    }
  },
  "syncOptions": {
    "items": [
      "string"
    ]
  }
}`;

const response = await fetch('https://argocd.example.com/api/v1/applications/string/sync', {
  method: 'POST',
  headers: {
    'Authorization': 'YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "appNamespace": "string",
  "dryRun": true,
  "infos": [
    {
      "name": "string",
      "value": "string"
    }
  ],
  "manifests": [
    "string"
  ],
  "name": "string",
  "project": "string",
  "prune": true,
  "resources": [
    {
      "group": "string",
      "kind": "string",
      "name": "string",
      "namespace": "string"
    }
  ],
  "retryStrategy": {
    "backoff": {
      "duration": "string",
      "factor": 0,
      "maxDuration": "string"
    },
    "limit": 0,
    "refresh": true
  },
  "revision": "string",
  "revisions": [
    "string"
  ],
  "sourcePositions": [
    "string"
  ],
  "strategy": {
    "apply": {
      "force": true
    },
    "hook": {
      "syncStrategyApply": {
        "force": true
      }
    }
  },
  "syncOptions": {
    "items": [
      "string"
    ]
  }
}'''

response = requests.post(
    'https://argocd.example.com/api/v1/applications/string/sync',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
