## Set the License via Management UI

### Request

POST

/management/v2.0/system/license

### cURL

```bash
curl --request POST \
  --url https://api-trial.cognigy.ai/new/management/v2.0/system/license \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "licensekey": "<string>"
}
'
```

### Code Samples

#### Python

```python
import requests

url = "https://api-trial.cognigy.ai/new/management/v2.0/system/license"

payload = { "licensekey": "<string>" }
headers = {
    "Authorization": "Basic <encoded-value>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

#### JavaScript (Fetch)

```javascript
const options = {
  method: 'POST',
  headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
  body: JSON.stringify({licensekey: '<string>'})
};

fetch('https://api-trial.cognigy.ai/new/management/v2.0/system/license', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

#### PHP

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api-trial.cognigy.ai/new/management/v2.0/system/license",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'licensekey' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Basic <encoded-value>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

#### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

url := "https://api-trial.cognigy.ai/new/management/v2.0/system/license"

payload := strings.NewReader("{\n  \"licensekey\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Basic <encoded-value>")
	req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

### Expected Responses

#### Success Response (202)
```json
{
  "message": "The new license was installed within the system."
}
```

#### Error Responses
- **400 Bad Request**  
  ```json
  {
    "type": "Bad Request",
    "title": "Bad Request Error",
    "status": 400,
    "detail": "Validation failed. Missing payload."
  }
  ```
- **401 Unauthorized**  
  ```json
  {
    "type": "Unauthorized",
    "title": "Unauthorized Error",
    "status": 401,
    "detail": "<string>"
  }
  ```
- **403 Forbidden**  
  ```json
  {
    "type": "Forbidden",
    "title": "Forbidden Error",
    "status": 403,
    "detail": "<string>"
  }
  ```

### Authorization

- `Authorization` header is required with Basic Authentication.
