# Create a new project

`POST /api/v1/projects`

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.

Request body: application/json (required)

Type: object

ProjectCreateRequest defines project creation parameters.

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

- `project` (optional)
  Reference: [v1alpha1AppProject](https://sourcey-argocd.pages.dev/api/models/v1alpha1appproject/index.md); Type: object

- `upsert` (optional)
  Type: boolean

Responses:

- 200: A successful response.

Content type: application/json

Type: object

Schema: [v1alpha1AppProject](https://sourcey-argocd.pages.dev/api/models/v1alpha1appproject/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.

- `spec` (optional)
  Reference: [v1alpha1AppProjectSpec](https://sourcey-argocd.pages.dev/api/models/v1alpha1appprojectspec/index.md); Type: object

- `status` (optional)
  Reference: [v1alpha1AppProjectStatus](https://sourcey-argocd.pages.dev/api/models/v1alpha1appprojectstatus/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/projects' \
  -H 'Authorization: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "project": {
    "metadata": {
      "annotations": {},
      "creationTimestamp": "2024-01-15T09:30:00Z",
      "deletionGracePeriodSeconds": 0,
      "deletionTimestamp": "2024-01-15T09:30:00Z",
      "finalizers": [
        "string"
      ],
      "generateName": "string",
      "generation": 0,
      "labels": {},
      "managedFields": [
        {
          "apiVersion": "string",
          "fieldsType": "string",
          "fieldsV1": {
            "Raw": "dGVzdA=="
          },
          "manager": "string",
          "operation": "string",
          "subresource": "string",
          "time": "2024-01-15T09:30:00Z"
        }
      ],
      "name": "string",
      "namespace": "string",
      "ownerReferences": [
        {
          "apiVersion": "string",
          "blockOwnerDeletion": true,
          "controller": true,
          "kind": "string",
          "name": "string",
          "uid": "string"
        }
      ],
      "resourceVersion": "string",
      "selfLink": "string",
      "uid": "string"
    },
    "spec": {
      "clusterResourceBlacklist": [
        {
          "group": "string",
          "kind": "string",
          "name": "string"
        }
      ],
      "clusterResourceWhitelist": [
        {
          "group": "string",
          "kind": "string",
          "name": "string"
        }
      ],
      "description": "string",
      "destinationServiceAccounts": [
        {
          "defaultServiceAccount": "string",
          "namespace": "string",
          "server": "string"
        }
      ],
      "destinations": [
        {
          "name": "string",
          "namespace": "string",
          "server": "string"
        }
      ],
      "namespaceResourceBlacklist": [
        {
          "group": "string",
          "kind": "string"
        }
      ],
      "namespaceResourceWhitelist": [
        {
          "group": "string",
          "kind": "string"
        }
      ],
      "orphanedResources": {
        "ignore": [
          {
            "group": "string",
            "kind": "string",
            "name": "string"
          }
        ],
        "warn": true
      },
      "permitOnlyProjectScopedClusters": true,
      "roles": [
        {
          "description": "string",
          "groups": [
            "string"
          ],
          "jwtTokens": [
            {
              "exp": 0,
              "iat": 0,
              "id": "string"
            }
          ],
          "name": "string",
          "policies": [
            "string"
          ]
        }
      ],
      "signatureKeys": [
        {
          "keyID": "string"
        }
      ],
      "sourceIntegrity": {
        "git": {
          "policies": [
            {
              "gpg": {
                "keys": [
                  "string"
                ],
                "mode": "string"
              },
              "repos": [
                {
                  "url": "string"
                }
              ]
            }
          ]
        }
      },
      "sourceNamespaces": [
        "string"
      ],
      "sourceRepos": [
        "string"
      ],
      "syncWindows": [
        {
          "andOperator": true,
          "applications": [
            "string"
          ],
          "clusters": [
            "string"
          ],
          "description": "string",
          "duration": "string",
          "kind": "string",
          "manualSync": true,
          "namespaces": [
            "string"
          ],
          "schedule": "string",
          "syncOverrun": true,
          "timeZone": "string"
        }
      ]
    },
    "status": {
      "jwtTokensByRole": {}
    }
  },
  "upsert": true
}'
```

### JavaScript

```javascript
const body = `{
  "project": {
    "metadata": {
      "annotations": {},
      "creationTimestamp": "2024-01-15T09:30:00Z",
      "deletionGracePeriodSeconds": 0,
      "deletionTimestamp": "2024-01-15T09:30:00Z",
      "finalizers": [
        "string"
      ],
      "generateName": "string",
      "generation": 0,
      "labels": {},
      "managedFields": [
        {
          "apiVersion": "string",
          "fieldsType": "string",
          "fieldsV1": {
            "Raw": "dGVzdA=="
          },
          "manager": "string",
          "operation": "string",
          "subresource": "string",
          "time": "2024-01-15T09:30:00Z"
        }
      ],
      "name": "string",
      "namespace": "string",
      "ownerReferences": [
        {
          "apiVersion": "string",
          "blockOwnerDeletion": true,
          "controller": true,
          "kind": "string",
          "name": "string",
          "uid": "string"
        }
      ],
      "resourceVersion": "string",
      "selfLink": "string",
      "uid": "string"
    },
    "spec": {
      "clusterResourceBlacklist": [
        {
          "group": "string",
          "kind": "string",
          "name": "string"
        }
      ],
      "clusterResourceWhitelist": [
        {
          "group": "string",
          "kind": "string",
          "name": "string"
        }
      ],
      "description": "string",
      "destinationServiceAccounts": [
        {
          "defaultServiceAccount": "string",
          "namespace": "string",
          "server": "string"
        }
      ],
      "destinations": [
        {
          "name": "string",
          "namespace": "string",
          "server": "string"
        }
      ],
      "namespaceResourceBlacklist": [
        {
          "group": "string",
          "kind": "string"
        }
      ],
      "namespaceResourceWhitelist": [
        {
          "group": "string",
          "kind": "string"
        }
      ],
      "orphanedResources": {
        "ignore": [
          {
            "group": "string",
            "kind": "string",
            "name": "string"
          }
        ],
        "warn": true
      },
      "permitOnlyProjectScopedClusters": true,
      "roles": [
        {
          "description": "string",
          "groups": [
            "string"
          ],
          "jwtTokens": [
            {
              "exp": 0,
              "iat": 0,
              "id": "string"
            }
          ],
          "name": "string",
          "policies": [
            "string"
          ]
        }
      ],
      "signatureKeys": [
        {
          "keyID": "string"
        }
      ],
      "sourceIntegrity": {
        "git": {
          "policies": [
            {
              "gpg": {
                "keys": [
                  "string"
                ],
                "mode": "string"
              },
              "repos": [
                {
                  "url": "string"
                }
              ]
            }
          ]
        }
      },
      "sourceNamespaces": [
        "string"
      ],
      "sourceRepos": [
        "string"
      ],
      "syncWindows": [
        {
          "andOperator": true,
          "applications": [
            "string"
          ],
          "clusters": [
            "string"
          ],
          "description": "string",
          "duration": "string",
          "kind": "string",
          "manualSync": true,
          "namespaces": [
            "string"
          ],
          "schedule": "string",
          "syncOverrun": true,
          "timeZone": "string"
        }
      ]
    },
    "status": {
      "jwtTokensByRole": {}
    }
  },
  "upsert": true
}`;

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

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

### Python

```python
import requests

body = '''{
  "project": {
    "metadata": {
      "annotations": {},
      "creationTimestamp": "2024-01-15T09:30:00Z",
      "deletionGracePeriodSeconds": 0,
      "deletionTimestamp": "2024-01-15T09:30:00Z",
      "finalizers": [
        "string"
      ],
      "generateName": "string",
      "generation": 0,
      "labels": {},
      "managedFields": [
        {
          "apiVersion": "string",
          "fieldsType": "string",
          "fieldsV1": {
            "Raw": "dGVzdA=="
          },
          "manager": "string",
          "operation": "string",
          "subresource": "string",
          "time": "2024-01-15T09:30:00Z"
        }
      ],
      "name": "string",
      "namespace": "string",
      "ownerReferences": [
        {
          "apiVersion": "string",
          "blockOwnerDeletion": true,
          "controller": true,
          "kind": "string",
          "name": "string",
          "uid": "string"
        }
      ],
      "resourceVersion": "string",
      "selfLink": "string",
      "uid": "string"
    },
    "spec": {
      "clusterResourceBlacklist": [
        {
          "group": "string",
          "kind": "string",
          "name": "string"
        }
      ],
      "clusterResourceWhitelist": [
        {
          "group": "string",
          "kind": "string",
          "name": "string"
        }
      ],
      "description": "string",
      "destinationServiceAccounts": [
        {
          "defaultServiceAccount": "string",
          "namespace": "string",
          "server": "string"
        }
      ],
      "destinations": [
        {
          "name": "string",
          "namespace": "string",
          "server": "string"
        }
      ],
      "namespaceResourceBlacklist": [
        {
          "group": "string",
          "kind": "string"
        }
      ],
      "namespaceResourceWhitelist": [
        {
          "group": "string",
          "kind": "string"
        }
      ],
      "orphanedResources": {
        "ignore": [
          {
            "group": "string",
            "kind": "string",
            "name": "string"
          }
        ],
        "warn": true
      },
      "permitOnlyProjectScopedClusters": true,
      "roles": [
        {
          "description": "string",
          "groups": [
            "string"
          ],
          "jwtTokens": [
            {
              "exp": 0,
              "iat": 0,
              "id": "string"
            }
          ],
          "name": "string",
          "policies": [
            "string"
          ]
        }
      ],
      "signatureKeys": [
        {
          "keyID": "string"
        }
      ],
      "sourceIntegrity": {
        "git": {
          "policies": [
            {
              "gpg": {
                "keys": [
                  "string"
                ],
                "mode": "string"
              },
              "repos": [
                {
                  "url": "string"
                }
              ]
            }
          ]
        }
      },
      "sourceNamespaces": [
        "string"
      ],
      "sourceRepos": [
        "string"
      ],
      "syncWindows": [
        {
          "andOperator": true,
          "applications": [
            "string"
          ],
          "clusters": [
            "string"
          ],
          "description": "string",
          "duration": "string",
          "kind": "string",
          "manualSync": true,
          "namespaces": [
            "string"
          ],
          "schedule": "string",
          "syncOverrun": true,
          "timeZone": "string"
        }
      ]
    },
    "status": {
      "jwtTokensByRole": {}
    }
  },
  "upsert": true
}'''

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