BaasixBaasix

Settings Routes

← Back to Documentation Home

Table of Contents

  1. Overview
  2. Get Project Info
  3. Get Settings
  4. Get Settings by App URL
  5. Update Settings
  6. Get Email Branding
  7. Test Email Configuration
  8. Reload Settings Cache
  9. Delete Tenant Settings
  10. Database Settings Reference
  11. Environment Variables Reference

Overview

The Settings API provides configuration management for the BAASIX application. Settings can be stored in the database (for runtime configuration) or set via environment variables (for server configuration).

Base URLs: / and /settings


Get Project Info

Get basic project information. This is a public endpoint.

  • URL: / or POST /
  • Method: GET or POST
  • Auth required: No (Public endpoint)

Success Response

{
  "data": {
    "project_name": "My Application",
    "title": "My App",
    "project_color": "#007bff",
    "secondary_color": "#6c757d",
    "description": "Application description",
    "project_url": "https://api.myapp.com",
    "app_url": "https://myapp.com"
  }
}

Example Request

curl -X GET "http://localhost:3000/"

Get Settings

Retrieve application settings. Returns global or tenant-specific settings.

  • URL: /settings
  • Method: GET
  • Auth required: No (Public endpoint, but some fields may require admin)

Query Parameters

ParameterTypeDescription
tenant_idstringGet settings for specific tenant (optional)

Success Response

{
  "data": {
    "project_name": "My Application",
    "title": "My App Title",
    "project_color": "#007bff",
    "secondary_color": "#6c757d",
    "description": "Application description",
    "keywords": "baasix, backend, api",
    "project_url": "https://api.myapp.com",
    "app_url": "https://myapp.com",
    "timezone": "UTC",
    "language": "en",
    "date_format": "YYYY-MM-DD",
    "currency": "USD",
    "from_email_name": "My App",
    "email_signature": "Best regards,\nMy App Team",
    "mobile_session_limit": -1,
    "web_session_limit": -1
  }
}

Example Request

# Get global settings
curl -X GET "http://localhost:3000/settings"

# Get tenant-specific settings
curl -X GET "http://localhost:3000/settings?tenant_id=tenant-123"

Get Settings by App URL

Retrieve settings for a specific application URL. Useful for multi-tenant frontends.

  • URL: /settings/by-app-url
  • Method: GET
  • Auth required: No (Public endpoint)

Query Parameters

ParameterTypeRequiredDescription
app_urlstringYesThe application URL to match

Success Response

{
  "data": {
    "project_name": "Tenant App",
    "title": "Tenant Application",
    "project_color": "#ff5722",
    "app_url": "https://tenant.myapp.com",
    "tenant_Id": "tenant-uuid"
  }
}

Example Request

curl -X GET "http://localhost:3000/settings/by-app-url?app_url=https://tenant.myapp.com"

Update Settings

Update application settings. Admin only.

  • URL: /settings
  • Method: PATCH
  • Auth required: Yes (Admin permissions required)

Request Body

Settings are updated as key-value pairs directly:

{
  "project_name": "New App Name",
  "project_color": "#ff5722",
  "timezone": "America/New_York",
  "mobile_session_limit": 3,
  "web_session_limit": 5
}

Success Response

{
  "data": {
    "id": "settings-uuid",
    "project_name": "New App Name",
    "project_color": "#ff5722",
    "timezone": "America/New_York",
    "mobile_session_limit": 3,
    "web_session_limit": 5,
    "updatedAt": "2025-01-15T10:30:00.000Z"
  }
}

Example Request

curl -X PATCH http://localhost:3000/settings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <admin-token>" \
  -d '{
    "project_name": "My Updated App",
    "timezone": "America/New_York",
    "mobile_session_limit": 3
  }'

Get Email Branding

Get email branding information for a tenant (used for email templates).

  • URL: /settings/branding
  • Method: GET
  • Auth required: No (but tenant_id is required)

