SipCore by SipSmart logoSipCore by SipSmart logo
SipCore™ Carrier Media & SIP Engine — Official Developer Reference

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:

Certified Live-Environment Capacity Reference — AWS EC2 c6in (6th-Gen, 60s ACD, Bidirectional 20 ms G.711 + CDRs)
Tested on 6th-Gen AWS c6in (not even c7/c8) vs. Asterisk 22.11 LTS & FreeSWITCH 1.11
AWS InstanceSipCore™ VoiceSipCore™ + AMDSipCore™ + AMD + Stereo Recvs. Asterisk / FreeSWITCH
4-Core (c6in.xlarge)150 CPS • 9,046 sess88 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 sess195 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 sess410 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 sess840 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.

Core Control & Media API:8080
HTTP / JSON

Outbound origination, 18 mid-call commands, DTMF long-polling, events, CDRs, WAV recordings & dynamic config.

AI Voice Stream Bridge:8083
WebSocket (Binary + JSON)

Full-duplex 20ms G.711 μ-law (160-byte) audio streaming between caller RTP and AI voice agents (<1ms barge-in).

Admin & Wire-Trace API:8082
HTTP / JSON

Zero-disk in-memory raw SIP packet and ES256 STIR/SHAKEN Identity header inspection.

FreeSWITCH ESL Emulator:8021
TCP (mod_event_socket)

Stateful Event Socket Layer adapter translating auth, event plain ALL & bgapi originate.

Base Endpoints & Bearer Authentication
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/json

2. Complete 34-Endpoint & Socket Catalog

CategoryMethodPath / InterfacePortDescription
Health & TelemetryGET/health:8080Liveness probe returning {"status":"ok"}
Health & TelemetryGET/ready:8080Readiness probe (200 OK when SIP & RTP pools are ready; 503 while draining)
Health & TelemetryGET/status:8080Node version, uptime, worker count, active calls/streams/bridges & queue depths
Health & TelemetryGET/metrics:8080Lock-free AtomicU64 operational counters for calls, AMD, beeps, RTP & bridges
Call OriginationPOST/calls/outbound:8080Canonical outbound origination: failover routes[], sip_headers, multi-codec audio, DSP modules, webhooks & STIR/SHAKEN
Call OriginationPOST/calls:8080Simplified outbound call origination (destination, caller_id, human_audio, voicemail_audio)
Call StateGET/calls/{call_id}:8080Real-time state machine status of an active call
Mid-Call ControlPOST/calls/{call_id}/commands:8080Dispatch 18 real-time mid-call commands (Hangup, StartAmd, StartBeepDetection, StartPlayback, StartRecording, BridgeToSipEndpoint, InterruptAudioStream, SetMetadata, etc.)
AI Audio StreamPOST/calls/{call_id}/audio-stream/start:8080Allocate a bidirectional AI WebSocket audio stream and return ws_url
AI Audio StreamGET/calls/{call_id}/audio-stream/ws:8080Check stream readiness and fetch WebSocket URL for call_id
AI Audio StreamWS/calls/{call_id}/audio-stream/ws:8083Full-duplex 20ms G.711 μ-law (160-byte) binary audio WebSocket (<1ms barge-in)
AI Audio StreamPOST/calls/{call_id}/audio-stream/stop:8080Stop and deregister an active WebSocket audio stream
DTMF & EventsGET/calls/{call_id}/wait-dtmf?timeout_ms={ms}:8080Long-poll up to 30,000 ms for a caller RFC 4733 DTMF digit
DTMF & EventsGET/calls/{call_id}/events:8080Chronological lifecycle events (ExternalEvent[]) for a specific call
DTMF & EventsGET/events:8080The 100 most recent lifecycle events across the node
DTMF & EventsPOST/webhooks/config:8080Configure global webhook URL for real-time HTTP POST event delivery
CDRs & RecordingsGET/cdr/{call_id}:8080Complete Session CDR JSON (legs, beep_frequency_hz, SIP/Q.850 outcomes, STIR/SHAKEN)
CDRs & RecordingsGET/cdr?from={epoch}&to={epoch}&limit={n}:8080Query historical Session CDR records within a timestamp window
CDRs & RecordingsGET/recordings/{call_id}:8080Download recorded WAV file (audio/wav) for call_id (Bearer token required)
CDRs & RecordingsDELETE/recordings/{call_id}:8080Delete local WAV recording on SipCore after upstream S3 upload (Bearer token required)
Dynamic ConfigGET/config:8080Retrieve active SipCoreConfig runtime settings
Dynamic ConfigGET/carriers:8080List configured outbound SIP carrier trunks
Dynamic ConfigPOST/carriers:8080Dynamically add and persist an outbound SIP carrier trunk
Dynamic ConfigGET/routes:8080List regex dialplan routing patterns
Dynamic ConfigPOST/routes:8080Dynamically add and persist a dialplan routing rule
Dynamic ConfigGET/inbound-targets:8080List registered inbound SIP target URIs
Dynamic ConfigPOST/inbound-targets:8080Add an inbound SIP target URI
Dynamic ConfigDELETE/inbound-targets/{target}:8080Remove an inbound SIP target URI
Dynamic ConfigGET/scripts:8080List declarative call-flow scripts
Dynamic ConfigPOST/scripts:8080Register or replace a named declarative call-flow script
Admin Wire-TraceGET/admin/health:8082Health check for Admin & Wire-Trace HTTP server
Admin Wire-TraceGET/admin/traces/recent:8082Summaries of the 50 most recent traced SIP calls
Admin Wire-TraceGET/admin/traces/call/{call_id}:8082Raw inbound/outbound SIP packets & STIR/SHAKEN Identity headers for call_id
FreeSWITCH ESLTCPauth / event / api / bgapi originate:8021Stateful 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.

