Admin
The admin module provides platform-level operations that affect all organizations. Currently handles domain migration — updating external service webhooks when the application’s hostname changes.
Domain Update
Section titled “Domain Update”When the Loquent platform moves to a new domain (e.g. staging → production, DNS change), all Twilio phone number webhooks must point to the new hostname. The update_domain operation handles this in bulk.
POST /api/admin/update-domain → Read APP_HOST env var (e.g. "app.loquent.com") → Build voice URL: https://{APP_HOST}/twilio/voice → For each phone number in the system: → Call Twilio API to update VoiceUrl webhook → Log results (total, succeeded, failures)Why It’s Needed
Section titled “Why It’s Needed”Twilio sends inbound call events to a webhook URL configured on each phone number. If the domain changes and webhooks aren’t updated, incoming calls fail silently.
Example: Moving from staging.loquent.com to app.loquent.com requires updating every phone number’s VoiceUrl from https://staging.loquent.com/twilio/voice to https://app.loquent.com/twilio/voice.
Result Tracking
Section titled “Result Tracking”The operation returns detailed results:
pub struct TwimlUpdateResult { pub voice_url: String, // New URL applied pub total: usize, // Phone numbers processed pub succeeded: usize, // Successful updates pub failures: Vec<TwimlUpdateFailure>,}
pub struct TwimlUpdateFailure { pub number: String, // Phone number that failed pub twilio_sid: String, // Twilio SID pub error: String, // Error message}API Endpoint
Section titled “API Endpoint”| Route | Method | Auth | Description |
|---|---|---|---|
/api/admin/update-domain | POST | Session required | Update all Twilio webhooks to current APP_HOST |
Configuration
Section titled “Configuration”| Environment Variable | Description |
|---|---|
APP_HOST | Current application hostname (e.g. app.loquent.com) |
The voice webhook path is a constant: /twilio/voice.
Module Structure
Section titled “Module Structure”src/mods/admin/├── api/ # update_domain_api endpoint└── services/ # update_domain service (reads APP_HOST, calls Twilio)