Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

feat(settings): drop the always-501 PUT /api/settings route

Yudhi Armyndharisa0d33da81e26
diff --git a/SECURITY.md b/SECURITY.md
index 575572068..785b6634f 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -98,7 +98,7 @@ deployment rather than on a single session:
and per-session config remain available, scoped to the sessions the key
allows)
- Cross-session statistics (`GET /api/stats/overview`, `GET /api/stats/messages`)
-- Application settings (`GET` / `PUT /api/settings`)
+- Application settings (`GET /api/settings`)
- Session creation (`POST /api/sessions`)
- The queue dashboard (`/api/admin/queues`)
diff --git a/docs/06-api-specification.md b/docs/06-api-specification.md
index b51da232d..3d26b9191 100644
--- a/docs/06-api-specification.md
+++ b/docs/06-api-specification.md
@@ -5039,28 +5039,6 @@ Notes: raw return of an in-memory `Settings` object built once in the controller
**Errors:** `401` — missing/invalid `X-API-Key` · `403` — API key lacks the ADMIN role, or the key is session-restricted.
-#### PUT /api/settings
-
-Update settings — intentionally not implemented; always returns `501` (settings are env-derived and read-only at runtime).
-
-**Auth:** API key (ADMIN)
-
-**Request body** — none. There is no request DTO; any body is ignored (the exception is thrown before validation matters).
-
-**Response** `501`
-
-```json
-{
- "statusCode": 501,
- "message": "Settings are derived from environment configuration and are read-only at runtime. Change the corresponding environment variable and restart the service.",
- "error": "Not Implemented"
-}
-```
-
-Notes: the handler unconditionally throws `NotImplementedException`. Even an ADMIN key always gets `501`; there is no success response.
-
-**Errors:** `401` — missing/invalid key · `403` — key lacks `ADMIN` · `501` — always (not implemented).
-
#### GET /api/audit
List audit-log entries, newest first. Every API-key lifecycle change, session/message/webhook event and ADMIN infra operation lands here.
diff --git a/docs/07-api-collection.md b/docs/07-api-collection.md
index 0a704da1b..5c47a1e4e 100644
--- a/docs/07-api-collection.md
+++ b/docs/07-api-collection.md
@@ -1332,15 +1332,6 @@ curl "$BASE/api/settings" \
-H "X-API-Key: $API_KEY"
```
-#### PUT /api/settings
-
-Always returns `501` — settings are read-only at runtime. ADMIN key required (still `501`).
-
-```bash
-curl -X PUT "$BASE/api/settings" \
- -H "X-API-Key: $API_KEY"
-```
-
#### GET /api/audit
List audit-log entries, newest first (ADMIN; rows stay confined to the key's allowed sessions).
diff --git a/openapi.json b/openapi.json
index 33445b6ef..864efd1ac 100644
--- a/openapi.json
+++ b/openapi.json
@@ -3945,19 +3945,6 @@
"tags": [
"settings"
]
- },
- "put": {
- "operationId": "SettingsController_update",
- "parameters": [],
- "responses": {
- "501": {
- "description": "Settings are derived from environment configuration and cannot be changed at runtime"
- }
- },
- "summary": "Settings are read-only at runtime (environment-derived)",
- "tags": [
- "settings"
- ]
}
},
"/api/infra/status": {
diff --git a/src/modules/settings/settings.controller.spec.ts b/src/modules/settings/settings.controller.spec.ts
index 556e8eecd..dd9d2e2f9 100644
--- a/src/modules/settings/settings.controller.spec.ts
+++ b/src/modules/settings/settings.controller.spec.ts
@@ -1,4 +1,3 @@
-import { NotImplementedException } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { ConfigService } from '@nestjs/config';
import { SettingsController } from './settings.controller';
@@ -43,20 +42,6 @@ describe('SettingsController', () => {
}
});
- // The previous PUT mutated an in-memory field and returned 200 'updated' while persisting
- // nothing and applying nothing to the runtime — a false success. Settings are env-derived and
- // read-only at runtime, so the write path must say so (501) rather than fake success.
- it('PUT /settings is read-only and throws 501 instead of a false-success 200', () => {
- const controller = new SettingsController(configStub);
- expect(() => controller.update()).toThrow(NotImplementedException);
- });
-
- it('PUT /settings still requires the ADMIN role', () => {
- const proto = SettingsController.prototype as unknown as Record<string, (...args: unknown[]) => unknown>;
- const role = new Reflector().get<ApiKeyRole | undefined>(REQUIRED_ROLE_KEY, proto.update);
- expect(role).toBe(ApiKeyRole.ADMIN);
- });
-
it('GET /settings requires the ADMIN role (env-derived config is not for low-privilege keys)', () => {
const proto = SettingsController.prototype as unknown as Record<string, (...args: unknown[]) => unknown>;
const role = new Reflector().get<ApiKeyRole | undefined>(REQUIRED_ROLE_KEY, proto.get);
diff --git a/src/modules/settings/settings.controller.ts b/src/modules/settings/settings.controller.ts
index 612abb158..0c69b277b 100644
--- a/src/modules/settings/settings.controller.ts
+++ b/src/modules/settings/settings.controller.ts
@@ -1,4 +1,4 @@
-import { Controller, Get, Put, NotImplementedException } from '@nestjs/common';
+import { Controller, Get } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse } from '@nestjs/swagger';
import { SettingsResponseDto } from './dto/settings-response.dto';
import { ConfigService } from '@nestjs/config';
@@ -71,24 +71,4 @@ export class SettingsController {
// to specific sessions, which has no claim on deployment-wide configuration.
return this.settings;
}
-
- @Put()
- @RequireRole(ApiKeyRole.ADMIN)
- @RequireUnscopedKey()
- @ApiOperation({ summary: 'Settings are read-only at runtime (environment-derived)' })
- @ApiResponse({
- status: 501,
- description: 'Settings are derived from environment configuration and cannot be changed at runtime',
- })
- update(): never {
- // Every Settings field is derived from environment variables and consumed at boot /
- // decorator-evaluation time (ThrottlerModule.forRootAsync, port, webhook timeout, DB logging),
- // and ConfigService is immutable at runtime — so a runtime write cannot actually take effect.
- // The previous handler mutated an in-memory copy and returned 200 'updated' while persisting
- // nothing and applying nothing: a false success. Be honest instead of pretending it worked.
- throw new NotImplementedException(
- 'Settings are derived from environment configuration and are read-only at runtime. ' +
- 'Change the corresponding environment variable and restart the service.',
- );
- }
}