# Config

The `/api/v3/config` endpoints allow you to inspect, modify, and reload the configuration of the datarhei Core.

## Read

Retrieve the currently active Core configuration with additionally a list of all fields that have an override by an environment variable. Such fields can be changed, but it will have no effect because the enviroment variable will always override the value.

Example:

{% tabs %}
{% tab title="Curl" %}

```bash
curl http://127.0.0.1:8080/api/v3/config \
   -H 'accept: application/json' \
   -H 'Content-Type: application/json' \
   -X GET
```

{% endtab %}

{% tab title="PyClient" %}

```python
from core_client import Client

client = Client(base_url="http://127.0.0.1:8080")
client.login()

core_config = client.v3_config_get()
print(core_config)
```

{% endtab %}

{% tab title="GoClient" %}

```go
import (
    "github.com/datarhei/core-client-go/v16"
    "github.com/datarhei/core-client-go/v16/api"
)

client, _ := coreclient.New(coreclient.Config{
    Address: "https://127.0.0.1:8080",
})

version, config, err := client.Config()
```

The actual config is in `config.Config` which is an `interface{}` type. Depending on the returned version, you have to cast it to the corresponding type in order to access the fields in the config:

```go
if version == 1 {
    configv1 := config.Config.(api.ConfigV1)
} else if version == 2 {
    configv2 := config.Config.(api.ConfigV2)
} else if version == 3 {
    configv3 := config.Config.(api.ConfigV3)
}
```

{% endtab %}
{% endtabs %}

Description:

