# Creates repository certificates on the server

`POST /api/v1/certificates`

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) - Whether to upsert already existing certificates.
  Type: boolean

Request body: application/json (required)

List of certificates to be created

Type: object

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

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

- `metadata` (optional)
  Reference: [v1ListMeta](https://sourcey-argocd.pages.dev/api/models/v1listmeta/index.md); Type: object
  
  ListMeta describes metadata that synthetic resources must have, including lists and
  various status objects. A resource may have only one of {ObjectMeta, ListMeta}.

Responses:

- 200: A successful response.

Content type: application/json

Type: object

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

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

- `metadata` (optional)
  Reference: [v1ListMeta](https://sourcey-argocd.pages.dev/api/models/v1listmeta/index.md); Type: object
  
  ListMeta describes metadata that synthetic resources must have, including lists and
  various status objects. A resource may have only one of {ObjectMeta, ListMeta}.

- 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/certificates' \
  -H 'Authorization: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "items": [
    {
      "certData": "dGVzdA==",
      "certInfo": "string",
      "certSubType": "string",
      "certType": "string",
      "serverName": "string"
    }
  ],
  "metadata": {
    "continue": "string",
    "remainingItemCount": 0,
    "resourceVersion": "string",
    "selfLink": "string",
    "shardInfo": {
      "selector": "string"
    }
  }
}'
```

### JavaScript

```javascript
const body = `{
  "items": [
    {
      "certData": "dGVzdA==",
      "certInfo": "string",
      "certSubType": "string",
      "certType": "string",
      "serverName": "string"
    }
  ],
  "metadata": {
    "continue": "string",
    "remainingItemCount": 0,
    "resourceVersion": "string",
    "selfLink": "string",
    "shardInfo": {
      "selector": "string"
    }
  }
}`;

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

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

### Python

```python
import requests

body = '''{
  "items": [
    {
      "certData": "dGVzdA==",
      "certInfo": "string",
      "certSubType": "string",
      "certType": "string",
      "serverName": "string"
    }
  ],
  "metadata": {
    "continue": "string",
    "remainingItemCount": 0,
    "resourceVersion": "string",
    "selfLink": "string",
    "shardInfo": {
      "selector": "string"
    }
  }
}'''

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