# Generate a new API key pair for a tenant.

`POST /api/tenant-api-key/generate-key-pair`

Authentication: no security requirement declared for this operation.

Request body: application/json (required)

Type: object

Schema: [GenerateApiKeyDTO](https://sourcey-gauzy.pages.dev/api-reference/models/generateapikeydto/index.md)

- `tenantId` (optional)
  Type: string, uuid
  
  The unique identifier of the tenant.

- `name` (optional)
  Type: string
  
  The name or label for the API key.

Responses:

- 201: API key pair generated successfully.

- 400: Invalid input data.

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/tenant-api-key/generate-key-pair' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "tenantId": "550e8400-e29b-41d4-a716-446655440000",
  "name": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "tenantId": "550e8400-e29b-41d4-a716-446655440000",
  "name": "string"
}`;

const response = await fetch('http://localhost:3000/api/tenant-api-key/generate-key-pair', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body,
});

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

### Python

```python
import requests

body = '''{
  "tenantId": "550e8400-e29b-41d4-a716-446655440000",
  "name": "string"
}'''

response = requests.post(
    'http://localhost:3000/api/tenant-api-key/generate-key-pair',
    data=body.encode('utf-8'),
    headers={
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
