Config editing
Read config files, bulk edit values, replace a file and reload, safely.
The API edits the config files of the server it runs on, then reloads them with the same code as /md reload. Every edit is checked first and written atomically. All config endpoints need the admin scope, except the file list, which needs read.
Which settings reload and which need a restart is the same as for /md reload. See Reload vs restart. The API does not restart anything.
What can be edited
Every .yml file under plugins/MineDuels/, up to three folders deep, for example config.yml, messages.yml, matchmaking.yml, kits/<name>.yml, ranks/_default.yml, guis/duel-menu.yml.
Never listed and never editable:
| Excluded | Why |
|---|---|
webapi.yml | Holds the API keys and the listener settings |
backups/ | Backup copies |
arenas/ | Arena templates written by the arena tools |
instances.yml, locations.yml, holograms.yml, editor-room.yml, tournament-cooldowns.yml | State the plugin writes while it runs |
Any path with .., an absolute path, or a symlink leading outside the folder | Path safety |
Secrets in database.yml are hidden and locked:
| Key | Read | Edit |
|---|---|---|
storage.mysql.password, cross-server.redis.password, cross-server.secret | shown as *** | refused |
storage.* | shown | refused |
cross-server.enabled, server-name, role, proxy-server-name, proxy, redis.* | shown | refused |
Every other key of database.yml, for example cross-server.global-chat or cross-server.limits.chat | shown | allowed |
PUT /config/database.yml is refused as a whole. Change single keys with PATCH /config.
GET /config
The list of editable files. Needs read.
curl -s -H "Authorization: Bearer $MD_KEY" "$MD_URL/config"{
"ok": true,
"data": [
{ "file": "config.yml", "bytes": 5120, "modified": 1767225000000, "protectedKeys": [] },
{ "file": "database.yml", "bytes": 2210, "modified": 1767225000000,
"protectedKeys": ["cross-server.redis.password", "cross-server.secret", "storage.mysql.password"] },
{ "file": "guis/duel-menu.yml", "bytes": 1800, "modified": 1767224000000, "protectedKeys": [] },
{ "file": "matchmaking.yml", "bytes": 4100, "modified": 1767225000000, "protectedKeys": [] },
{ "file": "ranks/_default.yml", "bytes": 2600, "modified": 1767224000000, "protectedKeys": [] }
]
}GET /config/:file
One file. Needs admin.
curl -s -H "Authorization: Bearer $ADMIN_KEY" "$MD_URL/config/matchmaking.yml"{
"ok": true,
"data": {
"file": "matchmaking.yml",
"content": "config-version: 3\nleaderboard:\n size: 10\n ...",
"values": {
"config-version": 3,
"leaderboard.size": 10,
"queue.tick-interval": 10,
"queue.ranked.initial-range": 50,
"queue.ranked.max-range": 400,
"duel.rounds": [1, 3, 5],
"history.keep-days": 30,
"history.max-matches": 100000,
"leaderboard.overall-min-games": 10
}
}
}content is the YAML text and values is the same data flattened to dotted paths, which is what PATCH uses. Subfolders go in the path: GET /config/ranks/_default.yml.
A file that does not exist or is not editable gives 404.
PATCH /config
Change several values, in one or more files, in one request. This is the bulk edit.
Body:
{
"dryRun": false,
"changes": [
{ "file": "matchmaking.yml", "path": "history.keep-days", "value": 60 },
{ "file": "matchmaking.yml", "path": "leaderboard.overall-min-games", "value": 20 },
{ "file": "database.yml", "path": "cross-server.global-chat", "value": true },
{ "file": "ranks/_default.yml", "path": "elo.k-factor", "value": 24 }
]
}| Field | Meaning |
|---|---|
dryRun | true checks everything and writes nothing. Default false |
changes | 1 to 200 items |
changes[].file | The file, for example matchmaking.yml or ranks/_default.yml |
changes[].path | The dotted path of the setting |
changes[].value | A boolean, a number, a string, or a list of those |
changes[].create | true to add a setting that does not exist yet. Default false |
curl -s -X PATCH -H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \
-d @changes.json "$MD_URL/config"{
"ok": true,
"data": {
"applied": true,
"changes": [
{ "file": "matchmaking.yml", "path": "history.keep-days", "old": 30, "new": 60 },
{ "file": "matchmaking.yml", "path": "leaderboard.overall-min-games", "old": 10, "new": 20 },
{ "file": "database.yml", "path": "cross-server.global-chat", "old": false, "new": true },
{ "file": "ranks/_default.yml", "path": "elo.k-factor", "old": 32, "new": 24 }
],
"files": ["matchmaking.yml", "database.yml", "ranks/_default.yml"],
"reloaded": true,
"warnings": []
}
}old and new show each change. warnings are the messages a reload prints, for example about an invalid value. They are the same as in the console.
How a batch is applied
- Every change is checked against the current files. Nothing is written yet.
- If any change is invalid, the whole batch is refused with
422and nothing changes. - The changed files are re-parsed to make sure they are still valid YAML.
- The files are written one by one, each through a temporary file and a rename, and the previous copy goes to
backups/autosave/. If a write fails, the files already written are put back. - The server reloads on its main thread. If the reload throws, the old files are written back, the reload runs again, and you get
500 reload_failed.
Type rules
A value must have the type of the setting it replaces:
| The setting is | The value must be |
|---|---|
| a boolean | true or false |
| a whole number | a whole number (45, not 45.5) |
| a decimal | any number (2 becomes 2.0) |
| a string | a string |
| a list | a list of booleans, numbers or strings |
| a section (has settings inside it) | not allowed. Set the settings inside it |
Lists can have up to 1000 items and strings up to 20000 characters. A setting that does not exist is refused unless the item has "create": true, which catches typos like history.keep-day.
Errors
All problems of a batch are reported together, with the position of each:
curl -s -X PATCH -H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \
-d '{"changes":[
{"file":"matchmaking.yml","path":"history.keep-days","value":60},
{"file":"matchmaking.yml","path":"history.keep-day","value":60},
{"file":"matchmaking.yml","path":"history.enabled","value":"yes"},
{"file":"database.yml","path":"cross-server.secret","value":"x"}
]}' "$MD_URL/config"{
"ok": false,
"error": {
"code": "invalid_changes",
"message": "changes[1]: history.keep-day does not exist in matchmaking.yml; add \"create\": true to add it; changes[2]: history.enabled is a boolean; changes[3]: cross-server.secret cannot be changed through the API"
}
}changes[0] was fine and was not applied either, because the batch is all or nothing.
Other errors: 400 for an empty batch or more than 200 changes, 404 for an unknown file, 422 invalid_file when the file on disk is not valid YAML.
Dry run first
Check a batch without changing anything:
curl -s -X PATCH -H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \
-d '{"dryRun":true,"changes":[{"file":"matchmaking.yml","path":"history.keep-days","value":60}]}' "$MD_URL/config"{
"ok": true,
"data": {
"applied": false,
"changes": [ { "file": "matchmaking.yml", "path": "history.keep-days", "old": 30, "new": 60 } ]
}
}Run the same body with "dryRun": false to apply it.
Adding a setting and a list
{
"changes": [
{ "file": "matchmaking.yml", "path": "queue.custom-note", "value": "hello", "create": true },
{ "file": "matchmaking.yml", "path": "duel.rounds", "value": [1, 3, 5, 7] }
]
}PUT /config/:file
Replace a whole file with new YAML text. Use it when you want to push a file you edited elsewhere.
| Field | Meaning |
|---|---|
content | The full YAML text. Up to 1 MB |
dryRun | true only checks that the text is valid YAML |
curl -s -X PUT -H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \
-d '{"content":"leaderboard:\n size: 20\n"}' "$MD_URL/config/matchmaking.yml"That example replaces the whole of matchmaking.yml with two lines. Settings you leave out fall back to the defaults from the jar, as if you had deleted them by hand. To edit safely, download the file, change it and send it back:
curl -s -H "Authorization: Bearer $ADMIN_KEY" "$MD_URL/config/messages.yml" | jq -r '.data.content' > messages.yml
nano messages.yml
jq -Rs '{content: .}' messages.yml \
| curl -s -X PUT -H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" -d @- "$MD_URL/config/messages.yml"{ "ok": true, "data": { "file": "messages.yml", "applied": true, "reloaded": true, "warnings": [] } }Invalid YAML gives 400 and the file is not touched:
{"ok":false,"error":{"code":"bad_request","message":"the content is not valid YAML: while scanning a simple key"}}For single changes use PATCH, which keeps everything else. PUT on database.yml gives 403 protected.
POST /reload
Reload the config files without editing anything. Needs write.
curl -s -X POST -H "Authorization: Bearer $MD_KEY" "$MD_URL/reload"{ "ok": true, "data": { "reloaded": true, "warnings": [] } }Use it after you edited files by hand. It does the same as /md reload. It can take a few seconds on a large server, so the API waits up to 30 seconds.
Roll back
Every write keeps the previous copy under plugins/MineDuels/backups/autosave/, mirroring the folder layout, for example backups/autosave/matchmaking.yml.bak. To undo an applied PATCH, send the old values from its response back as a new batch:
{
"changes": [
{ "file": "matchmaking.yml", "path": "history.keep-days", "value": 30 },
{ "file": "matchmaking.yml", "path": "leaderboard.overall-min-games", "value": 10 },
{ "file": "database.yml", "path": "cross-server.global-chat", "value": false },
{ "file": "ranks/_default.yml", "path": "elo.k-factor", "value": 32 }
]
}Changing every server of a network
The API edits only the files of its own server. To apply one change to many servers, run the web API on each of them, or apply the same PATCH through each one:
for url in http://lobby-1:8765/v1 http://game-1:8765/v1 http://game-2:8765/v1; do
curl -fsS -X PATCH -H "Authorization: Bearer $ADMIN_KEY" -H "Content-Type: application/json" \
-d @changes.json "$url/config" | jq -c '{url: "'$url'", applied: .data.applied}'
doneEach server needs its own key, since keys are stored per server in webapi.yml. Use dryRun on all of them first.