Query Parameters

ParameterTypeRequiredDescription
tenant_idstringYesThe tenant ID

Success Response

{
  "data": {
    "project_name": "Tenant App",
    "project_color": "#007bff",
    "email_icon_Id": "file-uuid",
    "email_signature": "Best regards,\nTenant Team"
  }
}

Example Request

curl -X GET "http://localhost:3000/settings/branding?tenant_id=tenant-123"

Test Email Configuration

Test the email configuration by sending a test email. Admin only.

  • URL: /settings/test-email
  • Method: POST
  • Auth required: Yes (Admin permissions required)

Request Body

ParameterTypeRequiredDescription
tostringYesEmail address to send test to

Example Request

curl -X POST http://localhost:3000/settings/test-email \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <admin-token>" \
  -d '{"to": "test@example.com"}'

Reload Settings Cache

Force reload of settings from database into cache. Admin only.

  • URL: /settings/reload
  • Method: POST
  • Auth required: Yes (Admin permissions required)

Example Request

curl -X POST http://localhost:3000/settings/reload \
  -H "Authorization: Bearer <admin-token>"

Delete Tenant Settings

Delete settings for a specific tenant. Admin only.

  • URL: /settings/tenant
  • Method: DELETE
  • Auth required: Yes (Admin permissions required)

Query Parameters

ParameterTypeRequiredDescription
tenant_idstringYesTenant ID to delete

Example Request

curl -X DELETE "http://localhost:3000/settings/tenant?tenant_id=tenant-123" \
  -H "Authorization: Bearer <admin-token>"

Database Settings Reference

These settings are stored in the baasix_Settings table and can be updated via the API:

Branding & Identity

Setting KeyTypeDescriptionDefault
project_namestringProject/application name-
titlestringApplication title for display-
project_colorstringPrimary brand color (hex)-
secondary_colorstringSecondary brand color (hex)-
descriptionstringApplication description (SEO)-
keywordsstringSEO keywords-
project_urlstringAPI/Backend URL-
app_urlstringFrontend application URL-

Logo & Icon Assets (File References)

Setting KeyTypeDescription
project_logo_light_IdUUIDLight theme logo file ID
project_logo_dark_IdUUIDDark theme logo file ID
project_logo_full_IdUUIDFull logo with text file ID
project_logo_transparent_IdUUIDTransparent logo file ID
project_favicon_IdUUIDFavicon file ID
project_icon_IdUUIDApp icon file ID
email_icon_IdUUIDEmail template icon file ID

Email Configuration (Database)

Setting KeyTypeDescriptionDefault
from_email_namestringFrom address display name-
email_signaturestringEmail signature template-
smtp_enabledbooleanEnable SMTPfalse
smtp_hoststringSMTP server hostname-
smtp_portnumberSMTP server port587
smtp_securebooleanUse TLS/SSLfalse
smtp_userstringSMTP username-
smtp_passstringSMTP password-
smtp_from_addressstringSMTP from email address-

Localization

Setting KeyTypeDescriptionDefault
timezonestringDefault timezone"UTC"
languagestringDefault language"en"
date_formatstringDate display format"YYYY-MM-DD"
currencystringDefault currency"USD"

Session Management

Setting KeyTypeDescriptionDefault
mobile_session_limitnumberMax mobile sessions per user (-1=unlimited)-1
web_session_limitnumberMax web sessions per user (-1=unlimited)-1
session_limit_rolesJSONArray of role IDs to apply limits to[]

Extensibility

Setting KeyTypeDescription
metadataJSONCustom metadata storage
modulesJSONModule configuration

Environment Variables Reference

These settings are configured via environment variables at server startup:

Core Server

VariableDescriptionDefault
PORTServer port8055
SECRET_KEYJWT signing key (required)-
NODE_ENVEnvironment (production/dev)development

Database

