AMD WebSocket API reference
The LineVaults AMD WebSocket API uses one connection per answered call: audio frames go in, a single JSON verdict comes out. This reference defines the endpoint, authentication, message formats, result codes and timing. VICIdial, Asterisk and FreeSWITCH users can use the ready-made clients instead; see the VICIdial install guide and the FreeSWITCH integration.
1. Endpoint
wss://amd.linevaults.com/
Customers of a private label partner connect to their provider's hostname instead. A key works only on the hostname of the brand that issued it.
2. Authentication
Every connection carries an API key of the form amd_live_…. Issue and revoke keys under WS keys in the dashboard. Source IP addresses are not registered or checked; possession of the key is the only credential.
| Method | Where | Format |
|---|---|---|
| Bearer header (preferred) | Handshake | Authorization: Bearer amd_live_… |
| Key header | Handshake | X-API-Key: amd_live_… |
| In the start message | First text frame | "api_key": "amd_live_…"; for clients that can't set headers. The server waits up to 1 s for it. |
3. Session lifecycle
- ConnectAt answer, one connection per call, key on the handshake.
- StartOptional text frame naming the call.
- StreamBinary audio frames in real time from the moment of answer.
- VerdictOne text frame from the server.
- CloseAfter sending the verdict, the server ignores further audio and ends the session.
Keep streaming until the verdict arrives. If the key or account is refused, the verdict is a FALLBACK that arrives at once, before any audio is used.
4. Client messages
| Message | Frame | Required | Content |
|---|---|---|---|
start | Text | No | {"type": "start", "call_id": "c-20931"}. call_id: your identifier for the call, max. 64 characters, displayed in call logs. |
| Audio | Binary | Yes | Raw PCM as defined in section 5. |
close | Text | No | {"type": "close"} when the call ends before a verdict. The server decides at once from the audio received. |
5. Audio format
| Property | Value |
|---|---|
| Sample rate | 8,000 Hz |
| Encoding | Signed 16-bit linear PCM, little-endian (Asterisk "slin") |
| Channels | 1: the called party's side only |
| Frame size | 100 ms (1,600 bytes) recommended; any size accepted |
| Start point | The moment of answer |
6. Verdict message
{"status": true, "amdstatus": "MACHINE", "amdcause": "SCREENING", "confidence": 0.91, "p_human": 0.04,
"tone": "", "audio_ms": 2000, "window_ms": 2000, "extended": false, "elapsed_ms": 2008}
| Field | Type | Description |
|---|---|---|
status | boolean | true when the message is a verdict. |
amdstatus | string | One of HUMAN, MACHINE, FALLBACK. Equals HUMAN if and only if amdcause equals HUMAN. |
amdcause | string | The reason; see sections 7 and 8. |
confidence | number | Range 0–1. Certainty of the stage that produced the verdict. |
p_human | number | Range 0–1. Model estimate that the answering party is a person. |
tone | string | Empty unless a tone or a known recording settled the call. Values: busy, reorder, sit, fax, ringback; repeat:… for a matched recording. |
audio_ms | integer | Audio received, in milliseconds. |
window_ms | integer | Decision window applied: 2000 or 3200. |
extended | boolean | true if the decision needed the 3.2 s window. |
elapsed_ms | integer | Server-side milliseconds between connection open and verdict. |
7. Result causes
| amdcause | amdstatus | Meaning |
|---|---|---|
HUMAN | HUMAN | A live person. |
MACHINE | MACHINE | Voicemail greeting or other recorded speech, including recorded "Hello?" robots. |
SCREENING | MACHINE | Answered by a screening assistant. |
SILENCE | MACHINE | No speech in the analyzed audio. |
TONE | MACHINE | Special information tone, fax, ringback, dial tone or voicemail beep. |
BUSY | MACHINE | Busy signal or reorder (fast busy). |
UNKNOWN | MACHINE | No class reached sufficient confidence; route as a machine. |
8. FALLBACK causes
FALLBACK signals that no judgment will be made. It is returned on connect, before audio is processed, leaving the dialer time to apply its own detection:
{"status": true, "amdstatus": "FALLBACK", "amdcause": "QUOTA"}
| amdcause | Condition |
|---|---|
AUTH | Key missing or not recognized, or presented on a hostname belonging to a different brand. |
SUSPENDED | Key or account disabled. |
QUOTA | Sandbox allowance for the month exhausted, or the account has an overdue payment. |
CONCURRENCY | Simultaneous calls in progress for the account already equal the plan's concurrency limit. |
CPS | New-call rate exceeded the plan's calls-per-second limit. |
NOSERVER | Service temporarily unable to judge calls. Also set locally by the clients when no connection could be made. |
FALLBACK. Clients must map them to MACHINE / UNKNOWN; agents receive confirmed people only.9. Timing
| Parameter | Value |
|---|---|
| Standard decision | At 2.0 s of received audio |
| Extended decision, unclear calls only | At 3.2 s of received audio |
| Early decision on a pause | A 0.6 s gap in the audio, provided ≥ 1 s was received |
Early decision on close or disconnect | Immediate, from the audio received |
Wait for an api_key start message | Up to 1 s |
| Recommended client timeout | 4,500 ms from connect; shorter timeouts turn slow verdicts into lost people |
Plan limits on concurrent calls and calls per second are listed on the pricing page.
10. Billing and recording
- Each verdict of
HUMANorMACHINEcounts as one call. FALLBACKanswers and health checks are never counted.- If the account records audio, only the seconds the model heard are kept, for the account's retention period (1 to 90 days). Recording can be turned off.
- Counting and recording happen after the verdict is sent and never delay it.
11. Health checks
Send a start message with "call_id": "__healthcheck__" followed by 2 s of silence. The expected verdict is MACHINE / SILENCE. Health checks are not billed, not recorded and never listened to longer than 2 s.
12. Example client
A synchronous Python client using the websockets package. It streams a WAV file in real time and stops as soon as a verdict arrives, as a dialer would.
import json, sys, time, wave
from websockets.sync.client import connect
URL = "wss://amd.linevaults.com/"
def judge(path, key, call_id="test-1"):
deadline = time.monotonic() + 4.5 # client timeout
with connect(URL, additional_headers={"Authorization": "Bearer " + key}) as ws:
ws.send(json.dumps({"type": "start", "call_id": call_id}))
with wave.open(path) as w: # 8 kHz, mono, 16-bit
frame = w.readframes(800) # 800 samples = 100 ms
while frame:
ws.send(frame)
try: # also paces the stream in real time
return json.loads(ws.recv(timeout=0.1))
except TimeoutError:
frame = w.readframes(800)
ws.send(json.dumps({"type": "close"})) # file ended first: decide now
return json.loads(ws.recv(timeout=max(0.1, deadline - time.monotonic())))
print(judge(sys.argv[1], sys.argv[2]))
Run it as python3 judge.py answer.wav amd_live_…. A production client should also treat a timeout or closed connection after streaming began as MACHINE / UNKNOWN, as described in section 8. Accuracy figures for the service are on the benchmarks page.
Put a verdict on every answered call
Run it on one campaign next to your current AMD and compare. If the service can't help, your dialer falls back to Asterisk AMD() on its own.