GET /status & GET /metrics
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 .
Sample Response — GET /status (200 OK)
{
  "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).

FieldTypeReq.Description
tostringYesDestination E.164 phone number with leading "+" (e.g. "+13235550116").
fromstringYesOrigination Caller ID in E.164 format (e.g. "+18005550199").
route / routesobject | arrayYesSingle carrier route {next_hop, domain, transport} or ordered failover array routes[]. Each leg is freshly ES256 STIR/SHAKEN signed.
mediaarrayYesNon-empty list of clips: [{source: {path: "/opt/..." } | {url: "https://..."}, hangup_after: true, interruptible: false}]. Supports WAV, MP3, OGG, FLAC, AAC/M4A.
modulesarrayNoInline DSP modules: [{"beep_detection": true, "playback_on_beep": true}, {"recording": {"enabled": true, "direction": "both"}}].
sip_headersmap<string,string>NoCustom SIP headers written verbatim onto outbound INVITE (e.g. Diversion, X-Carrier-SID, P-Asserted-Identity). Wire-isolated from metadata.
events_url / cdr_urlstringNoPer-call HTTP POST webhook URLs for real-time ExternalEvent notifications and final Session CDR delivery.
answer_timeout_secondsnumberNoRing timeout in seconds per route attempt before failover (default: 30).
max_call_secondsnumberNoHard maximum call duration in seconds before automatic hangup (default: 120).
stir_profile_id / stir_attestationstringNoNamed signing profile (e.g. "default") and attestation override ("A", "B", or "C").
scriptstringNoOptional named declarative call-flow script to run automatically on answer.
metadataobjectNoArbitrary JSON echoed on webhooks & CDR (optional preferred_codec: "pcmu" | "pcma" | "g722" | "g729").
POST /calls/outbound — Multi-Route Failover + Beep Drop + Stereo Recording
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 BodyDescription
"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.
POST /calls/{call_id}/commands
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.

Full-Duplex AI Voice Agent Bridge (:8080 + WS :8083)
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

GET /wait-dtmf, GET /events & POST /webhooks/config
# 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.

GET /cdr/{call_id} & GET/DELETE /recordings/{call_id}
# 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}"
Sample Session CDR Payload
{
  "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.

Carriers, Routes, Inbound Targets & Scripts CRUD
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.

Admin Wire-Trace API (:8082) & FreeSWITCH ESL TCP Session (: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