For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
        • addSection
        • addVerb
        • addVerbToSection
        • asRouter
        • extractSipUsername
        • getApp
        • getBasicAuthCredentials
        • getBuilder
        • getDocument
        • manualSetProxyUrl
        • onRequest
        • registerRoutingCallback
        • registerVerbHandler
        • renderDocument
        • renderSwml
        • resetDocument
        • run
        • serve
        • setOnRequestCallback
        • stop
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Examples
  • Extract from SIP URI
  • Extract from TEL URI
AgentsSWMLService

extractSipUsername

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

getApp

Next
Built with

Static utility method that extracts the username portion from the call.to field of a parsed request body. Handles three input formats:

  • sip:username@domain (or sips:...) — strips the scheme and @domain suffix, returning the username
  • tel:+1234567890 — strips the tel: scheme, returning the phone number
  • Plain string — returned as-is

Commonly paired with registerRoutingCallback() to route SIP traffic based on the dialed user.

Parameters

requestBody
Record<string, unknown>Required

The parsed JSON body from an incoming request. Expected to contain a call.to field with a SIP URI, TEL URI, or phone number string.

Returns

string | null — The extracted username or phone number, or null if the call.to field is missing or cannot be parsed.

Examples

Extract from SIP URI

1import { SWMLService } from '@signalwire/sdk';
2
3const body = { call: { to: 'sip:sales@example.sip.signalwire.com' } };
4const username = SWMLService.extractSipUsername(body);
5// "sales"

Extract from TEL URI

1import { SWMLService } from '@signalwire/sdk';
2
3const body = { call: { to: 'tel:+15551234567' } };
4const number = SWMLService.extractSipUsername(body);
5// "+15551234567"