Smart Library Docs

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:

KeyDefault ValueDescription
FINE_RATE_PER_DAY1.0Fine amount charged per day for overdue books (in dollars)
MAX_LOAN_DAYS_STUDENT14Default loan duration for students (in days)
MAX_LOAN_DAYS_STAFF30Default loan duration for staff members (in days)
MAX_RENEWALS2Maximum number of times a user can renew a single book

Get All Configurations

GET /api/v1/config

Returns 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/:id

Updates the value of a system configuration entry. The change is audit-logged.

Authorization: ROLE_ADMIN only

Path Parameters

ParameterDescription
idConfiguration entry ID

Request Body

FieldTypeRequiredDescription
valueMixedNew 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

CodeCondition
404Configuration entry not found
403Not an admin
500Internal server error

Route Summary

MethodPathAuthDescription
GET/configAdmin onlyList all configurations
PATCH/config/:idAdmin onlyUpdate a configuration value

On this page