

SipCore™ Complete API Documentation
Production-verified specification for all 34 SipCore™ endpoints and socket interfaces: multi-route outbound call origination with per-leg ES256 STIR/SHAKEN signing, wire-isolated sip_headers, 18 real-time mid-call DSP & bridge commands, full-duplex 20ms G.711 WebSocket AI streaming (:8083), WAV recording retrieval, zero-disk SIP wire tracing (:8082), and FreeSWITCH ESL emulation (:8021).
1. Multi-Port Network Architecture & Authentication
Each SipCore™ node separates HTTP control-plane REST APIs, real-time bi-directional PCMU WebSocket audio streams, wire-level SIP diagnostics, and legacy FreeSWITCH ESL sockets onto dedicated ports:
| AWS Instance | SipCore™ Voice | SipCore™ + AMD | SipCore™ + AMD + Stereo Rec | vs. Asterisk / FreeSWITCH |
|---|---|---|---|---|
| 4-Core (c6in.xlarge) | 150 CPS • 9,046 sess | 88 CPS • 5,311 sess (87.0% Beep) | 88 CPS • 5,226 sess (94.5% Beep) | 3.5× – 6.0× Legacy |
| 8-Core (c6in.2xlarge) | 320 CPS • 19,276 sess | 195 CPS • 11,759 sess (96.3% Beep) | 150 CPS • 9,046 sess (97.1% Beep) | 4.1× – 6.7× Legacy |
| 16-Core (c6in.4xlarge) | 520 CPS • 31,359 sess | 410 CPS • 24,701 sess (93.2% Beep) | 320 CPS • 19,297 sess (98.4% Beep) | 4.7× – 8.5× Legacy |
| 32-Core (c6in.8xlarge) | 1,060 CPS • 63,820 sess | 840 CPS • 50,038 sess (96.5% Beep) | 660 CPS • 39,757 sess (98.2% Beep) | Up to 10.15× Legacy |
Multi-Carrier Beep Recall Under Load: Across 740/850/1000/1400 Hz, 180 ms short, and wireless DTX-gap tones, SipCore™ maintained 93.2%–96.5% recall in Test 2 (+AMD) and 97.1%–98.4% recall in Test 3 (+AMD + Stereo Recording)—whereas Asterisk 22.11 (54.8%–55.1% → 0.0%–0.3%) and FreeSWITCH 1.11 (42.5%–44.1% → 1.6%–2.3%) missed non-1000 Hz/DTX tones and collapsed when live stereo recording was enabled.
Outbound origination, 18 mid-call commands, DTMF long-polling, events, CDRs, WAV recordings & dynamic config.
Full-duplex 20ms G.711 μ-law (160-byte) audio streaming between caller RTP and AI voice agents (<1ms barge-in).
Zero-disk in-memory raw SIP packet and ES256 STIR/SHAKEN Identity header inspection.
Stateful Event Socket Layer adapter translating auth, event plain ALL & bgapi originate.
HTTP Control Plane (:8080): http://<sipcore-node>:8080
WebSocket Audio Stream (:8083): ws://<sipcore-node>:8083/calls/{call_id}/audio-stream/ws
Admin & Wire-Trace (:8082): http://<sipcore-node>:8082
FreeSWITCH ESL TCP (:8021): tcp://<sipcore-node>:8021
# Required on all POST, DELETE, and protected GET (/recordings, /calls, /cdr, /events):
Authorization: Bearer <YOUR_SIPCORE_API_TOKEN>
Content-Type: application/json2. Complete 34-Endpoint & Socket Catalog
| Category | Method | Path / Interface | Port | Description |
|---|---|---|---|---|
| Health & Telemetry | GET | /health | :8080 | Liveness probe returning {"status":"ok"} |
| Health & Telemetry | GET | /ready | :8080 | Readiness probe (200 OK when SIP & RTP pools are ready; 503 while draining) |
| Health & Telemetry | GET | /status | :8080 | Node version, uptime, worker count, active calls/streams/bridges & queue depths |
| Health & Telemetry | GET | /metrics | :8080 | Lock-free AtomicU64 operational counters for calls, AMD, beeps, RTP & bridges |
| Call Origination | POST | /calls/outbound | :8080 | Canonical outbound origination: failover routes[], sip_headers, multi-codec audio, DSP modules, webhooks & STIR/SHAKEN |
| Call Origination | POST | /calls | :8080 | Simplified outbound call origination (destination, caller_id, human_audio, voicemail_audio) |
| Call State | GET | /calls/{call_id} | :8080 | Real-time state machine status of an active call |
| Mid-Call Control | POST | /calls/{call_id}/commands | :8080 | Dispatch 18 real-time mid-call commands (Hangup, StartAmd, StartBeepDetection, StartPlayback, StartRecording, BridgeToSipEndpoint, InterruptAudioStream, SetMetadata, etc.) |
| AI Audio Stream | POST | /calls/{call_id}/audio-stream/start | :8080 | Allocate a bidirectional AI WebSocket audio stream and return ws_url |
| AI Audio Stream | GET | /calls/{call_id}/audio-stream/ws | :8080 | Check stream readiness and fetch WebSocket URL for call_id |
| AI Audio Stream | WS | /calls/{call_id}/audio-stream/ws | :8083 | Full-duplex 20ms G.711 μ-law (160-byte) binary audio WebSocket (<1ms barge-in) |
| AI Audio Stream | POST | /calls/{call_id}/audio-stream/stop | :8080 | Stop and deregister an active WebSocket audio stream |
| DTMF & Events | GET | /calls/{call_id}/wait-dtmf?timeout_ms={ms} | :8080 | Long-poll up to 30,000 ms for a caller RFC 4733 DTMF digit |
| DTMF & Events | GET | /calls/{call_id}/events | :8080 | Chronological lifecycle events (ExternalEvent[]) for a specific call |
| DTMF & Events | GET | /events | :8080 | The 100 most recent lifecycle events across the node |
| DTMF & Events | POST | /webhooks/config | :8080 | Configure global webhook URL for real-time HTTP POST event delivery |
| CDRs & Recordings | GET | /cdr/{call_id} | :8080 | Complete Session CDR JSON (legs, beep_frequency_hz, SIP/Q.850 outcomes, STIR/SHAKEN) |
| CDRs & Recordings | GET | /cdr?from={epoch}&to={epoch}&limit={n} | :8080 | Query historical Session CDR records within a timestamp window |
| CDRs & Recordings | GET | /recordings/{call_id} | :8080 | Download recorded WAV file (audio/wav) for call_id (Bearer token required) |
| CDRs & Recordings | DELETE | /recordings/{call_id} | :8080 | Delete local WAV recording on SipCore after upstream S3 upload (Bearer token required) |
| Dynamic Config | GET | /config | :8080 | Retrieve active SipCoreConfig runtime settings |
| Dynamic Config | GET | /carriers | :8080 | List configured outbound SIP carrier trunks |
| Dynamic Config | POST | /carriers | :8080 | Dynamically add and persist an outbound SIP carrier trunk |
| Dynamic Config | GET | /routes | :8080 | List regex dialplan routing patterns |
| Dynamic Config | POST | /routes | :8080 | Dynamically add and persist a dialplan routing rule |
| Dynamic Config | GET | /inbound-targets | :8080 | List registered inbound SIP target URIs |
| Dynamic Config | POST | /inbound-targets | :8080 | Add an inbound SIP target URI |
| Dynamic Config | DELETE | /inbound-targets/{target} | :8080 | Remove an inbound SIP target URI |
| Dynamic Config | GET | /scripts | :8080 | List declarative call-flow scripts |
| Dynamic Config | POST | /scripts | :8080 | Register or replace a named declarative call-flow script |
| Admin Wire-Trace | GET | /admin/health | :8082 | Health check for Admin & Wire-Trace HTTP server |
| Admin Wire-Trace | GET | /admin/traces/recent | :8082 | Summaries of the 50 most recent traced SIP calls |
| Admin Wire-Trace | GET | /admin/traces/call/{call_id} | :8082 | Raw inbound/outbound SIP packets & STIR/SHAKEN Identity headers for call_id |
| FreeSWITCH ESL | TCP | auth / event / api / bgapi originate | :8021 | Stateful FreeSWITCH mod_event_socket emulation for zero-rewrite dialer migration |
3. System Health, Readiness, Status & Metrics
Unauthenticated operational probes on :8080 for load balancers, Kubernetes/systemd readiness gates, and real-time Prometheus/JSON telemetry scraping.
curl -s http://127.0.0.1:8080/health
curl -s http://127.0.0.1:8080/ready
curl -s http://127.0.0.1:8080/status | jq .
curl -s http://127.0.0.1:8080/metrics | jq .{
"version": "0.2.4",
"uptime_seconds": 86420,
"worker_count": 8,
"active_calls": 546,
"active_streams": 42,
"active_bridges": 18,
"cdr_queue_depth": 0,
"event_queue_depth": 0,
"recording_queue_depth": 0,
"config_loaded": true,
"ready_state": true
}4. Outbound Call Origination & 1-Leg RVM Diversion (POST /calls/outbound)
Originates an outbound SIP call with ordered multi-carrier failover (route or routes[] with fresh per-leg ES256 STIR/SHAKEN signing), native multi-format audio decoding (WAV, MP3, OGG, FLAC, AAC/M4A), multi-codec SDP/RTP (PCMU, PCMA, G.722 HD, G.729), inline DSP modules (beep_detection, playback_on_beep, recording), and wire-isolated sip_headers (e.g. Diversion for 1-leg RVM).
| Field | Type | Req. | Description |
|---|---|---|---|
| to | string | Yes | Destination E.164 phone number with leading "+" (e.g. "+13235550116"). |
| from | string | Yes | Origination Caller ID in E.164 format (e.g. "+18005550199"). |
| route / routes | object | array | Yes | Single carrier route {next_hop, domain, transport} or ordered failover array routes[]. Each leg is freshly ES256 STIR/SHAKEN signed. |
| media | array | Yes | Non-empty list of clips: [{source: {path: "/opt/..." } | {url: "https://..."}, hangup_after: true, interruptible: false}]. Supports WAV, MP3, OGG, FLAC, AAC/M4A. |
| modules | array | No | Inline DSP modules: [{"beep_detection": true, "playback_on_beep": true}, {"recording": {"enabled": true, "direction": "both"}}]. |
| sip_headers | map<string,string> | No | Custom SIP headers written verbatim onto outbound INVITE (e.g. Diversion, X-Carrier-SID, P-Asserted-Identity). Wire-isolated from metadata. |
| events_url / cdr_url | string | No | Per-call HTTP POST webhook URLs for real-time ExternalEvent notifications and final Session CDR delivery. |
| answer_timeout_seconds | number | No | Ring timeout in seconds per route attempt before failover (default: 30). |
| max_call_seconds | number | No | Hard maximum call duration in seconds before automatic hangup (default: 120). |
| stir_profile_id / stir_attestation | string | No | Named signing profile (e.g. "default") and attestation override ("A", "B", or "C"). |
| script | string | No | Optional named declarative call-flow script to run automatically on answer. |
| metadata | object | No | Arbitrary JSON echoed on webhooks & CDR (optional preferred_codec: "pcmu" | "pcma" | "g722" | "g729"). |
curl -X POST "http://127.0.0.1:8080/calls/outbound" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"to": "+13235550116",
"from": "+18005550199",
"routes": [
{ "next_hop": "sip.sipsmart.io:5060", "domain": "sip.sipsmart.io", "transport": "udp" },
{ "next_hop": "backup.carrier.example:5060", "domain": "backup.carrier.example", "transport": "udp" }
],
"media": [
{
"source": { "path": "/opt/sipcore/media/rvm_drop.wav" },
"hangup_after": true,
"interruptible": false
}
],
"modules": [
{ "beep_detection": true, "playback_on_beep": true },
{ "recording": { "enabled": true, "direction": "both" } }
],
"sip_headers": {
"Diversion": "<tel:+13235550116>;reason=user-busy;counter=1;privacy=off"
},
"events_url": "https://your-app.example.com/webhooks/sipcore-events",
"cdr_url": "https://your-app.example.com/webhooks/sipcore-cdr",
"stir_profile_id": "default",
"stir_attestation": "A",
"metadata": { "campaign_id": "camp_2026", "lead_id": "lead_99812" }
}'5. Real-Time Mid-Call Control Commands (POST /calls/{call_id}/commands)
Dispatches an O(1) asynchronous command directly to the worker owning {call_id}. Returns 202 Accepted or 404 Not Found.
| Command JSON Body | Description |
|---|---|
| "Hangup" | Immediately terminates the call (sends SIP BYE or CANCEL). |
| "Answer" | Answers an inbound ringing call (200 OK with negotiated SDP). |
| {"Forward": {"dest": "sip:+12125551234@sip.sipsmart.io:5060"}} | Redirects/forwards an inbound ringing call to another SIP URI. |
| "Hold" / "Unhold" | Places the active call on hold or resumes a held call. |
| "StartAmd" | Starts real-time Answering Machine Detection (AmdHumanDetected / AmdMachineDetected / AmdUnknownDetected). |
| "StartBeepDetection" / "StopBeepDetection" | Enables or disables 18-bin wideband voicemail tone detection with wireless DTX holdover. |
| {"StartPlayback": {"audio": "audio/greeting.wav", "interruptible": true}} | Streams audio ('human', 'voicemail', or file path) over RTP; stops on caller DTMF if interruptible. |
| "StopPlayback" | Immediately stops active audio playback. |
| {"StartRecording": {"direction": "Both"}} | Starts zero-thread WAV recording ('Both' for 2-ch L/R stereo, 'InboundRtp', or 'OutboundRtp'). |
| "StopRecording" | Finalizes the WAV RIFF header and closes the recording file. |
| {"BridgeToSipEndpoint": {"endpoint_uri": "sip:...", "caller_id": "+1...", "codec": 0, "timeout_ms": 20000}} | Originates a co-located B2BUA child leg (reusing parent sockets) and hairpin-bridges audio. |
| {"StartBridge": {"leg_a": {...}, "leg_b": {...}}} / "StopBridge" | Starts or tears down a low-level UDP RTP hairpin bridge. |
| "StartAudioStream" / "StopAudioStream" | Attaches or detaches call RTP to/from a registered WebSocket AudioStream. |
| "InterruptAudioStream" | Sub-frame (<1ms) AI barge-in: flushes queued outbound TTS frames without closing the WebSocket. |
| {"SetMetadata": {"metadata": {"disposition": "qualified"}}} | Merges key-value pairs into session metadata for webhooks and the final Session CDR. |
CALL_ID="api-1793154798428319-1892683"
# Start interruptible audio playback
curl -X POST "http://127.0.0.1:8080/calls/${CALL_ID}/commands" \
-H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" \
-d '{"StartPlayback": {"audio": "audio/menu_prompt.wav", "interruptible": true}}'
# Co-located B2BUA bridge to live agent SIP URI
curl -X POST "http://127.0.0.1:8080/calls/${CALL_ID}/commands" \
-H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" \
-d '{"BridgeToSipEndpoint": {"endpoint_uri": "sip:+18005559999@sip.sipsmart.io:5060", "caller_id": "+13235550116", "codec": 0, "timeout_ms": 20000}}'
# Sub-frame (<1ms) AI Barge-In & Hangup
curl -X POST "http://127.0.0.1:8080/calls/${CALL_ID}/commands" \
-H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" \
-d '"InterruptAudioStream"'6. Conversational AI Bidirectional Audio Streaming (:8083)
Stream raw 8 kHz G.711 μ-law (PCMU, 160 bytes per 20ms frame) audio between active SIP calls and STT/LLM/TTS voice agents with zero heap growth and 0.85 ms sub-frame barge-in interruption.
import asyncio, json, requests, websockets
SIPCORE_HTTP = "http://127.0.0.1:8080"
HEADERS = {"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"}
async def run_ai_voice_stream(call_id: str):
res = requests.post(f"{SIPCORE_HTTP}/calls/{call_id}/audio-stream/start", headers=HEADERS, json={})
res.raise_for_status()
ws_url = res.json()["ws_url"] # ws://<host>:8083/calls/{call_id}/audio-stream/ws
async with websockets.connect(ws_url) as ws:
start_msg = json.loads(await ws.recv())
async for msg in ws:
if isinstance(msg, bytes):
# 160 bytes (20ms) of 8kHz G.711 PCMU caller audio -> forward to STT
# Inject 160-byte TTS G.711 PCMU frame back to caller:
await ws.send(bytes([0xFF] * 160))
elif json.loads(msg).get("type") == "stop":
break
requests.post(f"{SIPCORE_HTTP}/calls/{call_id}/audio-stream/stop", headers=HEADERS, json={})7. DTMF Long-Polling, Lifecycle Events & Webhooks
# Long-poll up to 8000ms for an RFC 4733 DTMF digit
curl -s "http://127.0.0.1:8080/calls/${CALL_ID}/wait-dtmf?timeout_ms=8000"
# Fetch chronological lifecycle events for a call
curl -s -H "Authorization: Bearer YOUR_API_TOKEN" "http://127.0.0.1:8080/calls/${CALL_ID}/events" | jq .
# Configure global webhook URL
curl -X POST "http://127.0.0.1:8080/webhooks/config" \
-H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" \
-d '{"url": "https://your-app.example.com/webhooks/sipcore-events"}'8. Session CDRs & WAV Recording Retrieval (/cdr & /recordings)
Retrieve rich Session CDRs (with millisecond timestamps, detected beep Hz/confidence, SIP/Q.850 outcomes, and STIR/SHAKEN status) and download or purge recorded stereo WAV files directly over HTTP.
# Query Session CDR
curl -s -H "Authorization: Bearer YOUR_API_TOKEN" "http://127.0.0.1:8080/cdr/${CALL_ID}" | jq .
# Download recorded WAV file (audio/wav)
curl -s -H "Authorization: Bearer YOUR_API_TOKEN" \
"http://127.0.0.1:8080/recordings/${CALL_ID}" -o call.wav
# Delete local WAV after archiving to object storage
curl -s -X DELETE -H "Authorization: Bearer YOUR_API_TOKEN" \
"http://127.0.0.1:8080/recordings/${CALL_ID}"{
"schema_version": 1,
"session_id": "api-1793154798428319-1892683",
"call_id": "api-1793154798428319-1892683",
"direction": "outbound",
"from": "+18005550199",
"to": "+13235550116",
"duration_ms": 19401,
"billsec_ms": 16710,
"hangup_cause": "NORMAL_CLEARING",
"final_state": "Completed",
"amd_result": "MACHINE",
"beep_detected": true,
"beep_frequency_hz": 740.0,
"beep_confidence": 0.977,
"playback_completed": true,
"sip_outcome": { "raw_status_code": 200, "raw_reason_phrase": "OK", "normalized_disposition": "ANSWERED" },
"q850_outcome": { "mapped_cause": 16, "mapped_text": "NORMAL_CLEARING" },
"recording_summary": { "recording_enabled": true, "recording_duration_seconds": 17 },
"stir_summary": { "stir_profile_id": "default", "attestation": "A", "status": "signed" }
}9. Dynamic Runtime Configuration: Carriers, Routes, Targets & Scripts
Hot-update outbound SIP trunks, regex routing rules, inbound SIP targets, and declarative call-flow scripts with zero process restarts.
curl -X POST "http://127.0.0.1:8080/carriers" \
-H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" \
-d '{"prefix": "+", "addr": "sip.sipsmart.io:5060", "domain": "sip.sipsmart.io", "name": "sipsmart-primary", "priority": 1}'
curl -X POST "http://127.0.0.1:8080/scripts" \
-H "Authorization: Bearer YOUR_API_TOKEN" -H "Content-Type: application/json" \
-d '{
"name": "amd_rvm_drop",
"rules": [
{ "condition": "OnAnswer", "actions": ["StartAmd"] },
{ "condition": "OnAmdHuman", "actions": [{"StartPlayback": {"audio": "HumanAudio", "interruptible": true}}] },
{ "condition": "OnAmdMachine", "actions": ["StartBeepDetection"] },
{ "condition": "OnBeepDetected", "actions": ["StopBeepDetection", {"StartPlayback": {"audio": "VoicemailAudio", "interruptible": false}}] },
{ "condition": "OnPlaybackCompleted", "actions": ["Hangup"] }
]
}'10. Admin Wire-Trace (:8082) & FreeSWITCH ESL Adapter (:8021)
Inspect raw SIP messages and ES256 STIR/SHAKEN Identity headers from the zero-disk ring buffer on port :8082, or point existing FreeSWITCH mod_event_socket dialers directly at TCP port :8021.
# 1. Inspect recent & per-call SIP wire traces (:8082)
curl -s http://127.0.0.1:8082/admin/traces/recent | jq .
curl -s http://127.0.0.1:8082/admin/traces/call/api-1793154798428319-1892683 | jq .
# 2. Connect a legacy FreeSWITCH ESL client directly to TCP :8021
$ nc 127.0.0.1 8021
Content-Type: auth/request
auth ClueCon
Content-Type: command/reply
Reply-Text: +OK accepted
event plain ALL
Content-Type: command/reply
Reply-Text: +OK event listener enabled
bgapi originate {origination_caller_id_number=+18005550199,sipcore_wait_for_beep=true}sofia/gateway/sipsmart/+13235550116 &playback(/opt/sipcore/media/rvm_drop.wav)
Content-Type: command/reply
Reply-Text: +OK Job-UUID: d4f8a102-8b3e-4c91-9a12-7c8e9f001122