LineVaults
Documentation · reference

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

WebSocket URL · TLS only
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.

MethodWhereFormat
Bearer header (preferred)HandshakeAuthorization: Bearer amd_live_…
Key headerHandshakeX-API-Key: amd_live_…
In the start messageFirst 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

  1. ConnectAt answer, one connection per call, key on the handshake.
  2. StartOptional text frame naming the call.
  3. StreamBinary audio frames in real time from the moment of answer.
  4. VerdictOne text frame from the server.
  5. 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

MessageFrameRequiredContent
startTextNo{"type": "start", "call_id": "c-20931"}. call_id: your identifier for the call, max. 64 characters, displayed in call logs.
AudioBinaryYesRaw PCM as defined in section 5.
closeTextNo{"type": "close"} when the call ends before a verdict. The server decides at once from the audio received.

5. Audio format

PropertyValue
Sample rate8,000 Hz
EncodingSigned 16-bit linear PCM, little-endian (Asterisk "slin")
Channels1: the called party's side only
Frame size100 ms (1,600 bytes) recommended; any size accepted
Start pointThe moment of answer

6. Verdict message

server → client · one text frame
{"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}
FieldTypeDescription
statusbooleantrue when the message is a verdict.
amdstatusstringOne of HUMAN, MACHINE, FALLBACK. Equals HUMAN if and only if amdcause equals HUMAN.
amdcausestringThe reason; see sections 7 and 8.
confidencenumberRange 0–1. Certainty of the stage that produced the verdict.
p_humannumberRange 0–1. Model estimate that the answering party is a person.
tonestringEmpty unless a tone or a known recording settled the call. Values: busy, reorder, sit, fax, ringback; repeat:… for a matched recording.
audio_msintegerAudio received, in milliseconds.
window_msintegerDecision window applied: 2000 or 3200.
extendedbooleantrue if the decision needed the 3.2 s window.
elapsed_msintegerServer-side milliseconds between connection open and verdict.

7. Result causes

amdcauseamdstatusMeaning
HUMANHUMANA live person.
MACHINEMACHINEVoicemail greeting or other recorded speech, including recorded "Hello?" robots.
SCREENINGMACHINEAnswered by a screening assistant.
SILENCEMACHINENo speech in the analyzed audio.
TONEMACHINESpecial information tone, fax, ringback, dial tone or voicemail beep.
BUSYMACHINEBusy signal or reorder (fast busy).
UNKNOWNMACHINENo 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"}
amdcauseCondition
AUTHKey missing or not recognized, or presented on a hostname belonging to a different brand.
SUSPENDEDKey or account disabled.
QUOTASandbox allowance for the month exhausted, or the account has an overdue payment.
CONCURRENCYSimultaneous calls in progress for the account already equal the plan's concurrency limit.
CPSNew-call rate exceeded the plan's calls-per-second limit.
NOSERVERService temporarily unable to judge calls. Also set locally by the clients when no connection could be made.
Errors after streaming has started (a timeout, a dropped connection) are not FALLBACK. Clients must map them to MACHINE / UNKNOWN; agents receive confirmed people only.

9. Timing

ParameterValue
Standard decisionAt 2.0 s of received audio
Extended decision, unclear calls onlyAt 3.2 s of received audio
Early decision on a pauseA 0.6 s gap in the audio, provided ≥ 1 s was received
Early decision on close or disconnectImmediate, from the audio received
Wait for an api_key start messageUp to 1 s
Recommended client timeout4,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 HUMAN or MACHINE counts as one call.
  • FALLBACK answers 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.

judge.py · Python 3.8+ · pip install websockets
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.

Sandbox · 50,000 calls a month · no card

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.