# Create a metrics config

> Source: https://docs.clonepartner.com/api-reference/metrics/create-metrics-config/

`POST /api/metrics/config`

Create a metrics config

**Operation ID:** `createMetricsConfig`

## Authentication

### Option 1

- **BearerAuth** (`http bearer`)
  API key token. Create via POST /api/api-keys. Format: `envoy_<hex>`

### Option 2

- **CookieAuth** (`apiKey`)
  Session cookie set after login + TOTP verification

## Request body

The request body is required.

### `application/json`

- Type: `object`
- Properties:
  - `backend` (`string`, `required`) — Metrics backend type (e.g. 'sqlite')
  - `config` (`object`, `required`)
    - Additional properties: allowed
  - `enabled` (`boolean`)
    - Default: `true`

## Success responses

### 201

Config created

**Content type:** `application/json`

- Type: `object`

## Examples

### cURL

```bash
curl --request POST \
  --url 'https://your-envoy.example.com/api/metrics/config' \
  --header 'Authorization: Bearer $API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "backend": "string",
  "config": {}
}'
```

### JavaScript (fetch)

```javascript
const response = await fetch('https://your-envoy.example.com/api/metrics/config', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "backend": "string",
    "config": {}
  }),
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);
```
