# Create creates a cluster

`POST /api/v1/clusters`

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:

- `upsert` (query, boolean, optional)
  Type: boolean

Request body: application/json (required)

Type: object

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

- `annotations` (optional)
  Type: object
  
  Additional properties: 
    Type: string

- `clusterResources` (optional)
  Type: boolean
  
  Indicates if cluster level resources should be managed. This setting is used only if cluster is connected in a namespaced mode.

- `config` (optional)
  Reference: [v1alpha1ClusterConfig](https://sourcey-argocd.pages.dev/api/models/v1alpha1clusterconfig/index.md); Type: object
  
  ClusterConfig is the configuration attributes. This structure is subset of the go-client
  rest.Config with annotations added for marshalling.

- `configHash` (optional)
  Type: string, uint64

- `connectionState` (optional)
  Reference: [v1alpha1ConnectionState](https://sourcey-argocd.pages.dev/api/models/v1alpha1connectionstate/index.md); Type: object

- `info` (optional)
  Reference: [v1alpha1ClusterInfo](https://sourcey-argocd.pages.dev/api/models/v1alpha1clusterinfo/index.md); Type: object

- `labels` (optional)
  Type: object
  
  Additional properties: 
    Type: string

- `name` (optional)
  Type: string

- `namespaces` (optional)
  Type: array
  
  Holds list of namespaces which are accessible in that cluster. Cluster level resources will be ignored if namespace list is not empty.
  
  Items:
    Type: string

- `project` (optional)
  Type: string

- `refreshRequestedAt` (optional)
  Reference: [v1Time](https://sourcey-argocd.pages.dev/api/models/v1time/index.md); Type: string, date-time
  
  Time is a wrapper around time.Time which supports correct
  marshaling to YAML and JSON.  Wrappers are provided for many
  of the factory methods that the time package offers.
  
  +protobuf.options.marshal=false
  +protobuf.as=Timestamp
  +protobuf.options.(gogoproto.goproto_stringer)=false

- `server` (optional)
  Type: string

- `serverVersion` (optional)
  Type: string

- `shard` (optional)
  Type: integer, int64
  
  Shard contains optional shard number. Calculated on the fly by the application controller if not specified.

Responses:

- 200: A successful response.

Content type: application/json

Type: object

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

- `annotations` (optional)
  Type: object
  
  Additional properties: 
    Type: string

- `clusterResources` (optional)
  Type: boolean
  
  Indicates if cluster level resources should be managed. This setting is used only if cluster is connected in a namespaced mode.

- `config` (optional)
  Reference: [v1alpha1ClusterConfig](https://sourcey-argocd.pages.dev/api/models/v1alpha1clusterconfig/index.md); Type: object
  
  ClusterConfig is the configuration attributes. This structure is subset of the go-client
  rest.Config with annotations added for marshalling.

- `configHash` (optional)
  Type: string, uint64

- `connectionState` (optional)
  Reference: [v1alpha1ConnectionState](https://sourcey-argocd.pages.dev/api/models/v1alpha1connectionstate/index.md); Type: object

- `info` (optional)
  Reference: [v1alpha1ClusterInfo](https://sourcey-argocd.pages.dev/api/models/v1alpha1clusterinfo/index.md); Type: object

- `labels` (optional)
  Type: object
  
  Additional properties: 
    Type: string

- `name` (optional)
  Type: string

- `namespaces` (optional)
  Type: array
  
  Holds list of namespaces which are accessible in that cluster. Cluster level resources will be ignored if namespace list is not empty.
  
  Items:
    Type: string

- `project` (optional)
  Type: string

- `refreshRequestedAt` (optional)
  Reference: [v1Time](https://sourcey-argocd.pages.dev/api/models/v1time/index.md); Type: string, date-time
  
  Time is a wrapper around time.Time which supports correct
  marshaling to YAML and JSON.  Wrappers are provided for many
  of the factory methods that the time package offers.
  
  +protobuf.options.marshal=false
  +protobuf.as=Timestamp
  +protobuf.options.(gogoproto.goproto_stringer)=false

- `server` (optional)
  Type: string

- `serverVersion` (optional)
  Type: string

- `shard` (optional)
  Type: integer, int64
  
  Shard contains optional shard number. Calculated on the fly by the application controller if not specified.

- 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/clusters' \
  -H 'Authorization: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "annotations": {},
  "clusterResources": true,
  "config": {
    "awsAuthConfig": {
      "clusterName": "string",
      "profile": "string",
      "roleARN": "string"
    },
    "bearerToken": "string",
    "burst": 0,
    "disableCompression": true,
    "execProviderConfig": {
      "apiVersion": "string",
      "args": [
        "string"
      ],
      "command": "string",
      "config": {
        "raw": "dGVzdA=="
      },
      "env": {},
      "installHint": "string",
      "provideClusterInfo": true
    },
    "password": "string",
    "proxyUrl": "string",
    "qps": 0,
    "tlsClientConfig": {
      "caData": "dGVzdA==",
      "certData": "dGVzdA==",
      "insecure": true,
      "keyData": "dGVzdA==",
      "serverName": "string"
    },
    "username": "string"
  },
  "configHash": "string",
  "connectionState": {
    "attemptedAt": "2024-01-15T09:30:00Z",
    "message": "string",
    "status": "string"
  },
  "info": {
    "apiVersions": [
      "string"
    ],
    "applicationsCount": 0,
    "cacheInfo": {
      "apisCount": 0,
      "lastCacheSyncTime": "2024-01-15T09:30:00Z",
      "resourcesCount": 0
    },
    "connectionState": {
      "attemptedAt": "2024-01-15T09:30:00Z",
      "message": "string",
      "status": "string"
    },
    "serverVersion": "string"
  },
  "labels": {},
  "name": "string",
  "namespaces": [
    "string"
  ],
  "project": "string",
  "refreshRequestedAt": "2024-01-15T09:30:00Z",
  "server": "string",
  "serverVersion": "string",
  "shard": 0
}'
```

### JavaScript

```javascript
const body = `{
  "annotations": {},
  "clusterResources": true,
  "config": {
    "awsAuthConfig": {
      "clusterName": "string",
      "profile": "string",
      "roleARN": "string"
    },
    "bearerToken": "string",
    "burst": 0,
    "disableCompression": true,
    "execProviderConfig": {
      "apiVersion": "string",
      "args": [
        "string"
      ],
      "command": "string",
      "config": {
        "raw": "dGVzdA=="
      },
      "env": {},
      "installHint": "string",
      "provideClusterInfo": true
    },
    "password": "string",
    "proxyUrl": "string",
    "qps": 0,
    "tlsClientConfig": {
      "caData": "dGVzdA==",
      "certData": "dGVzdA==",
      "insecure": true,
      "keyData": "dGVzdA==",
      "serverName": "string"
    },
    "username": "string"
  },
  "configHash": "string",
  "connectionState": {
    "attemptedAt": "2024-01-15T09:30:00Z",
    "message": "string",
    "status": "string"
  },
  "info": {
    "apiVersions": [
      "string"
    ],
    "applicationsCount": 0,
    "cacheInfo": {
      "apisCount": 0,
      "lastCacheSyncTime": "2024-01-15T09:30:00Z",
      "resourcesCount": 0
    },
    "connectionState": {
      "attemptedAt": "2024-01-15T09:30:00Z",
      "message": "string",
      "status": "string"
    },
    "serverVersion": "string"
  },
  "labels": {},
  "name": "string",
  "namespaces": [
    "string"
  ],
  "project": "string",
  "refreshRequestedAt": "2024-01-15T09:30:00Z",
  "server": "string",
  "serverVersion": "string",
  "shard": 0
}`;

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

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

### Python

```python
import requests

body = '''{
  "annotations": {},
  "clusterResources": true,
  "config": {
    "awsAuthConfig": {
      "clusterName": "string",
      "profile": "string",
      "roleARN": "string"
    },
    "bearerToken": "string",
    "burst": 0,
    "disableCompression": true,
    "execProviderConfig": {
      "apiVersion": "string",
      "args": [
        "string"
      ],
      "command": "string",
      "config": {
        "raw": "dGVzdA=="
      },
      "env": {},
      "installHint": "string",
      "provideClusterInfo": true
    },
    "password": "string",
    "proxyUrl": "string",
    "qps": 0,
    "tlsClientConfig": {
      "caData": "dGVzdA==",
      "certData": "dGVzdA==",
      "insecure": true,
      "keyData": "dGVzdA==",
      "serverName": "string"
    },
    "username": "string"
  },
  "configHash": "string",
  "connectionState": {
    "attemptedAt": "2024-01-15T09:30:00Z",
    "message": "string",
    "status": "string"
  },
  "info": {
    "apiVersions": [
      "string"
    ],
    "applicationsCount": 0,
    "cacheInfo": {
      "apisCount": 0,
      "lastCacheSyncTime": "2024-01-15T09:30:00Z",
      "resourcesCount": 0
    },
    "connectionState": {
      "attemptedAt": "2024-01-15T09:30:00Z",
      "message": "string",
      "status": "string"
    },
    "serverVersion": "string"
  },
  "labels": {},
  "name": "string",
  "namespaces": [
    "string"
  ],
  "project": "string",
  "refreshRequestedAt": "2024-01-15T09:30:00Z",
  "server": "string",
  "serverVersion": "string",
  "shard": 0
}'''

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