Skip to content

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.

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)

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.

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
}
RouteMethodAuthDescription
/api/admin/update-domainPOSTSession requiredUpdate all Twilio webhooks to current APP_HOST
Environment VariableDescription
APP_HOSTCurrent application hostname (e.g. app.loquent.com)

The voice webhook path is a constant: /twilio/voice.

src/mods/admin/
├── api/ # update_domain_api endpoint
└── services/ # update_domain service (reads APP_HOST, calls Twilio)
  • Twilio — provides update_phone_numbers_twiml for bulk webhook updates
  • Phone — phone numbers whose webhooks are updated