# Create one or more GPG public keys in the server's configuration

`POST /api/v1/gpgkeys`

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 public keys.
  Type: boolean

Request body: application/json (required)

Raw key data of the GPG key(s) to create

Type: object

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

- `fingerprint` (optional)
  Type: string

- `keyData` (optional)
  Type: string

- `keyID` (optional)
  Type: string

- `owner` (optional)
  Type: string

- `subType` (optional)
  Type: string

- `trust` (optional)
  Type: string

Responses:

- 200: A successful response.

Content type: application/json

Type: object

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

- `created` (optional)
  Reference: [v1alpha1GnuPGPublicKeyList](https://sourcey-argocd.pages.dev/api/models/v1alpha1gnupgpublickeylist/index.md); Type: object

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

- 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/gpgkeys' \
  -H 'Authorization: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "fingerprint": "string",
  "keyData": "string",
  "keyID": "string",
  "owner": "string",
  "subType": "string",
  "trust": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "fingerprint": "string",
  "keyData": "string",
  "keyID": "string",
  "owner": "string",
  "subType": "string",
  "trust": "string"
}`;

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

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

### Python

```python
import requests

body = '''{
  "fingerprint": "string",
  "keyData": "string",
  "keyID": "string",
  "owner": "string",
  "subType": "string",
  "trust": "string"
}'''

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