{% openapi src="<https://951110271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQRvnKSkK1SsZB0HeYhh%2Fuploads%2F3duUHhkhwH69BGLlHYga%2Fdoc.json?alt=media&token=dcd2b063-c826-4652-9a98-c265ec41a469>" path="/api/v3/config" method="get" %}
[doc.json](https://951110271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQRvnKSkK1SsZB0HeYhh%2Fuploads%2F3duUHhkhwH69BGLlHYga%2Fdoc.json?alt=media\&token=dcd2b063-c826-4652-9a98-c265ec41a469)
{% endopenapi %}

## Update

Upload a modified configuration. You can provide a partial configuration with only the fields you want to change. The minimal valid configuration you have to provide contains the version number:

```json
{
    "version": 3
}
```

Example:

{% tabs %}
{% tab title="Curl" %}

```bash
curl http://127.0.0.1:8080/api/v3/config \
   -H 'accept: application/json' \
   -H 'Content-Type: application/json' \
   -X PUT \
   -d '{
         "version": 3,
         "name": "core-1",
         "log": {
            "level": "debug"
         }
      }'
```

{% endtab %}

{% tab title="PyClient" %}

```python
from core_client import Client

client = Client(base_url="http://127.0.0.1:8080")
client.login()

client.v3_config_put(config: {
   "version": 3,
   "name": "core-1",
   "log": {
      "level": "debug"
   }
})
```

{% endtab %}

{% tab title="GoClient" %}

```go
import (
    "github.com/datarhei/core-client-go/v16"
)

client, _ := coreclient.New(coreclient.Config{
    Address: "https://127.0.0.1:8080",
})

type cfg struct{
    Version int64 `json:"version"`
    Name string `json:"name"`
    Log struct{
        Level string `json:"level"`
    } `json:"log"`
}

var config = &cfg{
    Version: 3,
    Name: "core-1",
}
config.Log.Level = "debug"

err := client.ConfigSet(config)
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
This has no effect until the configuration is reloaded.
{% endhint %}

Description:

{% openapi src="<https://951110271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQRvnKSkK1SsZB0HeYhh%2Fuploads%2F3duUHhkhwH69BGLlHYga%2Fdoc.json?alt=media&token=dcd2b063-c826-4652-9a98-c265ec41a469>" path="/api/v3/config" method="put" %}
[doc.json](https://951110271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQRvnKSkK1SsZB0HeYhh%2Fuploads%2F3duUHhkhwH69BGLlHYga%2Fdoc.json?alt=media\&token=dcd2b063-c826-4652-9a98-c265ec41a469)
{% endopenapi %}

## Reload

After changing the configuration, the datarhei Core has to be restarted in order to reload the changed configuration.

Example:

{% tabs %}
{% tab title="Curl" %}

```bash
curl http://127.0.0.1:8080/api/v3/config/reload \
   -H 'accept: application/json' \
   -H 'Content-Type: application/json' \
   -X GET
```

{% endtab %}

{% tab title="PyClient" %}

```python
from core_client import Client

client = Client(base_url="http://127.0.0.1:8080")
client.login()

client.v3_config_reload()
```

{% endtab %}

{% tab title="GoClient" %}

```go
import (
    "github.com/datarhei/core-client-go/v16"
)

client, _ := coreclient.New(coreclient.Config{
    Address: "https://127.0.0.1:8080",
})

err := client.ConfigReload()
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
**Configuration reload will restart the Core!**\
The in-memory file system and sessions will remain intact.
{% endhint %}

Description:

{% openapi src="<https://951110271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQRvnKSkK1SsZB0HeYhh%2Fuploads%2FtNYJCg6GDZV2tOUcjzOt%2Fdoc-16.12.0.json?alt=media&token=ca0f4565-35e8-4e2c-97a6-10346f96231b>" path="/api/v3/config/reload" method="get" %}
[doc-16.12.0.json](https://951110271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQRvnKSkK1SsZB0HeYhh%2Fuploads%2FtNYJCg6GDZV2tOUcjzOt%2Fdoc-16.12.0.json?alt=media\&token=ca0f4565-35e8-4e2c-97a6-10346f96231b)
{% endopenapi %}

## Configuration

Complete config example:

```json
{
    "version": 3,
    "id": "03a1d1af-b947-4a13-a169-d3f2238714ee",
    "name": "super-core-1337",
    "address": ":8080",
    "update_check": true,
    "log": {
        "level": "info",
        "topics": [],
        "max_lines": 1000
    },
    "db": {
        "dir": "/core/config"
    },
    "host": {
        "name": [
            "example.com"
        ],
        "auto": true
    },
    "api": {
        "read_only": false,
        "access": {
            "http": {
                "allow": [],
                "block": []
            },
            "https": {
                "allow": [],
                "block": []
            }
        },
        "auth": {
            "enable": true,
            "disable_localhost": false,
            "username": "admin",
            "password": "datarhei",
            "jwt": {
                "secret": "cz$L%a(d%%[lLh;Y8dahIjcQx+tBq(%5"
            },
            "auth0": {
                "enable": false,
                "tenants": []
            }
        }
    },
    "tls": {
        "address": ":8181",
        "enable": true,
        "auto": true,
        "email": "cert@example.com",
        "cert_file": "",
        "key_file": ""
    },
    "storage": {
        "disk": {
            "dir": "/core/data",
            "max_size_mbytes": 50000,
            "cache": {
                "enable": true,
                "max_size_mbytes": 500,
                "ttl_seconds": 300,
                "max_file_size_mbytes": 1,
                "types": {
                    "allow": [],
                    "block": [
                        ".m3u8",
                        ".mpd"
                    ]
                }
            }
        },
        "memory": {
            "auth": {
                "enable": true,
                "username": "admin",
                "password": "WH8y3alD7pHGsuBGwb"
            },
            "max_size_mbytes": 2000,
            "purge": true
        },
        "s3": [],
        "cors": {
            "origins": [
                "*"
            ]
        },
        "mimetypes_file": "./mime.types"
    },
    "rtmp": {
        "enable": true,
        "enable_tls": true,
        "address": ":1935",
        "address_tls": ":1936",
        "app": "/",
        "token": "n4jk235nNJKN4k5n24k"
    },
    "srt": {
        "enable": true,
        "address": ":6000",
        "passphrase": "n23jk4DD5DOAn5jk4DSS",
        "token": "",
        "log": {
            "enable": false,
            "topics": []
        }
    },
    "ffmpeg": {
        "binary": "ffmpeg",
        "max_processes": 0,
        "access": {
            "input": {
                "allow": [],
                "block": []
            },
            "output": {
                "allow": [],
                "block": []
            }
        },
        "log": {
            "max_lines": 50,
            "max_history": 3
        }
    },
    "playout": {
        "enable": false,
        "min_port": 0,
        "max_port": 0
    },
    "debug": {
        "profiling": false,
        "force_gc": 0
    },
    "metrics": {
        "enable": false,
        "enable_prometheus": false,
        "range_sec": 300,
        "interval_sec": 2
    },
    "sessions": {
        "enable": true,
        "ip_ignorelist": [
            "127.0.0.1/32",
            "::1/128"
        ],
        "session_timeout_sec": 30,
        "persist": true,
        "persist_interval_sec": 300,
        "max_bitrate_mbit": 250,
        "max_sessions": 50
    },
    "service": {
        "enable": false,
        "token": "",
        "url": "https://service.datarhei.com"
    },
    "router": {
        "blocked_prefixes": [
            "/api"
        ],
        "routes": {},
        "ui_path": "/core/ui"
    }
}
```

{% hint style="info" %}
**Required fields:** version
{% endhint %}

### Descriptions

{% content-ref url="../configuration" %}
[configuration](https://docs.datarhei.com/core/configuration)
{% endcontent-ref %}