VariableDescriptionDefault
DATABASE_URLPostgreSQL connection string-
DATABASE_POOL_MAXMax connection pool size20
DATABASE_POOL_IDLEIdle timeout (ms)10000
DATABASE_POOL_ACQUIREAcquire timeout (ms)30000
DATABASE_LOGGINGEnable SQL loggingfalse
DATABASE_SSL_CERTIFICATEPath to SSL certificate-
DATABASE_READ_REPLICA_ENABLEDEnable read replicasfalse
DATABASE_READ_REPLICA_URLSComma-separated replica URLs-

Cache (Redis)

VariableDescriptionDefault
CACHE_ADAPTERCache backend (memory/redis/upstash)memory
CACHE_REDIS_URLRedis connection URL-
CACHE_TTLCache TTL in seconds30
CACHE_SIZE_GBIn-memory cache size (GB)1.0
CACHE_ENABLEDEnable/disable cachingtrue

CORS & Authentication

VariableDescriptionDefault
AUTH_CORS_ALLOWED_ORIGINSComma-separated allowed CORS origins-
AUTH_CORS_ALLOW_ANY_PORTAllow any port for CORS matchingtrue
AUTH_CORS_CREDENTIALSInclude credentials in CORStrue
AUTH_APP_URLComma-separated allowed app URLs-

Rate Limiting

VariableDescriptionDefault
RATE_LIMITMax requests per window100
RATE_LIMIT_INTERVALRate limit window (ms)5000

Multi-Tenancy

VariableDescriptionDefault
MULTI_TENANTEnable multi-tenant modefalse

Mail Service

VariableDescription
MAIL_SENDERS_ENABLEDComma-separated list of mail senders
MAIL_DEFAULT_SENDERDefault sender name
<SENDER>_SMTP_HOSTSMTP host for sender
<SENDER>_SMTP_PORTSMTP port for sender
<SENDER>_SMTP_SECURETLS/SSL for sender (true/false)
<SENDER>_SMTP_USERSMTP username for sender
<SENDER>_SMTP_PASSSMTP password for sender
<SENDER>_FROM_ADDRESSFrom email address for sender

File Storage

VariableDescription
STORAGE_SERVICES_ENABLEDComma-separated list of storage services
STORAGE_DEFAULT_SERVICEDefault storage service
STORAGE_TEMP_PATHTemporary file storage path
<SERVICE>_STORAGE_DRIVERStorage driver (LOCAL or S3)
<SERVICE>_STORAGE_PATHLocal storage path
<SERVICE>_STORAGE_ACCESS_KEY_IDS3 access key
<SERVICE>_STORAGE_SECRET_ACCESS_KEYS3 secret key
<SERVICE>_STORAGE_REGIONS3 region
<SERVICE>_STORAGE_BUCKETS3 bucket name
<SERVICE>_STORAGE_ENDPOINTS3 endpoint URL

Real-time (Socket.IO)

VariableDescriptionDefault
SOCKET_ENABLEDEnable Socket.IOfalse
SOCKET_PATHSocket.IO connection path/socket
SOCKET_CORS_ENABLED_ORIGINSCORS origins for WebSocket-
SOCKET_REDIS_ENABLEDUse Redis for Socket.IO clusteringfalse
SOCKET_REDIS_URLRedis URL for Socket.IO adapter-

Task Management

VariableDescriptionDefault
TASK_SERVICE_ENABLEDEnable background task servicefalse
TASK_LIST_REFRESH_INTERVALTask cache refresh interval (sec)600
TASK_SHUTDOWN_WAIT_TIMEWait time for tasks on shutdown (sec)30

Error Responses

Common Error Codes

CodeMessageDescription
400Invalid settings dataMalformed settings object
401UnauthorizedAuthentication required
403ForbiddenAdmin permissions required
404Settings not foundNo settings for given tenant
500Settings update failedServer error during update

Core Configuration

Authentication & Sessions

Multi-tenant

Real-time & Tasks

API Reference

← Back to Documentation Home

On this page