API Settings & Route Security (RBAC & Route Password)
Toggle CRUD endpoints on or off in real time, restrict access by user roles (RBAC), and lock sensitive routes with a custom password (
X-Route-Password) — with live testing in API Tester.
1. Overview
The API Settings page in your HosteDay dashboard (dash.hosteday.com) gives you centralized, real-time control over every auto-generated CRUD route for your application tables — without touching code or rebuilding your container.
Every change you make in API Settings updates tenant_routes directly in your isolated database and immediately clears the route cache inside your container so changes take effect instantly.
- System tables (
users,tenant_routes,migrations,jobs,device_tokens,table_job_hooks, etc.) are automatically excluded from dynamic CRUD routing to protect application integrity. - Any new custom table created via Data Manager or phpMyAdmin is automatically discovered and registered with standard CRUD routes.
2. CRUD Route Control & Quick Presets
You can independently manage each operation for a table (GET Index, GET Show, POST Create, PUT/PATCH Update, DELETE Delete):
- Safe Soft-Toggle: Disabling a route hides it completely at runtime without deleting its configuration from the database, returning
404 Not Found:
{
"status": false,
"message": "Endpoint not found or disabled"
}
- Instant Auto-Save: Toggling route status, updating roles, or changing a route password saves automatically in the background and clears your container's route cache immediately.
Quick Presets
At the top of each table card, three one-click presets let you configure the entire table instantly:
| Preset | Automatic Behavior | Best For |
|---|---|---|
| Full CRUD | Enables all operations (GET, POST, PUT, PATCH, DELETE). |
Active application tables requiring full read/write access. |
| Read-Only | Enables GET routes only and disables all write/delete endpoints (404). |
Public catalogs, articles, settings, and read-only feeds. |
| Admin Write | Keeps GET routes open by default and restricts POST, PUT, PATCH, DELETE to the admin role. |
Products, announcements, and admin-managed content. |
3. Role-Based Access Control (RBAC)
RBAC lets you restrict any CRUD endpoint (including GET routes) to authenticated Sanctum users who hold one of the allowed roles in your users table.
Configuring the Role Column (role_column)
- By default, HosteDay reads the
rolecolumn from youruserstable (default value'user'). - You can customize the column name (e.g.,
typeoruser_type) from the top bar in API Settings and apply it to the table in one click. - For older environments that do not yet have a
rolecolumn inusers, a smart banner provides a one-click "Add role Column Automatically Now" button without opening phpMyAdmin.
Assigning Allowed Roles (allowed_roles)
- Switch the endpoint's access mode to RBAC Roles.
- Pick from quick suggestions (
admin,super_admin,moderator,editor) or type any custom role and pressEnter. - When a request hits an RBAC-protected endpoint:
- Missing or invalid Sanctum token (
Authorization: Bearer <token>) returns401 Unauthorized:{ "status": false, "message": "Authentication required for this endpoint" } - Authenticated user without a matching role returns
403 Forbidden:{ "status": false, "message": "Access denied: insufficient role permissions" }
- Missing or invalid Sanctum token (
4. Route Password Protection (X-Route-Password)
Route Password Protection adds an optional, lightweight secret lock per endpoint that works standalone or combined with RBAC.
When to Use Route Passwords
- Protecting public endpoints that do not require a logged-in user account but should only be called by trusted clients.
- Securing webhook receivers or external automation endpoints without creating a user account.
- Adding a second defense layer on top of RBAC (
RBAC + Route Password) for sensitive operations such asDELETE.
Enabling & Generating a Password
- Click the key/lock icon next to any active endpoint in API Settings.
- Type a custom password (minimum 4 characters) or click Generate to create a strong 24-character random password and save it automatically.
- Click Copy to copy the secret, or Unlock at any time to remove the password lock.
Server-Side Verification
The runtime reads the password from the X-Route-Password header and verifies it using timing-safe comparison (hash_equals):
- Missing header returns
401 Unauthorized:{ "status": false, "message": "Route password required" } - Invalid password returns
403 Forbidden:{ "status": false, "message": "Invalid route password" }
5. Live Testing in API Tester & Live Headers Preview
API Tester integrates seamlessly with password-protected routes:
- Locked routes display an amber lock icon in the sidebar list.
- Selecting a locked route reveals the Route Password (
X-Route-Password) input — left blank by default so you can verify401 Unauthorizedrejection first, with a one-click Auto-fill from route settings button to test200 OKimmediately. - The live Headers JSON box updates in real time as you edit tokens or passwords:
{
"Accept": "application/json",
"Content-Type": "application/json",
"X-Api-Token": "your-tenant-api-token",
"X-Route-Password": "your-generated-route-password"
}
6. Code Examples
cURL Example
curl -X GET "https://your-app.hosteday.com/api/notes" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-Token: YOUR_TENANT_API_TOKEN" \
-H "X-Route-Password: YOUR_GENERATED_ROUTE_PASSWORD" \
-H "Authorization: Bearer YOUR_USER_SANCTUM_TOKEN"
Flutter / Dart Example (http)
import 'dart:convert';
import 'package:http/http.dart' as http;
Future<Map<String, dynamic>> fetchProtectedNotes({
required String apiToken,
required String routePassword,
String? bearerToken,
}) async {
final uri = Uri.parse('https://your-app.hosteday.com/api/notes');
final headers = <String, String>{
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-Api-Token': apiToken,
'X-Route-Password': routePassword,
if (bearerToken != null && bearerToken.isNotEmpty)
'Authorization': 'Bearer $bearerToken',
};
final response = await http.get(uri, headers: headers);
if (response.statusCode == 200) {
return jsonDecode(response.body) as Map<String, dynamic>;
}
throw Exception('Request failed (${response.statusCode}): ${response.body}');
}