System Config Endpoints
API reference for dynamic system configuration — view and update runtime parameters like fine rates and loan durations.
System Config Endpoints
Manage dynamic system-wide configuration parameters. These settings control runtime behavior such as fine rates, loan durations, and renewal limits without requiring code changes or redeployment.
Base Path: /api/v1/config
All endpoints require authentication and ROLE_ADMIN authorization.
Default Configuration Keys
The following keys are automatically initialized on first server startup if they don't already exist:
| Key | Default Value | Description |
|---|---|---|
FINE_RATE_PER_DAY | 1.0 | Fine amount charged per day for overdue books (in dollars) |
MAX_LOAN_DAYS_STUDENT | 14 | Default loan duration for students (in days) |
MAX_LOAN_DAYS_STAFF | 30 | Default loan duration for staff members (in days) |
MAX_RENEWALS | 2 | Maximum number of times a user can renew a single book |
Get All Configurations
GET /api/v1/configReturns all system configuration entries, sorted alphabetically by key.
Authorization: ROLE_ADMIN only
Success Response — 200 OK
{
"configs": [
{
"_id": "...",
"key": "FINE_RATE_PER_DAY",
"value": 1.0,
"description": "The fine amount charged per day for overdue books.",
"lastUpdatedBy": null,
"createdAt": "2026-07-01T00:00:00.000Z",
"updatedAt": "2026-07-01T00:00:00.000Z"
},
{
"_id": "...",
"key": "MAX_LOAN_DAYS_STUDENT",
"value": 14,
"description": "Default loan duration for students.",
"lastUpdatedBy": "...",
"createdAt": "...",
"updatedAt": "..."
}
]
}Update Configuration
PATCH /api/v1/config/:idUpdates the value of a system configuration entry. The change is audit-logged.
Authorization: ROLE_ADMIN only
Path Parameters
| Parameter | Description |
|---|---|
id | Configuration entry ID |
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
value | Mixed | ✅ | New value for the configuration key |
Success Response — 200 OK
{
"message": "Configuration updated",
"config": {
"_id": "...",
"key": "FINE_RATE_PER_DAY",
"value": 2.5,
"description": "The fine amount charged per day for overdue books.",
"lastUpdatedBy": "admin-user-id",
"updatedAt": "2026-07-06T21:00:00.000Z"
}
}Error Responses
| Code | Condition |
|---|---|
404 | Configuration entry not found |
403 | Not an admin |
500 | Internal server error |
Route Summary
| Method | Path | Auth | Description |
|---|---|---|---|
GET | /config | Admin only | List all configurations |
PATCH | /config/:id | Admin only | Update a configuration value |