Noesis
Find out who or what answered a phone call, live during the call or from a recording. Live over a WebSocket from Twilio, Plivo, Telnyx, Exotel, Vonage, FreeSWITCH, Asterisk, LiveKit, Pipecat or your own code, or from a recorded call.
Noesis tells you who or what answered a phone call: a person, a voicemail, an IVR menu, a hold queue or an automated voice agent. It listens for the whole call and tells you when the answer changes, for example from ivr to hold to human when a menu transfers you to a person.
Noesis runs on your DetectifAI account: the same API keys, the same credit balance and the same dashboard.
Two ways to use it
| Use | You send | You get back |
|---|---|---|
| Live calls | The callee's audio, streamed over a WebSocket for the whole call | A classification event for the first answer and for every change, then a summary |
| Recorded calls | A recorded call as a WAV file | The answers a live call would have received |
Base URLs
https://api.noesis.detectif.ai
wss://api.noesis.detectif.ai/v1/detect/streamEvery request needs an API key that is allowed to use Noesis. See Authentication.
Answers
| Label | Category | Meaning | Suggested action |
|---|---|---|---|
human |
human | A live person | Start the conversation |
ivr |
machine | An automated menu: press or say an option | Stay silent, keep listening |
hold |
machine | Waiting, queue music, or "connecting you to an agent" | Stay silent, keep listening |
ai_agent |
machine | An automated voice agent that says it is one | Stay silent, keep listening |
voicemail |
machine | A mailbox that can record a message | Leave a message or hang up |
announcement |
machine | A one-way recording: no menu, no message | Hang up |
unavailable |
machine | A carrier message: busy, invalid number, switched off, mailbox full | Hang up |
machine |
machine | A machine answered; the type is not known yet | Stay silent; a specific label usually follows |
unknown |
unknown | Not enough to tell yet | Wait |
Route on category if you only need to know whether a person or a machine answered.
How the answer behaves
- The first answer comes a few seconds after the callee starts to speak. If nobody speaks (silence or ringing), you get no answer rather than a guess.
- A line that announces a person ("connecting you to our sales team") is
hold, nothuman.humanfollows when the person speaks. - Once a person is confirmed, the answer stays
human, even if they say "please hold". - English, Hindi and Hinglish are supported.
- Answers are signals, not proof. Build your call flow so that it still works when the answer is
unknownor arrives late.
Never block a call on Noesis. If the connection fails or closes, carry on with the call as you would without it.
Recording
Calls you send to Noesis are recorded (audio and transcript) and kept for 30 days, unless you set record=false. See Data and recording.
Quickstart
Create a key for Noesis, get a stream token, stream a recorded call over the WebSocket and read the answers.
Stream a recorded call to Noesis and watch the answers arrive, exactly as they would on a live call.
1. Create an API key for Noesis
Sign in at us.platform.detectif.ai, open API keys and create a key that is allowed to use Noesis: noesis:detect to analyse calls, and noesis:read to read sessions and usage. The key is shown once; keep it in an environment variable:
export DETECTIF_API_KEY="dtf_live_..."2. Get a stream token
Code on your server can send the key in the Authorization header when it opens the WebSocket. Clients that cannot set headers, such as Twilio, use a stream token instead. This quickstart uses a token, so you see both steps:
curl -X POST https://api.noesis.detectif.ai/v1/detect/stream-tokens \
-H "Authorization: Bearer $DETECTIF_API_KEY"{"token": "ntk_4mZ0pQx7Lr2Vd9Kc1Ty6Wb3Ns8Hf5Ja0Ge2Ru7Xo4Il", "expires_at": "2026-10-19T10:05:00Z"}A token opens one call and expires after 5 minutes. The scripts below create their own token each time they run.
3. Stream a recording
A recording streamed in real time behaves like a live call. Python needs pip install websockets (version 14 or later); Node.js 18 or later needs npm install ws. Both read a 16-bit PCM mono WAV file.
# noesis_quickstart.py: stream a recording to Noesis as if it were a live call
import asyncio, json, os, sys, urllib.request, wave
import websockets
API = "https://api.noesis.detectif.ai"
STREAM = "wss://api.noesis.detectif.ai/v1/detect/stream"
def stream_token():
request = urllib.request.Request(
f"{API}/v1/detect/stream-tokens",
data=b"{}",
method="POST",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}", "Content-Type": "application/json"},
)
with urllib.request.urlopen(request, timeout=30) as response:
return json.load(response)["token"]
async def main(path):
with wave.open(path) as w: # 16-bit PCM WAV, mono
rate, pcm = w.getframerate(), w.readframes(w.getnframes())
url = f"{STREAM}?token={stream_token()}&encoding=pcm_s16le&sample_rate={rate}&call_id=test-1"
async with websockets.connect(url) as ws:
async def events():
try:
async for raw in ws:
e = json.loads(raw)
if e["type"] == "classification":
print(f'{e["t"]:6.1f}s {e["label"]} ({e["category"]})')
elif e["type"] == "summary":
print("final:", e["label"])
elif e["type"] == "error":
print("error:", e)
except websockets.ConnectionClosed as closed:
print("closed:", closed.rcvd.code if closed.rcvd else "")
reader = asyncio.create_task(events())
step = rate * 2 // 50 # 20 ms of audio per frame
for i in range(0, len(pcm), step):
await ws.send(pcm[i:i + step])
await asyncio.sleep(0.02) # real time, like a live call
await ws.send(json.dumps({"type": "end"}))
await reader # ends when Noesis closes the socket
asyncio.run(main(sys.argv[1]))// noesis-quickstart.mjs: stream a recording to Noesis as if it were a live call
import fs from "node:fs";
import WebSocket from "ws";
const API = "https://api.noesis.detectif.ai";
const STREAM = "wss://api.noesis.detectif.ai/v1/detect/stream";
const wav = fs.readFileSync(process.argv[2]); // 16-bit PCM WAV, mono
let rate, pcm;
for (let pos = 12; pos + 8 <= wav.length; ) {
const id = wav.toString("ascii", pos, pos + 4), size = wav.readUInt32LE(pos + 4);
if (id === "fmt ") rate = wav.readUInt32LE(pos + 12);
if (id === "data") { pcm = wav.subarray(pos + 8, pos + 8 + size); break; }
pos += 8 + size + (size % 2);
}
const res = await fetch(`${API}/v1/detect/stream-tokens`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.DETECTIF_API_KEY}`, "Content-Type": "application/json" },
body: "{}",
});
if (!res.ok) { console.error(await res.text()); process.exit(1); }
const { token } = await res.json();
const ws = new WebSocket(`${STREAM}?token=${token}&encoding=pcm_s16le&sample_rate=${rate}&call_id=test-1`);
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
ws.on("message", async (raw) => {
const e = JSON.parse(raw);
if (e.type === "classification") console.log(`${e.t.toFixed(1).padStart(6)}s ${e.label} (${e.category})`);
if (e.type === "summary") console.log("final:", e.label);
if (e.type === "error") console.error("error:", e);
if (e.type === "ready") {
const step = rate * 2 / 50; // 20 ms of audio per frame
for (let i = 0; i < pcm.length && ws.readyState === WebSocket.OPEN; i += step) {
ws.send(pcm.subarray(i, i + step));
await sleep(20); // real time, like a live call
}
if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: "end" }));
}
});
ws.on("close", (code) => { if (code !== 1000) console.log("closed:", code); });4. Run it and read the answers
Run python noesis_quickstart.py call.wav or node noesis-quickstart.mjs call.wav. The output looks like this:
3.2s ivr (machine)
13.0s hold (machine)
23.4s human (human)
final: humanIf the socket closes with an error, both scripts print the error event and the close code; see Errors.
- Each
classificationevent is an answer:labelsays who or what answered,categoryishuman,machineorunknown, andtis seconds into the call. See Answers. - A new
classificationarrives every time the answer changes. Act on the one with the highestseq. - After
{"type": "end"}you receive asummarywith the final answer, and the socket closes.
Convert other recordings first, for example ffmpeg -i call.mp3 -ac 1 -ar 16000 -sample_fmt s16 call.wav. Live calls need no conversion: see Stream protocol.
The call is recorded for 30 days. To try it without recording, create the token with {"record": false} as the request body. See Data and recording.
Authentication
Send your API key as a bearer token, on HTTP requests and on the WebSocket upgrade. Use a stream token for clients that cannot set headers.
Noesis uses your DetectifAI API keys. A key must be allowed to use Noesis:
| Permission | Allows |
|---|---|
noesis:detect |
Live calls, stream tokens and recorded calls |
noesis:read |
Sessions and usage |
Choose the permissions when you create a key under API keys in the dashboard. A key without them gets 403 with insufficient_scope.
HTTP requests
Send the key as a bearer token:
curl https://api.noesis.detectif.ai/v1/detect/usage \
-H "Authorization: Bearer $DETECTIF_API_KEY"The WebSocket
Send the same header on the WebSocket upgrade request:
import os
import websockets
async def open_stream():
return await websockets.connect(
"wss://api.noesis.detectif.ai/v1/detect/stream?encoding=mulaw&sample_rate=8000",
additional_headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"},
)import WebSocket from "ws";
const ws = new WebSocket("wss://api.noesis.detectif.ai/v1/detect/stream?encoding=mulaw&sample_rate=8000", {
headers: { Authorization: `Bearer ${process.env.DETECTIF_API_KEY}` },
});Stream tokens
Some clients cannot set headers on a WebSocket: Twilio <Stream>, a browser, or a telephony provider where you only enter a URL. For these, your server creates a stream token for each call and the client passes it instead of the key:
- In the URL:
wss://api.noesis.detectif.ai/v1/detect/stream?token=ntk_... - On Twilio:
<Parameter name="token" value="ntk_..."/>inside<Stream>. See Twilio. The token then arrives in Twilio'sstartmessage, which must come within 10 seconds of the socket opening and in its first 3 messages; otherwise the socket closes with4401.
curl -X POST https://api.noesis.detectif.ai/v1/detect/stream-tokens \
-H "Authorization: Bearer $DETECTIF_API_KEY" \
-H "Content-Type: application/json" \
-d '{"record": true}'import os
import requests
resp = requests.post(
"https://api.noesis.detectif.ai/v1/detect/stream-tokens",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"},
json={"record": True},
timeout=10,
)
token = resp.json()["token"]const res = await fetch("https://api.noesis.detectif.ai/v1/detect/stream-tokens", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.DETECTIF_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ record: true }),
});
const { token } = await res.json();- A token opens one call. It expires 5 minutes after it is created if it has not been used.
- It belongs to the key and account that created it, and carries the key's Noesis permission.
record(optional, defaulttrue) sets whether the call is recorded. See Data and recording.- Create tokens on your server, right before the call. Never create them in browser or app code, because that needs the API key.
Keep keys out of URLs
Never put an API key in a URL. A request with ?api_key= is refused with api_key_in_url; rotate a key that was sent that way. Never put an API key in browser or mobile app code: give those clients a stream token from your server.
When a key or token is refused
| HTTP | WebSocket close code | Meaning |
|---|---|---|
401 |
4401 |
The key is missing, mistyped or revoked, or the token is invalid, expired or already used, or a Twilio-style token did not arrive within 10 seconds and the first 3 messages |
403 |
4403 |
The key is not allowed to use Noesis, or the account's email address is not verified |
See Errors.
Stream protocol
Connect a live call over the WebSocket: audio formats, the messages you send, the events you receive, limits, credits and close codes.
One WebSocket per call. Stream the callee's audio for the whole call, and receive the first answer and every change.
wss://api.noesis.detectif.ai/v1/detect/streamOpen the socket as soon as the call is answered and stream the callee's audio in real time. Keep it open for the whole call: a transfer to a person can happen minutes in. Authenticate with the Authorization header on the upgrade request, or with a stream token in ?token=; see Authentication.
Query parameters
| Parameter | Values | Default |
|---|---|---|
encoding |
mulaw, alaw or pcm_s16le |
mulaw |
sample_rate |
8000, 16000, 22050, 24000, 44100 or 48000 |
8000 |
channels |
1: the callee only. 2: the callee and your agent on separate channels |
1 |
remote_channel |
The callee's channel when channels=2: 0 or 1 |
0 |
language |
Optional hint, en or hi. Leave it out for automatic (English, Hindi, Hinglish) |
automatic |
call_id |
Your reference for the call, up to 200 characters, returned in every event | none |
transcripts |
true to also receive what the callee says, for debugging |
false |
record |
false to not record this call. See Data and recording |
true |
token |
A stream token, for clients that cannot set the Authorization header |
none |
callback_url and other webhook settings are not available; a socket that sets them is refused with unsupported_parameter. Answers arrive on the socket, and later through sessions.
Audio
| Audio | Accepted |
|---|---|
| Encoding | G.711 μ-law (mulaw), G.711 A-law (alaw), or 16-bit linear PCM, little-endian (pcm_s16le) |
| Sample rate | 8, 16, 22.05, 24, 44.1 or 48 kHz |
| Channels | Mono (the callee only), or stereo with your agent on the other channel |
| Framing | Binary WebSocket frames, or Twilio and Plivo media-stream JSON |
Compressed audio such as Opus, MP3, AAC or G.729 is not accepted: decode it to PCM first. Most telephony platforms already give you μ-law or PCM. Set encoding and sample_rate to what you send; the audio is not converted.
Messages you send
| Message | When |
|---|---|
| Binary audio | The callee's audio, 20 to 100 ms per frame, in real time from the moment the call is answered |
{"event": "media", ...} |
Twilio or Plivo media-stream JSON, unchanged. The inbound track is the callee; an outbound track is your agent. A start message sets call_id from the call's ID; stop ends the call. A media message whose payload is not valid base64 is ignored and not billed |
{"type": "agent.speech", "state": "started"} and {"type": "agent.speech", "state": "ended"} |
Optional: when your agent starts and stops talking, if its audio is not on a second channel or track. It helps Noesis recognise a person sooner |
{"type": "end"} |
On hang-up. You receive the summary and the socket closes |
{"type": "ping"} |
Keep-alive, answered with {"type": "pong"} |
Events you receive
// once, when the socket opens
{"type": "ready", "session_id": "9f2c4e7a1b3d4c5e8f602a7b9c1d3e4f", "call_id": "your-id", "t": 0.0,
"audio": {"encoding": "mulaw", "sample_rate": 8000, "channels": 1}}
// the first answer, then one event per change
{"type": "classification", "seq": 2, "t": 13.0,
"label": "hold", "category": "machine", "confidence": 0.8,
"previous_label": "ivr", "change": "transition",
"session_id": "9f2c4e7a1b3d4c5e8f602a7b9c1d3e4f", "call_id": "your-id"}
// after {"type": "end"} (or a Twilio or Plivo "stop")
{"type": "summary", "label": "human", "category": "human", "timeline": [ ... ]}
{"type": "usage", "session_id": "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f", "operation_id": "op_6f1ed002ab5595859014ebf0951522d9",
"billed_seconds": 27}| Field | Meaning |
|---|---|
session_id |
An ID for the call, to look it up later in sessions. See Two session IDs |
call_id |
Your reference: from the URL, a Twilio <Parameter name="call_id">, or else the call ID in the Twilio or Plivo start message (the CallSid, or Plivo's call ID). It is in ready too when the start message is sent as soon as the socket opens, without waiting for ready, as Twilio and Plivo do |
seq |
Increases with every event. Act on the highest you have seen |
t |
Seconds since the socket opened |
label, category |
The answer. See Answers |
confidence |
0 to 1 |
change |
initial: the first answer. transition: person and machine swapped, or a transfer to hold. refinement: a more specific label, such as machine to voicemail |
billed_seconds |
In the usage event at the end: the seconds of call audio billed for this call |
operation_id |
In the usage event: the call's billing record |
| Other fields | Events may carry more fields than these. Ignore the ones you do not use |
With transcripts=true you also receive {"type": "transcript", ...} events with what the callee said.
Two session IDs
A call has two session IDs, and both find the same call:
- The
ready,classificationandsummaryevents carry the ID the analysis gives the call when the socket opens. - The
usageevent carries the call's ID in your account. It is the same ID a stream token gives you before the call starts.
Both are 32 lowercase hexadecimal characters, such as 5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f, and GET /v1/detect/sessions/{session_id} accepts either. In the session you get back, session_id is the account's ID and stream_session_id is the one from ready. An ID in another form, such as a UUID with dashes, returns 404.
A typical transfer
| Time | Label | On the line |
|---|---|---|
| 3.2 s | ivr |
"For credit cards, press one." |
| 13.0 s | hold |
"Please hold while we connect you to a customer associate." |
| 23.4 s | human |
"Hi, this is Priya. How can I help you?" |
Ending a call
Send {"type": "end"} when the call ends (a Twilio or Plivo stop does the same). You receive the summary and a usage event, then the socket closes with code 1000.
Rarely, the usage of a call that ended normally cannot be recorded at once. Then an error event with the code settlement_delayed comes instead of the usage event, and the socket still closes with 1000. Nothing is lost and you need not do anything: the usage is recorded a little later, and the session shows it then. See Errors.
If you close the socket without end, the call still ends and its result is kept in the session, but the summary is not sent to you.
Limits
| Limit | Value |
|---|---|
| Binary audio frame | Up to 192,000 bytes; 20 to 100 ms of audio is best |
| JSON message | Up to 384,000 characters |
| Any frame | Up to 1 MiB (1,048,576 bytes). A larger frame closes the socket with code 1009 |
| One call | Up to 2 hours |
| Silence on the socket | The socket closes after 15 minutes without any message |
| Calls at the same time | Set by your plan. A call over the limit is refused with 429 and close code 4429 |
A binary frame over 192,000 bytes or a JSON message over 384,000 characters, up to 1 MiB, gets an error event with status 413: it is not analysed and not billed, and the socket stays open. A frame over 1 MiB closes the socket with 1009, without an event.
Credits
Live calls are charged for each started minute of audio Noesis receives: a 40-second call is charged for one minute, a 2-minute 10-second call for three. A call that sends less than a second of audio is not billed. Your balance is on the dashboard Overview page.
If your balance runs out during a call, you receive {"type": "error", "code": "insufficient_credits", ...} and the socket closes with code 4402. The audio already received is billed. Carry on with the call without detection, and add credits before the next one.
Close codes
| Close code | HTTP status in the error event |
Meaning | What to do |
|---|---|---|---|
1000 |
The call ended normally after end, or the socket was silent for 15 minutes, or the call passed 2 hours (408) |
Open one socket per call | |
1003 |
400 |
A parameter is invalid or not available, such as callback_url; the message names it |
Fix the URL |
1009 |
A frame was larger than 1 MiB. No error event is sent |
Send 20 to 100 ms of audio per frame | |
1011 |
500 |
Something failed on our side during the call. The audio received until then is billed | Carry on with the call without detection |
1013 |
503 |
Busy, or temporarily unavailable | Carry on with the call without detection |
4401 |
401 |
The key or stream token is missing, invalid, expired or already used, or a token sent in a Twilio-style start message did not arrive within 10 seconds and the first 3 messages |
Check the key, or create a new token |
4402 |
402 |
The credit balance ran out (insufficient_credits) |
Add credits in the dashboard |
4403 |
403 |
The key is not allowed to use Noesis, or the email address is not verified | Use a key with noesis:detect |
4429 |
429 |
Too many calls at once, or new calls too fast | Wait for a call to end |
Before closing with an error code, Noesis sends an error event with the details (not for 1009). Events about a single message, such as the 413 for a frame that is too large, do not close the socket. See Errors.
Recorded calls
Upload a recorded call as a WAV file and get back the answers a live call would have received.
Upload a recorded call as a WAV file and get back the answers a live call would have received. Use it to test Noesis on your own calls before you connect live ones.
POST https://api.noesis.detectif.ai/v1/detect/fileThe recording goes through the same analysis as a live call, in real time, so the labels and their timing are what a live call would have given. The request therefore takes about as long as the recording.
Send a file
Send the file as a multipart field named file, with an Idempotency-Key so a retry does not analyse it twice:
curl https://api.noesis.detectif.ai/v1/detect/file \
-H "Authorization: Bearer $DETECTIF_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-F "file=@call.wav" \
-F "call_id=test-1"# analyse_call.py: send a recorded call to Noesis and print the answers
import os, sys, uuid
import requests
with open(sys.argv[1], "rb") as f:
r = requests.post(
"https://api.noesis.detectif.ai/v1/detect/file",
headers={
"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
data={"call_id": "test-1"},
files={"file": f},
timeout=60, # between bytes: a newline arrives every 5 s
)
result = r.json()
if r.status_code != 200 or result.get("type") == "error":
sys.exit(result) # not a WAV file, balance too low, ...
for e in result["timeline"]:
print(f'{e["t"]:6.1f}s {e["label"]} ({e["category"]})')
print("final:", result["final"]["label"] if result["final"] else "no speech heard")// analyse-call.mjs: send a recorded call to Noesis and print the answers (Node.js 18+)
import fs from "node:fs";
import { randomUUID } from "node:crypto";
const form = new FormData();
form.append("file", new Blob([fs.readFileSync(process.argv[2])]), "call.wav");
form.append("call_id", "test-1");
const r = await fetch("https://api.noesis.detectif.ai/v1/detect/file", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.DETECTIF_API_KEY}`, "Idempotency-Key": randomUUID() },
body: form,
});
const result = await r.json();
if (!r.ok || result.type === "error") { console.error(result); process.exit(1); }
for (const e of result.timeline) console.log(`${e.t.toFixed(1).padStart(6)}s ${e.label} (${e.category})`);
console.log("final:", result.final ? result.final.label : "no speech heard");The Python and Node.js samples print:
3.2s ivr (machine)
13.0s hold (machine)
23.4s human (human)
final: humanFields
| Field | Values | Default |
|---|---|---|
file |
The recording (required) | |
call_id |
Your reference, up to 200 characters, returned in the result | none |
remote_channel |
For a stereo file, the channel of the person you called: 0 or 1 |
0 |
language |
Optional hint, en or hi. Leave it out for automatic (English, Hindi, Hinglish) |
automatic |
transcripts |
false to leave the transcript out of the result |
true |
record |
false to not keep the recording and its transcript. See Data and recording |
true |
Accepted files
| File | Accepted |
|---|---|
| Format | WAV with 8, 16, 24 or 32-bit PCM, 32 or 64-bit float, or G.711 μ-law or A-law samples |
| Sample rate | Any. Rates other than 8, 16, 22.05, 24, 44.1 and 48 kHz are converted to 16 kHz |
| Channels | Mono (the person you called), or stereo with your agent on the other channel |
| Length | 1 second to 15 minutes, up to 50 MB |
Convert other recordings, such as MP3, M4A or Opus, first: ffmpeg -i call.mp3 -ac 1 -ar 16000 -sample_fmt s16 call.wav.
Response
{
"type": "result",
"session_id": "9f2c4e7a1b3d4c5e8f602a7b9c1d3e4f",
"call_id": "test-1",
"file": {"name": "call.wav", "duration_s": 26.6, "format": "pcm_s16le", "sample_rate": 8000, "channels": 1},
"first": {"label": "ivr", "category": "machine", "confidence": 0.9, "t": 3.2},
"final": {"label": "human", "category": "human", "confidence": 0.97},
"timeline": [
{"seq": 1, "t": 3.2, "label": "ivr", "category": "machine", "confidence": 0.9, "previous_label": "unknown", "change": "initial"},
{"seq": 2, "t": 13.0, "label": "hold", "category": "machine", "confidence": 0.8, "previous_label": "ivr", "change": "transition"},
{"seq": 3, "t": 23.4, "label": "human", "category": "human", "confidence": 0.95, "previous_label": "hold", "change": "transition"}
],
"transcript": [{"t": 3.0, "text": "For credit cards, press one."}]
}| Field | Meaning |
|---|---|
first |
The first answer, and when it came: t is seconds into the recording |
final |
The answer at the end of the recording. first and final are null when no speech was heard |
timeline |
Every answer in order, with the fields of a live call's classification events |
transcript |
What the callee said, with times. Left out when transcripts=false |
file |
What was analysed |
session_id |
Look the call up again later; see Sessions and usage |
operation_id, billed_seconds, credits, idempotent_replay |
The analysis's billing record, the seconds billed, what it used from your balance, and whether this is a replay (see Credits) |
The full schema is in Analyse a call recording in the API Reference.
While it runs
A 30-second recording takes about 30 seconds. The response starts straight away and a newline is sent every 5 seconds until the result, so the connection stays open however long the recording is; JSON parsers skip the newlines. If your HTTP client limits the total time of a request, set it above the recording's length plus a minute.
If the analysis fails after it has started, the response (status 200) ends with {"type": "error", ...} instead of the result.
Credits
A recording is charged like a live call of the same length: for each started minute. A file that is refused uses none, and nothing is billed if the analysis fails. Send the same Idempotency-Key when you retry: the retry returns the stored result instead of running again, and is not billed again. The stored result has no transcript (transcripts are not kept with it), and it comes with "idempotent_replay": true and the header Idempotent-Replayed: true.
Errors (recorded calls)
| Status | Meaning |
|---|---|
400 |
No file was sent (missing_file), the multipart body is incomplete (invalid_multipart), or a field is unknown or invalid (unknown_parameter, invalid_parameter) |
401 |
The API key is missing, invalid or revoked |
402 |
Your credit balance does not cover the recording |
403 |
The key is not allowed to use Noesis, or your email address is not verified |
409 |
A request with the same Idempotency-Key is still running |
413 |
The file is larger than 50 MB |
415 |
It is not a WAV file, or its encoding is not accepted (unsupported_format) |
422 |
It is shorter than 1 second (audio_too_short), longer than 15 minutes (audio_too_long) or has more than 2 channels, or the Idempotency-Key was used for a different request (idempotency_key_reuse) |
429 |
Too many requests or recordings at once |
503 |
Busy; try again after the Retry-After seconds |
A problem found during the analysis, such as remote_channel=1 for a mono file, comes as {"type": "error", ...} at the end of a 200 response (see While it runs).
See Errors for the error body and codes.
Sessions and usage
Look up a call by its session ID, and see your Noesis calls and minutes.
Both endpoints need a key with the noesis:read permission.
Look up a call
Every live call and recorded call has a session_id: 32 lowercase hexadecimal characters. Use it to read the call's state, its latest answer and its events:
curl https://api.noesis.detectif.ai/v1/detect/sessions/5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f \
-H "Authorization: Bearer $DETECTIF_API_KEY"import os
import requests
session_id = "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f"
resp = requests.get(
f"https://api.noesis.detectif.ai/v1/detect/sessions/{session_id}",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"},
timeout=30,
)
session = resp.json()
print(session["closed"], session["label"])const sessionId = "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f";
const res = await fetch(`https://api.noesis.detectif.ai/v1/detect/sessions/${sessionId}`, {
headers: { Authorization: `Bearer ${process.env.DETECTIF_API_KEY}` },
});
const session = await res.json();
console.log(session.closed, session.label);Where to find it:
- A live call has two IDs, and both work here. The
readyevent (and everyclassificationandsummaryevent) carries the ID the analysis gives the call. Theusageevent at the end carries the call's ID in your account, the same one a stream token returns before the call starts, so you can follow a call you cannot see, such as a Twilio stream. See Two session IDs. - A recorded call: the
session_idin the result.
The session's session_id is the account's ID and stream_session_id is the one from ready. An ID in another form, such as a UUID with dashes, returns 404.
closedsays whether the call has ended. While the call is live, the session shows the answers so far.- Use it after a dropped connection, or to check a call later.
- Only the account that created a session can read it. Any other session ID returns
404withsession_not_found.
Usage
Your account's Noesis calls and minutes:
curl https://api.noesis.detectif.ai/v1/detect/usage \
-H "Authorization: Bearer $DETECTIF_API_KEY"The fields are listed in Get your Noesis usage in the API Reference. Your credit balance, shared with the other DetectifAI APIs, is on the dashboard Overview page.
Calls at the same time
Your plan sets how many live calls and recordings can run at the same time. Over the limit, a new call is refused with 429 (close code 4429 on the WebSocket) until one of your calls ends.
Integrations
How to send a call from each platform to Noesis. Most platforms cannot pass the answers back to you, so the guides stream through a small relay on your server; the WebSocket client section has the relay helper they use.
Twilio
Twilio Media Streams send a call's audio to a WebSocket. Noesis reads Twilio's messages as they are, and the defaults (μ-law, 8 kHz) match.
Twilio cannot send an Authorization header, so you pass a stream token as a <Parameter> instead. Twilio does not pass messages from the stream back to you, so to act on the answers during the call, stream through a relay on your server (step 3).
1. Stream the call to Noesis
Add a <Stream> inside <Start>, so the call carries on while its audio is streamed. track="both_tracks" lets Noesis hear when your agent speaks, and the call ID defaults to the CallSid.
<Response>
<Start>
<Stream url="wss://api.noesis.detectif.ai/v1/detect/stream" track="both_tracks">
<Parameter name="token" value="ntk_..."/>
</Stream>
</Start>
<!-- your existing call flow continues here -->
</Response>To not record the call, add <Parameter name="record" value="false"/>. See Data and recording. To use your own call ID instead of the CallSid, add <Parameter name="call_id" value="..."/>.
Noesis reads the token from Twilio's start message, which Twilio sends right after it connects. A stream whose token does not arrive within 10 seconds and its first 3 messages is closed with code 4401. The call ID (the CallSid) is then in every event, ready included.
2. Create a token for each call
A token opens one call and expires after 5 minutes, so create it in your voice webhook, right before you return the TwiML. This Flask webhook uses the Twilio helper library (pip install flask requests twilio):
# voice.py: Twilio voice webhook that streams each call to Noesis
import os
import requests
from flask import Flask
from twilio.twiml.voice_response import Start, VoiceResponse
app = Flask(__name__)
@app.post("/voice")
def voice():
response = VoiceResponse()
try:
r = requests.post(
"https://api.noesis.detectif.ai/v1/detect/stream-tokens",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"},
json={},
timeout=5,
)
r.raise_for_status()
start = Start()
stream = start.stream(url="wss://api.noesis.detectif.ai/v1/detect/stream",
track="both_tracks")
stream.parameter(name="token", value=r.json()["token"])
response.append(start)
except requests.RequestException:
pass # never block the call on Noesis
response.say("Your existing call flow continues here.")
return str(response), 200, {"Content-Type": "text/xml"}3. Receive the answers during the call
With the stream pointed straight at Noesis, the answers go back to Twilio, which ignores them. To act on them, point the <Stream> at a relay on your server instead. The relay forwards Twilio's messages to Noesis unchanged, with your API key in the header, so it needs no token:
<Response>
<Start>
<Stream url="wss://relay.example.com/twilio" track="both_tracks"/>
</Start>
<!-- your existing call flow continues here -->
</Response>The relay uses noesis_relay.py from the relay helper:
# twilio_relay.py: Twilio Media Stream -> your server -> Noesis
import asyncio
import websockets
from noesis_relay import NoesisCall
async def on_answer(event):
if event["type"] == "classification":
print(event["call_id"], event["label"]) # your own logic; call_id is the CallSid
async def handle(twilio):
call = NoesisCall(on_answer) # Twilio's format is the default
await call.open()
try:
async for message in twilio: # Twilio's JSON messages, unchanged
await call.send(message)
except websockets.ConnectionClosed:
pass
await call.close()
async def main():
async with websockets.serve(handle, "0.0.0.0", 8080):
await asyncio.Future() # run until stopped
asyncio.run(main())Act on the latest seq for each CallSid. For example, update the live call with Twilio's REST API when the answer is voicemail. To not record calls through the relay, create the call with NoesisCall(on_answer, record="false").
Plivo
Plivo's <Stream> element sends a call's audio to a WebSocket. Noesis reads Plivo's media messages as they are. Plivo cannot send an Authorization header to Noesis, so put a stream token in the URL.
1. Stream the call to Noesis
Ask Plivo for μ-law at 8 kHz and set the same format on the URL. In XML, write each & in the URL as &:
<Response>
<Stream bidirectional="false" audioTrack="inbound" contentType="audio/x-mulaw;rate=8000">wss://api.noesis.detectif.ai/v1/detect/stream?token=ntk_...&encoding=mulaw&sample_rate=8000</Stream>
<!-- your existing call flow continues here -->
</Response>Create the token in your answer webhook, right before you return the XML, as in the Twilio guide. To not record the call, add &record=false to the URL.
2. Receive the answers during the call
Plivo does not pass messages from the stream back to you. To act on the answers, point the stream at a relay on your server, which forwards Plivo's messages to Noesis unchanged and receives the answers:
<Response>
<Stream bidirectional="false" audioTrack="inbound" contentType="audio/x-mulaw;rate=8000">wss://relay.example.com/plivo</Stream>
<!-- your existing call flow continues here -->
</Response>The relay uses noesis_relay.py from the relay helper:
# plivo_relay.py: Plivo Stream -> your server -> Noesis
import asyncio
import websockets
from noesis_relay import NoesisCall
async def on_answer(event):
if event["type"] == "classification":
print(event["call_id"], event["label"]) # your own logic; call_id is Plivo's call ID
async def handle(plivo):
call = NoesisCall(on_answer, encoding="mulaw", sample_rate=8000)
await call.open()
try:
async for message in plivo: # Plivo's JSON messages, unchanged
await call.send(message)
except websockets.ConnectionClosed:
pass
await call.close()
async def main():
async with websockets.serve(handle, "0.0.0.0", 8080):
await asyncio.Future() # run until stopped
asyncio.run(main())If you choose 16-bit PCM in contentType (audio/x-l16;rate=8000 or audio/x-l16;rate=16000), set encoding="pcm_s16le" and the same sample_rate.
Telnyx
Telnyx media streaming sends a call's audio to a WebSocket as JSON messages. Run a relay that takes the callee's audio from those messages and forwards it to Noesis.
1. Stream the call to your relay
With TeXML, add a <Stream> inside <Start> so the call carries on:
<Response>
<Start>
<Stream url="wss://relay.example.com/telnyx" track="inbound_track"/>
</Start>
<!-- your existing call flow continues here -->
</Response>With Call Control, start streaming on the answered call with stream_url set to wss://relay.example.com/telnyx and stream_track set to inbound_track. Keep the default audio format, PCMU (μ-law) at 8 kHz.
2. Forward the audio to Noesis
The relay uses noesis_relay.py from the relay helper:
# telnyx_relay.py: Telnyx media stream -> your server -> Noesis
import asyncio, base64, json
import websockets
from noesis_relay import NoesisCall
ENCODINGS = {"PCMU": "mulaw", "PCMA": "alaw"}
async def on_answer(event):
if event["type"] == "classification":
print(event["call_id"], event["label"]) # your own logic
async def handle(telnyx):
call = None
try:
async for raw in telnyx:
msg = json.loads(raw)
if msg.get("event") == "start":
fmt = msg["start"].get("media_format", {})
call = NoesisCall(on_answer,
encoding=ENCODINGS.get(fmt.get("encoding"), "mulaw"),
sample_rate=fmt.get("sample_rate", 8000),
call_id=msg["start"].get("call_control_id"))
await call.open()
elif msg.get("event") == "media" and call is not None:
if msg["media"].get("track", "inbound") == "inbound":
await call.send(base64.b64decode(msg["media"]["payload"]))
elif msg.get("event") == "stop":
break
except websockets.ConnectionClosed:
pass
if call is not None:
await call.close()
async def main():
async with websockets.serve(handle, "0.0.0.0", 8080):
await asyncio.Future() # run until stopped
asyncio.run(main())To not record calls, create each call with record="false" as well.
Exotel
Exotel's Stream and Voicebot applets send a call's audio to a WebSocket as JSON messages, with 16-bit PCM audio at 8 kHz in base64. Run a relay that decodes the audio and forwards it to Noesis.
1. Stream the call to your relay
In your call flow, add a Stream applet (or a Voicebot applet) and set its URL to your relay, for example wss://relay.example.com/exotel. Exotel calls the relay when the applet runs.
2. Forward the audio to Noesis
The relay uses noesis_relay.py from the relay helper:
# exotel_relay.py: Exotel stream -> your server -> Noesis
import asyncio, base64, json
import websockets
from noesis_relay import NoesisCall
async def on_answer(event):
if event["type"] == "classification":
print(event["call_id"], event["label"]) # your own logic
async def handle(exotel):
call = None
try:
async for raw in exotel:
msg = json.loads(raw)
if msg.get("event") == "start":
call = NoesisCall(on_answer, encoding="pcm_s16le", sample_rate=8000,
call_id=msg["start"].get("call_sid"))
await call.open()
elif msg.get("event") == "media" and call is not None:
await call.send(base64.b64decode(msg["media"]["payload"])) # 16-bit PCM
elif msg.get("event") == "stop":
break
except websockets.ConnectionClosed:
pass
if call is not None:
await call.close()
async def main():
async with websockets.serve(handle, "0.0.0.0", 8080):
await asyncio.Future() # run until stopped
asyncio.run(main())If your stream is set to 16 kHz, use sample_rate=16000. To not record calls, create each call with record="false" as well.
Vonage
The Vonage Voice API connects a call to a WebSocket and sends its audio as binary frames of 16-bit PCM. Run a relay that forwards those frames to Noesis.
1. Connect the call to your relay
In your NCCO, connect the call to the relay's WebSocket. Values in headers arrive in the first message, so use them to pass your call ID:
[
{
"action": "connect",
"endpoint": [
{
"type": "websocket",
"uri": "wss://relay.example.com/vonage",
"content-type": "audio/l16;rate=16000",
"headers": { "call_id": "your-call-id" }
}
]
}
]The WebSocket becomes part of the call: Vonage sends it the call's audio and plays back anything it sends. The relay sends nothing back. To keep the call connected to a person or bot at the same time, add the WebSocket as another leg of the same conversation.
2. Forward the audio to Noesis
The relay uses noesis_relay.py from the relay helper:
# vonage_relay.py: Vonage WebSocket -> your server -> Noesis
import asyncio, json
import websockets
from noesis_relay import NoesisCall
async def on_answer(event):
if event["type"] == "classification":
print(event["call_id"], event["label"]) # your own logic
async def handle(vonage):
call = None
try:
async for message in vonage:
if call is None: # the first message is JSON with your headers
info = json.loads(message) if isinstance(message, str) else {}
call = NoesisCall(on_answer, encoding="pcm_s16le", sample_rate=16000,
call_id=info.get("call_id"))
await call.open()
if isinstance(message, bytes):
await call.send(message) # 16-bit PCM, 20 ms per frame
except websockets.ConnectionClosed:
pass
if call is not None:
await call.close()
async def main():
async with websockets.serve(handle, "0.0.0.0", 8080):
await asyncio.Future() # run until stopped
asyncio.run(main())For audio/l16;rate=8000, use sample_rate=8000. To not record calls, create each call with record="false" as well.
FreeSWITCH
FreeSWITCH can fork a channel's audio to a WebSocket with an audio-fork module, such as mod_audio_fork. The module sends 16-bit PCM as binary frames, after an optional JSON metadata message. Run a relay that forwards the frames to Noesis.
1. Fork the callee's audio to your relay
Start the fork on the channel of the person you called, for example from fs_cli or the event socket, once the call is answered:
uuid_audio_fork <uuid> start wss://relay.example.com/freeswitch mono 16k {"call_id":"<uuid>"}mono sends that channel's audio only, and 16k sets 16 kHz. Check your module's documentation for its exact options; other audio-fork modules work the same way.
2. Forward the audio to Noesis
The relay uses noesis_relay.py from the relay helper:
# freeswitch_relay.py: FreeSWITCH audio fork -> your server -> Noesis
import asyncio, json
import websockets
from noesis_relay import NoesisCall
async def on_answer(event):
if event["type"] == "classification":
print(event["call_id"], event["label"]) # your own logic
async def handle(fork):
call = None
try:
async for message in fork:
if call is None: # metadata, if the fork sends it first
meta = json.loads(message) if isinstance(message, str) else {}
call = NoesisCall(on_answer, encoding="pcm_s16le", sample_rate=16000,
call_id=meta.get("call_id"))
await call.open()
if isinstance(message, bytes):
await call.send(message) # 16-bit PCM
except websockets.ConnectionClosed:
pass
if call is not None:
await call.close()
async def main():
async with websockets.serve(handle, "0.0.0.0", 8080):
await asyncio.Future() # run until stopped
asyncio.run(main())For an 8k fork, use sample_rate=8000. To not record calls, create each call with record="false" as well.
Asterisk
Asterisk's AudioSocket (Asterisk 18 and later) sends a channel's audio to a TCP server as 16-bit PCM at 8 kHz. Run a relay that accepts the AudioSocket connection and forwards the audio to Noesis.
1. Send the channel's audio to your relay
In the dialplan, give AudioSocket a UUID for the call and your relay's address:
exten => 100,1,Answer()
same => n,AudioSocket(40325ec2-5efd-4bd3-805f-53576e581d13,relay.example.com:9092)AudioSocket connects the channel to the relay until the connection closes. To listen to a call that continues with a person or bot at the same time, run AudioSocket on a spy channel of the person you called, for example with ChanSpy or an ARI snoop channel.
2. Forward the audio to Noesis
The relay uses noesis_relay.py from the relay helper. Each AudioSocket message is a 1-byte type, a 2-byte length (big-endian) and the payload:
# asterisk_relay.py: Asterisk AudioSocket -> your server -> Noesis
import asyncio, uuid
from noesis_relay import NoesisCall
HANGUP, CALL_UUID, AUDIO = 0x00, 0x01, 0x10
async def on_answer(event):
if event["type"] == "classification":
print(event["call_id"], event["label"]) # your own logic
async def handle(reader, writer):
call = None
try:
while True:
header = await reader.readexactly(3)
kind, size = header[0], int.from_bytes(header[1:3], "big")
payload = await reader.readexactly(size) if size else b""
if kind == CALL_UUID:
call = NoesisCall(on_answer, encoding="pcm_s16le", sample_rate=8000,
call_id=str(uuid.UUID(bytes=payload)))
await call.open()
elif kind == AUDIO and call is not None:
await call.send(payload) # 16-bit PCM, 8 kHz, mono
elif kind == HANGUP:
break
except asyncio.IncompleteReadError:
pass # Asterisk closed the connection
if call is not None:
await call.close()
writer.close()
async def main():
server = await asyncio.start_server(handle, "0.0.0.0", 9092)
async with server:
await server.serve_forever()
asyncio.run(main())To not record calls, create each call with record="false" as well.
LiveKit
Stream the SIP callee's audio from your LiveKit agent to Noesis, and act on every answer. The module sends 16-bit PCM at 16 kHz in 100 ms frames, and tells Noesis when your agent speaks.
1. Add the module
Needs pip install aiohttp (LiveKit Agents already uses it).
# detectif_noesis.py
import asyncio, json
import aiohttp
from livekit import rtc
URL = "wss://api.noesis.detectif.ai/v1/detect/stream?encoding=pcm_s16le&sample_rate=16000"
class DetectifNoesis:
def __init__(self, api_key, call_id, on_classification):
self.key, self.call_id, self.on = api_key, call_id, on_classification
self.http = self.ws = None
async def start(self, track: rtc.Track):
self.http = aiohttp.ClientSession()
try:
self.ws = await self.http.ws_connect(f"{URL}&call_id={self.call_id}",
headers={"Authorization": f"Bearer {self.key}"},
heartbeat=20)
await self.ws.receive_json() # "ready"
except Exception:
return # never block the call
asyncio.create_task(self._read())
stream = rtc.AudioStream(track, sample_rate=16000, num_channels=1, frame_size_ms=100)
async for ev in stream:
if self.ws.closed:
break
await self.ws.send_bytes(bytes(ev.frame.data))
async def _read(self):
async for msg in self.ws:
if msg.type == aiohttp.WSMsgType.TEXT:
ev = json.loads(msg.data)
if ev.get("type") == "classification":
await self.on(ev)
def agent_speech(self, state): # "started" / "ended"
if self.ws is not None and not self.ws.closed:
msg = json.dumps({"type": "agent.speech", "state": state})
asyncio.create_task(self.ws.send_str(msg))
async def aclose(self):
if self.ws is not None and not self.ws.closed:
await self.ws.send_str(json.dumps({"type": "end"}))
await self.ws.close()
if self.http is not None:
await self.http.close()2. Wire it into your entrypoint
After the SIP participant has joined:
# in your entrypoint (uses: import asyncio, os; from livekit import api, rtc)
callee = await ctx.wait_for_participant(kind=rtc.ParticipantKind.PARTICIPANT_KIND_SIP)
noesis = DetectifNoesis(os.environ["DETECTIF_API_KEY"], ctx.room.name, on_classification)
ctx.add_shutdown_callback(noesis.aclose)
@ctx.room.on("track_subscribed")
def _on_track(track, publication, participant):
if participant.identity == callee.identity and track.kind == rtc.TrackKind.KIND_AUDIO:
asyncio.create_task(noesis.start(track))
@session.on("agent_state_changed")
def _on_agent_state(ev):
if ev.new_state == "speaking":
noesis.agent_speech("started")
elif ev.old_state == "speaking":
noesis.agent_speech("ended")
async def on_classification(ev):
if ev["label"] == "human":
await session.generate_reply(instructions="Greet the caller.")
elif ev["label"] == "voicemail":
await session.say("Hi, this is Acme ...", allow_interruptions=False)
await ctx.api.room.delete_room(api.DeleteRoomRequest(room=ctx.room.name))
elif ev["label"] in ("unavailable", "announcement"):
await ctx.api.room.delete_room(api.DeleteRoomRequest(room=ctx.room.name))
# ivr / hold / ai_agent: stay silent and keep listeningTo not record calls, add &record=false to URL.
Pipecat
A frame processor that streams the call's input audio to Noesis, tells it when your bot speaks, and reports every answer.
1. Add the processor
Needs pip install websockets (version 14 or later).
# detectif_noesis.py
import asyncio, json
import websockets
from pipecat.frames.frames import (BotStartedSpeakingFrame, BotStoppedSpeakingFrame,
CancelFrame, EndFrame, InputAudioRawFrame)
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
URL = "wss://api.noesis.detectif.ai/v1/detect/stream?encoding=pcm_s16le"
class DetectifNoesis(FrameProcessor):
def __init__(self, api_key, call_id, on_classification, **kwargs):
super().__init__(**kwargs)
self.key, self.call_id, self.on = api_key, call_id, on_classification
self.ws, self.connecting = None, False
async def _connect(self, rate, channels):
self.connecting = True
try:
self.ws = await websockets.connect(
f"{URL}&sample_rate={rate}&channels={channels}&call_id={self.call_id}",
additional_headers={"Authorization": f"Bearer {self.key}"})
await self.ws.recv() # "ready"
asyncio.create_task(self._read())
except Exception:
self.ws = None # never block the call
async def _read(self):
async for raw in self.ws:
ev = json.loads(raw)
if ev.get("type") == "classification":
await self.on(ev)
async def _send(self, data):
if self.ws is not None:
try:
await self.ws.send(data)
except Exception:
self.ws = None
async def process_frame(self, frame, direction: FrameDirection):
await super().process_frame(frame, direction)
if isinstance(frame, InputAudioRawFrame):
if self.ws is None and not self.connecting:
asyncio.create_task(self._connect(frame.sample_rate, frame.num_channels))
await self._send(frame.audio)
elif isinstance(frame, BotStartedSpeakingFrame):
await self._send(json.dumps({"type": "agent.speech", "state": "started"}))
elif isinstance(frame, BotStoppedSpeakingFrame):
await self._send(json.dumps({"type": "agent.speech", "state": "ended"}))
elif isinstance(frame, (EndFrame, CancelFrame)):
await self._send(json.dumps({"type": "end"}))
await self.push_frame(frame, direction)2. Place it after the transport input
noesis = DetectifNoesis(os.environ["DETECTIF_API_KEY"], call_sid, on_classification)
pipeline = Pipeline([transport.input(), noesis, stt, context_aggregator.user(), llm, tts,
transport.output(), context_aggregator.assistant()])
async def on_classification(ev):
if ev["label"] == "voicemail":
await task.queue_frames([TTSSpeakFrame("Hi, this is Acme ..."), EndFrame()])
elif ev["label"] in ("unavailable", "announcement"):
await task.queue_frame(EndFrame())The processor sends the audio in the format the transport delivers: 16-bit PCM at its sample rate, which must be one of the accepted rates. To not record calls, add &record=false to URL.
WebSocket client
Use these clients when your own code has the call's audio, for example a media server, a softphone or a voice bot. Each opens one socket per call, sends the callee's audio, and passes every answer to your code.
Python
Needs pip install websockets (version 14 or later).
# noesis_client.py: one Noesis socket per call
import asyncio, json, os
import websockets
STREAM = "wss://api.noesis.detectif.ai/v1/detect/stream"
HEADERS = {"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"}
async def analyse_call(frames, call_id, on_answer, encoding="mulaw", sample_rate=8000):
"""frames: an async iterator of the callee's audio, 20 to 100 ms per frame."""
url = f"{STREAM}?encoding={encoding}&sample_rate={sample_rate}&call_id={call_id}"
try:
ws = await websockets.connect(url, additional_headers=HEADERS)
except Exception:
return # never block the call on Noesis
async def answers():
try:
async for raw in ws:
event = json.loads(raw)
if event["type"] in ("classification", "summary"):
await on_answer(event)
except websockets.ConnectionClosed:
pass
reader = asyncio.create_task(answers())
try:
async for frame in frames:
await ws.send(frame)
await ws.send(json.dumps({"type": "end"}))
except websockets.ConnectionClosed:
pass # Noesis closed early: the call carries on
try:
await asyncio.wait_for(reader, timeout=10) # the summary arrives after "end"
except asyncio.TimeoutError:
await ws.close()Node.js
Needs Node.js 18 or later and npm install ws.
// noesis-client.mjs: one Noesis socket per call
import WebSocket from "ws";
const STREAM = "wss://api.noesis.detectif.ai/v1/detect/stream";
export function analyseCall({ callId, onAnswer, encoding = "mulaw", sampleRate = 8000 }) {
const url = `${STREAM}?encoding=${encoding}&sample_rate=${sampleRate}&call_id=${encodeURIComponent(callId)}`;
const ws = new WebSocket(url, { headers: { Authorization: `Bearer ${process.env.DETECTIF_API_KEY}` } });
ws.on("error", () => {}); // never block the call on Noesis
ws.on("message", (raw) => {
const event = JSON.parse(raw);
if (event.type === "classification" || event.type === "summary") onAnswer(event);
});
return {
send(frame) { if (ws.readyState === WebSocket.OPEN) ws.send(frame); },
end() { if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify({ type: "end" })); },
};
}Use it from your media handler:
const noesis = analyseCall({ callId, onAnswer: (e) => console.log(e.label) });
// for each frame of the callee's audio:
noesis.send(frame);
// when the call ends:
noesis.end();Browsers
A browser cannot set the Authorization header on a WebSocket, and must never hold an API key. Have your server create a stream token for the call, and open the socket with it:
const ws = new WebSocket(`wss://api.noesis.detectif.ai/v1/detect/stream?token=${token}&encoding=pcm_s16le&sample_rate=16000`);Relay helper
Most telephony platforms send a call's audio to a WebSocket or TCP server that you run. The Telnyx, Exotel, Vonage, FreeSWITCH, Asterisk, Twilio and Plivo guides run a small relay: it receives the platform's stream, forwards the callee's audio to Noesis, and passes the answers to your code. They share this helper:
# noesis_relay.py: forward one call's audio to Noesis and pass its answers to your code
import asyncio, json, os
from urllib.parse import urlencode
import websockets
STREAM = "wss://api.noesis.detectif.ai/v1/detect/stream"
HEADERS = {"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"}
class NoesisCall:
"""One call. Never raises: if Noesis is unreachable or closes, the call carries on."""
def __init__(self, on_answer, **params):
self.on_answer = on_answer
self.query = urlencode({k: v for k, v in params.items() if v is not None})
self.ws = self.reader = None
async def open(self):
try:
self.ws = await websockets.connect(f"{STREAM}?{self.query}", additional_headers=HEADERS)
except Exception:
self.ws = None
return
self.reader = asyncio.create_task(self._read())
async def _read(self):
try:
async for raw in self.ws:
event = json.loads(raw)
if event["type"] in ("classification", "summary", "error"):
await self.on_answer(event)
except websockets.ConnectionClosed:
pass
async def send(self, data):
"""Binary audio, or a JSON message as text."""
if self.ws is None:
return
try:
await self.ws.send(data)
except websockets.ConnectionClosed:
self.ws = None
async def close(self):
await self.send(json.dumps({"type": "end"}))
if self.reader is not None:
try:
await asyncio.wait_for(self.reader, timeout=10) # the summary follows "end"
except asyncio.TimeoutError:
pass
if self.ws is not None:
await self.ws.close()on_answer receives each classification, the summary and any error event. The relay must be reachable from the platform over wss:// (or TCP for Asterisk), for example behind your load balancer or a TLS proxy.
Errors
The error body of the REST endpoints, every error code, the WebSocket error event and its close codes.
REST endpoints
Every error response from https://api.noesis.detectif.ai has the same JSON body as the rest of the DetectifAI API:
{
"error": {
"type": "not_found",
"code": "session_not_found",
"message": "No session with this session_id exists in your account.",
"param": "session_id"
},
"request_id": "req_8f14e45fceea167a5a36dedd"
}- Use
error.codein your code; it does not change. Showerror.messageto people; its wording can change. - Include the
request_idwhen you contact support.
Error codes
| Status | Meaning | Code | How to fix |
|---|---|---|---|
400 |
The request is invalid: a parameter, a form field or the body. error.param names the field when there is one. | invalid_body |
Send a JSON object, such as {"record": false}, or no body. |
api_key_in_url |
Send the key only in the Authorization header (or use a stream token), then rotate the key that was in the URL. | ||
unsupported_parameter |
Remove the parameter: callback_url and webhooks are not offered on the platform; read results on the socket or the session. | ||
invalid_parameter |
Check the field named in error.param. | ||
unknown_parameter |
Remove the form field named in error.param; the fields a recording takes are listed in the API Reference. | ||
missing_file |
Send the recording in a multipart field named file, or as the request body. | ||
invalid_multipart |
Send a complete multipart/form-data body with one file, in the field named file. | ||
invalid_cursor |
Pass the next_cursor of the previous page unchanged, or leave cursor out to start again. | ||
401 |
The API key is missing, invalid or revoked. | invalid_api_key |
Check that the whole key was copied, or create a new one in the dashboard. |
missing_api_key |
Add the header Authorization: Bearer <your API key>, or a stream token for the WebSocket. | ||
invalid_stream_token |
Create a new stream token: each one opens one call and expires after 5 minutes. | ||
revoked_api_key |
The key (or the key the stream token was made with) was revoked: create a new one in the dashboard. | ||
402 |
Your balance is too low for this call or file. | insufficient_credits |
Check your balance on the dashboard Overview page. |
403 |
The key lacks the required scope, the e-mail address is not verified, or the account is suspended. | insufficient_scope |
Use a key that is allowed to use Noesis, or create one in the dashboard. |
email_not_verified |
Verify your email address, then try again. | ||
404 |
No session with this ID exists in your account, or no endpoint exists at this path. | session_not_found |
Check the session ID (32 lowercase hexadecimal characters); only the account that created a session can read it. |
route_not_found |
Check the path: every endpoint is listed in the API Reference. | ||
405 |
The path exists, but not with this HTTP method. The Allow header lists the methods it takes. | method_not_allowed |
Use a method from the Allow header: GET to read sessions and usage, POST to send a recording or create a stream token. |
408 |
The upload did not arrive in time. | upload_timeout |
Retry on a faster connection; the recording must arrive within the time limit. |
409 |
A request with the same Idempotency-Key is still running. | operation_in_progress |
A request with this Idempotency-Key is still running: wait, then retry with the same key to get its result. |
413 |
The file is larger than 50 MB. | file_too_large |
Send a WAV file up to 50 MB and 15 minutes long. |
request_too_large |
Keep request bodies under 1 MB; only recordings sent to /v1/detect/file may be larger. | ||
415 |
Not a WAV file. | unsupported_format |
Convert the recording to WAV first, for example with ffmpeg. |
422 |
The recording is too short or too long, or the Idempotency-Key was used for a different request. | audio_too_long |
Send a recording of up to 15 minutes, or split it into parts. |
audio_too_short |
Send a recording that is at least 1 second long. | ||
idempotency_key_reuse |
Use a new Idempotency-Key for a different file or different fields; reuse a key only to retry the same request. | ||
426 |
The live-call path was requested over plain HTTP instead of a WebSocket. | websocket_required |
Open wss://api.noesis.detectif.ai/v1/detect/stream with a WebSocket client. |
429 |
Too many requests, or too many calls and file analyses at the same time. Wait for Retry-After seconds. | concurrency_limited |
Wait for a live call or recording to finish, then retry. |
rate_limited |
Wait for the Retry-After seconds, then retry. | ||
500 |
Something went wrong on our side. | internal_error |
Retry later, and include the request_id if you contact support. |
503 |
Busy or temporarily unavailable. Retry after the Retry-After seconds. | noesis_capacity |
Busy: carry on with the call without detection, and try again on the next call. |
server_busy |
Busy, try again after the Retry-After seconds; carry on with the call without detection. | ||
upstream_unavailable |
Temporarily unavailable (on the WebSocket the socket closes with 1013): carry on without detection and retry after the Retry-After seconds. |
The WebSocket
On a live call, an error that ends the call arrives as an event, and then the socket closes:
{"type": "error", "code": "insufficient_credits", "error": "Your balance is too low to continue this call; the call is being ended.", "status": 402, "request_id": "req_8f14e45fceea167a5a36dedd"}| Close code | Status | Meaning | What to do |
|---|---|---|---|
1003 |
400 |
A parameter is invalid or not available; the message names it | Fix the URL |
4401 |
401 |
The key or stream token is missing, invalid, expired or already used. A Twilio or Plivo stream that sends its token in the start message must send it within 10 seconds and in its first 3 messages |
Check the key, or create a new token |
4402 |
402 |
The credit balance ran out (insufficient_credits) |
Add credits in the dashboard |
4403 |
403 |
The key is not allowed to use Noesis, or the email address is not verified | Use a key with noesis:detect |
4429 |
429 |
Too many calls at once, or new calls too fast | Wait for a call to end |
1013 |
503 |
Busy, or temporarily unavailable (noesis_capacity, upstream_unavailable) |
Carry on with the call without detection |
1011 |
500 |
Something failed on our side during the call. The audio received until then is billed | Carry on with the call without detection; the session keeps the answers so far |
1009 |
A frame was larger than 1 MiB (1,048,576 bytes). No error event is sent |
Send 20 to 100 ms of audio per frame | |
1000 |
408 |
The socket was silent for 15 minutes, or the call passed 2 hours | Open one socket per call |
Errors that do not end the call
Some error events only say that one message was not used: the call goes on and the socket stays open. They come from the analysis service and have no code, so check status and error:
| Status | error |
Meaning |
|---|---|---|
413 |
audio frame too large |
A binary frame larger than 192,000 bytes (and up to 1 MiB). It is not analysed and not billed |
413 |
message too large |
A text message longer than 384,000 characters (and up to 1 MiB). It is not analysed and not billed |
400 |
invalid JSON, JSON object required, unknown message type: ... |
A text message that could not be read. It is ignored |
A Twilio or Plivo media message whose payload is not valid base64 is ignored without an event, and is not billed.
Usage recorded later
Rarely, a call ends normally but its usage cannot be recorded at once. You then receive this event after the summary, instead of the usage event, and the socket closes as usual (1000 after end):
{"type": "error", "code": "settlement_delayed", "status": 503, "error": "The call ended normally, but recording its usage is delayed on our side. This completes on its own; nothing needs to be sent again. The session shows the final numbers once it is done.", "session_id": "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f", "operation_id": "op_6f1ed002ab5595859014ebf0951522d9", "request_id": "req_8f14e45fceea167a5a36dedd"}The call and its answers are complete. Do not retry it: the usage is recorded automatically a little later, and the session shows the billed seconds once it is.
Never block a call
If the connection fails, is refused or closes early, carry on with the call as you would without Noesis. Retry 429 and 503 on the next call, not by holding the current one.
Data and recording
Calls sent to Noesis are recorded for 30 days unless you opt out. Uploads to the other APIs are always stored for 30 days. How to opt out of call recording and how data is deleted.
Noesis calls are recorded
Live calls and recorded calls you send to Noesis are recorded: the call audio and its transcript are kept for 30 days, then deleted.
To not record a call, opt out for that call:
| How you connect | How to opt out |
|---|---|
| WebSocket URL | Add record=false to the query string |
| Stream token | Create the token with {"record": false} |
Twilio <Stream> |
Add <Parameter name="record" value="false"/>, or create the token with {"record": false} |
POST /v1/detect/file |
Send the form field record=false |
MCP analyze_call_recording |
Pass record: false |
A call that is not recorded is still analysed, and its answers are kept in its session.
If you record calls, you may need to tell the people on the call. Follow the rules that apply where you and they are.
Uploads to the other APIs are stored
Files you upload to Aletheia and Eidos (through the REST API, the dashboard or MCP) are always stored for 30 days, then deleted.
Files that are refused, for example because they are corrupt, in an unsupported format or too large, are not kept.
Where it is kept and who can open it
- Stored audio and transcripts are private to your account. They are never public.
- DetectifAI staff can open a stored file only through a short-lived link, and every such access is logged.
Deleting data
- Deleting your account deletes its stored audio, call recordings and transcripts.
- Deleting a speaker deletes its voice profile and the stored recordings used to enroll it.
- Everything else is deleted automatically after 30 days.
See also Privacy for Aletheia and Eidos.
API reference
Base URL https://api.noesis.detectif.ai, and wss://api.noesis.detectif.ai/v1/detect/stream for live calls (described in Stream protocol above). Every request needs an API key with the Noesis permission (see Authentication); errors share one shape with a stable error.code (see Errors).
Base URL: https://api.noesis.detectif.ai (live stream: wss://api.noesis.detectif.ai). Same API keys as the other products; the key needs the Noesis permission.
| Method | Path | Reference |
|---|---|---|
WS |
/v1/detect/stream |
Live call stream |
POST |
/v1/detect/stream-tokens |
Create a stream token |
POST |
/v1/detect/file |
Analyse a call recording |
GET |
/v1/detect/sessions/{session_id} |
Get a call session |
GET |
/v1/detect/sessions |
List call sessions |
GET |
/v1/detect/usage |
Get your Noesis usage |
GET |
/v1/health |
Check service health |
Create a stream token
POST /v1/detect/stream-tokens
Creates a single-use token for one live call, valid for 5 minutes, for clients that cannot send an Authorization header (Twilio <Stream>, Exotel, Telnyx, Vonage). Pass it as ?token= on the WebSocket URL or as the Twilio <Parameter name="token">. The response also has the session_id the call will use: poll GET /v1/detect/sessions/{session_id} for live state and the final answer. Send {"record": false} to not record that call. Does not use your balance. Requires scope noesis:detect.
Full URL: https://api.noesis.detectif.ai/v1/detect/stream-tokens. Send your API key as Authorization: Bearer <your API key>.
Request
Headers:
| Name | Type | Required | Description |
|---|---|---|---|
Authorization |
string | yes | Bearer <your API key>. Keys are created in the dashboard; see Authentication. |
JSON body (application/json):
| Field | Type | Required | Description |
|---|---|---|---|
record |
boolean or null | no | Record the call (audio and transcript, kept 30 days). Default true; false turns recording off for the call that uses this token. |
{}Response
201: Success.
| Field | Type | Always there | Description |
|---|---|---|---|
request_id |
string | yes | |
object |
string | yes | (always "noesis.stream_token") |
token |
string | yes | Single-use token (ntk_...), valid for 5 minutes. Pass it as ?token= or as the Twilio <Parameter name="token">. |
session_id |
string | yes | The session id the call that uses this token will have. Poll GET /v1/detect/sessions/{session_id} for its results. |
expires_at |
string | yes | |
expires_in |
integer | yes | Seconds until the token expires. |
record |
boolean | yes | Whether the call will be recorded. |
Example response:
{
"request_id": "req_8f14e45fceea167a5a36dedd",
"object": "noesis.stream_token",
"token": "ntk_Q7xQ7xQ7xQ7xQ7xQ7xQ7xQ7xQ7xQ7xQ7xQ7xQ7xQ7xa",
"session_id": "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f",
"expires_at": "2026-10-19T09:35:00Z",
"expires_in": 300,
"record": true
}Errors
| Status | Meaning |
|---|---|
400 |
The request is invalid, for example an API key in the URL or an unsupported parameter. |
401 |
The API key is missing, invalid or revoked. |
403 |
The key lacks the required scope, the e-mail address is not verified, or the account is suspended. |
429 |
Too many requests, or too many calls and file analyses at the same time. Wait for Retry-After seconds. |
500 |
Something went wrong on our side. |
Every error body has the shape described in Errors, with a stable error.code.
Example
curl -X POST "https://api.noesis.detectif.ai/v1/detect/stream-tokens" \
-H "Authorization: Bearer $DETECTIF_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'import os
import requests
resp = requests.post(
"https://api.noesis.detectif.ai/v1/detect/stream-tokens",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"},
json={},
timeout=30,
)
print(resp.status_code, resp.json())const res = await fetch("https://api.noesis.detectif.ai/v1/detect/stream-tokens", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DETECTIF_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
});
console.log(res.status, await res.json());Analyse a call recording
POST /v1/detect/file
Analyses a recorded call as if it were live and returns the answer. Send a WAV file (PCM, float or G.711; 1 second to 15 minutes, at most 50 MB) as multipart/form-data in the file field, or as the request body. Options as query parameters or form fields: call_id, language, remote_channel (stereo files), transcripts (default true), record (false to not keep the recording). The file is replayed in real time, so the answer takes about as long as the recording: the response (200) starts at once, sends a newline every few seconds to keep the connection open, and ends with one JSON object, the result (type: result) or {"type":"error",...} if the analysis failed (then nothing is charged). File analyses use your account balance. Send an Idempotency-Key to make retries safe (24 h): a retry with the same key returns the stored result (without the transcript, which is not stored) with idempotent_replay: true and is not billed again. Requires scope noesis:detect.
Full URL: https://api.noesis.detectif.ai/v1/detect/file. Send your API key as Authorization: Bearer <your API key>.
Request
Headers:
| Name | Type | Required | Description |
|---|---|---|---|
Authorization |
string | yes | Bearer <your API key>. Keys are created in the dashboard; see Authentication. |
Idempotency-Key |
string or null | no | Optional (recommended) key that makes retries safe for 24 h: a retry with the same key and the same request returns the stored response without charging again. (1 to 128 characters) |
Form fields (multipart/form-data). Upload the recording as a WAV file in the file field (up to 50 MB and 15 minutes); send the other fields as form fields:
| Field | Type | Required | Description |
|---|---|---|---|
file |
file | yes | The WAV file (PCM, float or G.711; 1 s to 15 min; at most 50 MB). |
call_id |
string | no | Your id for the call. (at most 200 characters) |
language |
string | no | Language hint, e.g. en or hi. (at most 16 characters) |
remote_channel |
integer | no | Stereo files: the channel of the person called. (default 0; one of 0, 1) |
transcripts |
boolean | no | Include the transcript. (default true) |
record |
boolean | no | Keep the recording and transcript for 30 days; false to not keep them. (default true) |
Response
200: The analysis runs: newlines while it works, then one JSON object (this result, or {"type":"error","code","error","status"}).
| Field | Type | Always there | Description |
|---|---|---|---|
type |
string | yes | (always "result") |
session_id |
string | yes | |
call_id |
string or null | no | |
file |
object | yes | |
first |
object or null | yes | |
final |
object or null | yes | |
timeline |
array of object | yes | |
transcript |
array of object or null | no | What the person called said, with times. Left out with transcripts=false, and in an idempotent replay (transcripts are not stored with the result). |
usage |
object or null | no | |
operation_id |
string | yes | |
billed_seconds |
number | yes | |
credits |
object or null | no | What the analysis used from your balance. |
idempotent_replay |
boolean | yes | true when this is the stored result of an earlier request with the same Idempotency-Key (nothing was analysed or billed again). |
Example response:
{
"type": "result",
"session_id": "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f",
"call_id": "crm-4711",
"file": {
"name": "call.wav",
"duration_s": 42.5,
"format": "pcm_s16le",
"sample_rate": 8000,
"channels": 1
},
"first": {
"label": "voicemail",
"category": "machine",
"confidence": 0.88,
"t": 3.1
},
"final": {
"label": "voicemail",
"category": "machine",
"confidence": 0.95
},
"timeline": [
{
"seq": 1,
"t": 3.1,
"label": "voicemail",
"category": "machine",
"confidence": 0.88,
"change": "initial",
"reason": "A greeting asks to leave a message."
}
],
"transcript": [
{
"t": 0.8,
"text": "Hi, you've reached Ada. Leave a message."
}
],
"usage": {
"audio_s": 42.5,
"transcribed_s": 42.5,
"checks": 3
},
"operation_id": "op_6f1ed002ab5595859014ebf0951522d9",
"billed_seconds": 42.5,
"idempotent_replay": false
}Errors
| Status | Meaning |
|---|---|
400 |
The request is invalid, for example an API key in the URL or an unsupported parameter. |
401 |
The API key is missing, invalid or revoked. |
402 |
Your balance is too low for this call or file. |
403 |
The key lacks the required scope, the e-mail address is not verified, or the account is suspended. |
408 |
The upload did not arrive in time. |
409 |
A request with the same Idempotency-Key is still running. |
413 |
The file is larger than 50 MB. |
415 |
Not a WAV file. |
422 |
The recording is too short or too long, or the Idempotency-Key was used for a different request. |
429 |
Too many requests, or too many calls and file analyses at the same time. Wait for Retry-After seconds. |
500 |
Something went wrong on our side. |
503 |
Noesis is busy or temporarily unavailable. Retry after the Retry-After seconds. |
Every error body has the shape described in Errors, with a stable error.code.
Example
curl "https://api.noesis.detectif.ai/v1/detect/file" \
-H "Authorization: Bearer $DETECTIF_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-F "file=@call.wav"import os
import uuid
import requests
with open("call.wav", "rb") as f:
resp = requests.post(
"https://api.noesis.detectif.ai/v1/detect/file",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
files={"file": f},
timeout=300,
)
print(resp.status_code, resp.json())import { readFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
const form = new FormData();
form.append("file", new Blob([await readFile("call.wav")]), "call.wav");
const res = await fetch("https://api.noesis.detectif.ai/v1/detect/file", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DETECTIF_API_KEY}`,
"Idempotency-Key": randomUUID(),
},
body: form,
});
console.log(res.status, await res.json());Get a call session
GET /v1/detect/sessions/{session_id}
Returns one of your calls or file analyses by session id (from the stream token or the socket's ready message). During a call: status active, the latest classification (latest), the audio seconds received so far and the timestamps. After it: the final answer (label, category, confidence, decided, timeline). A token's session not started yet is waiting. Sessions of other accounts return 404. Details are kept for 30 days; after that the session keeps its times, seconds and final answer only. Requires scope noesis:read.
Full URL: https://api.noesis.detectif.ai/v1/detect/sessions/{session_id}. Send your API key as Authorization: Bearer <your API key>.
Request
Headers:
| Name | Type | Required | Description |
|---|---|---|---|
Authorization |
string | yes | Bearer <your API key>. Keys are created in the dashboard; see Authentication. |
Path parameters:
| Name | Type | Required | Description |
|---|---|---|---|
session_id |
string | yes | The session id (32 lowercase hexadecimal characters) from the stream token, the socket's ready or usage event, or a recording's result. |
Response
200: Success.
| Field | Type | Always there | Description |
|---|---|---|---|
request_id |
string or null | no | |
type |
string | no | (default "session"; always "session") |
object |
string | no | (default "noesis.session"; always "noesis.session") |
session_id |
string | yes | |
stream_session_id |
string or null | no | The session id in the socket's ready event (the id the analysis gave the call). session_id is the call's id in your account (the one a stream token returns and the usage event carries). Both work for lookups. |
operation_id |
string or null | no | |
status |
string | yes | waiting: the stream token was created but not used yet; active: the call is running; completed / interrupted / failed: the call ended. (one of waiting, expired, active, completed, interrupted, failed) |
closed |
boolean | yes | |
call_id |
string or null | no | Your call id, or the provider's (Twilio callSid, Plivo callUuid). |
transport |
string or null | no | (one of websocket, file) |
orchestration |
string or null | no | binary, json, twilio, plivo or file. |
encoding |
string or null | no | |
sample_rate |
integer or null | no | |
channels |
integer or null | no | |
record |
boolean | yes | |
started_at |
string or null | no | |
ready_at |
string or null | no | |
ended_at |
string or null | no | |
end_reason |
string or null | no | |
audio_seconds |
number | yes | Seconds of the called person's audio received so far. |
billed_seconds |
number or null | no | |
credits_charged |
integer or null | no | |
latest |
object or null | no | The latest classification event (live during the call). |
events |
array of object | no | Classification events, oldest first. |
error |
string or null | no | |
label |
string or null | no | The answer: the final one after the call, the latest during it. |
category |
string or null | no | |
confidence |
number or null | no | |
decided |
boolean or null | no | |
timeline |
array of object or null | no |
Example response:
{
"request_id": "req_8f14e45fceea167a5a36dedd",
"type": "session",
"object": "noesis.session",
"session_id": "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f",
"stream_session_id": "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f",
"operation_id": "op_6f1ed002ab5595859014ebf0951522d9",
"status": "completed",
"closed": true,
"call_id": "CA0123456789abcdef0123456789abcdef",
"transport": "websocket",
"orchestration": "twilio",
"encoding": "mulaw",
"sample_rate": 8000,
"channels": 1,
"record": true,
"started_at": "2026-10-19T09:30:00Z",
"ready_at": "2026-10-19T09:30:00Z",
"ended_at": "2026-10-19T09:31:12Z",
"end_reason": "client_end",
"audio_seconds": 71.4,
"billed_seconds": 71.4,
"latest": {
"type": "classification",
"seq": 1,
"version": 1,
"t": 4.2,
"label": "human",
"category": "human",
"confidence": 0.93,
"change": "initial",
"trigger": "speech",
"reason": "A person answered and greeted the caller."
},
"events": [
{
"type": "classification",
"seq": 1,
"version": 1,
"t": 4.2,
"label": "human",
"category": "human",
"confidence": 0.93,
"change": "initial",
"trigger": "speech",
"reason": "A person answered and greeted the caller."
}
],
"label": "human",
"category": "human",
"confidence": 0.93,
"decided": true,
"timeline": [
{
"type": "classification",
"seq": 1,
"version": 1,
"t": 4.2,
"label": "human",
"category": "human",
"confidence": 0.93,
"change": "initial",
"trigger": "speech",
"reason": "A person answered and greeted the caller."
}
]
}Errors
| Status | Meaning |
|---|---|
400 |
The request is invalid, for example an API key in the URL or an unsupported parameter. |
401 |
The API key is missing, invalid or revoked. |
403 |
The key lacks the required scope, the e-mail address is not verified, or the account is suspended. |
404 |
No session with this id exists in your account. |
429 |
Too many requests, or too many calls and file analyses at the same time. Wait for Retry-After seconds. |
500 |
Something went wrong on our side. |
Every error body has the shape described in Errors, with a stable error.code.
Example
curl "https://api.noesis.detectif.ai/v1/detect/sessions/5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f" \
-H "Authorization: Bearer $DETECTIF_API_KEY"import os
import requests
resp = requests.get(
"https://api.noesis.detectif.ai/v1/detect/sessions/5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"},
timeout=30,
)
print(resp.status_code, resp.json())const res = await fetch("https://api.noesis.detectif.ai/v1/detect/sessions/5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f", {
headers: {
Authorization: `Bearer ${process.env.DETECTIF_API_KEY}`,
},
});
console.log(res.status, await res.json());List call sessions
GET /v1/detect/sessions
Lists your calls and file analyses, newest first. Filter with call_id to find the session of a provider call (Twilio callSid, Plivo callUuid, taken from the start message) or of your own call id. Page with limit and cursor. Requires scope noesis:read.
Full URL: https://api.noesis.detectif.ai/v1/detect/sessions. Send your API key as Authorization: Bearer <your API key>.
Request
Headers:
| Name | Type | Required | Description |
|---|---|---|---|
Authorization |
string | yes | Bearer <your API key>. Keys are created in the dashboard; see Authentication. |
Query parameters:
| Name | Type | Required | Description |
|---|---|---|---|
call_id |
string or null | no | Only sessions of this call id (yours, or Twilio's callSid / Plivo's callUuid). (at most 200 characters) |
limit |
integer | no | How many sessions to return (1-100). (1 to 100; default 20) |
cursor |
string or null | no | next_cursor from the previous page. (at most 256 characters) |
Response
200: Success.
| Field | Type | Always there | Description |
|---|---|---|---|
request_id |
string | yes | |
object |
string | yes | (always "list") |
data |
array of object | yes | |
data.request_id |
string or null | no | |
data.type |
string | no | (default "session"; always "session") |
data.object |
string | no | (default "noesis.session"; always "noesis.session") |
data.session_id |
string | yes | |
data.stream_session_id |
string or null | no | The session id in the socket's ready event (the id the analysis gave the call). session_id is the call's id in your account (the one a stream token returns and the usage event carries). Both work for lookups. |
data.operation_id |
string or null | no | |
data.status |
string | yes | waiting: the stream token was created but not used yet; active: the call is running; completed / interrupted / failed: the call ended. (one of waiting, expired, active, completed, interrupted, failed) |
data.closed |
boolean | yes | |
data.call_id |
string or null | no | Your call id, or the provider's (Twilio callSid, Plivo callUuid). |
data.transport |
string or null | no | (one of websocket, file) |
data.orchestration |
string or null | no | binary, json, twilio, plivo or file. |
data.encoding |
string or null | no | |
data.sample_rate |
integer or null | no | |
data.channels |
integer or null | no | |
data.record |
boolean | yes | |
data.started_at |
string or null | no | |
data.ready_at |
string or null | no | |
data.ended_at |
string or null | no | |
data.end_reason |
string or null | no | |
data.audio_seconds |
number | yes | Seconds of the called person's audio received so far. |
data.billed_seconds |
number or null | no | |
data.credits_charged |
integer or null | no | |
data.latest |
object or null | no | The latest classification event (live during the call). |
data.events |
array of object | no | Classification events, oldest first. |
data.error |
string or null | no | |
data.label |
string or null | no | The answer: the final one after the call, the latest during it. |
data.category |
string or null | no | |
data.confidence |
number or null | no | |
data.decided |
boolean or null | no | |
data.timeline |
array of object or null | no | |
has_more |
boolean | yes | |
next_cursor |
string or null | yes |
Example response:
{
"request_id": "req_8f14e45fceea167a5a36dedd",
"object": "list",
"data": [
{
"type": "session",
"object": "noesis.session",
"session_id": "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f",
"stream_session_id": "5b2f0c9e8d7a4b6c9e1f2a3b4c5d6e7f",
"operation_id": "op_6f1ed002ab5595859014ebf0951522d9",
"status": "completed",
"closed": true,
"call_id": "CA0123456789abcdef0123456789abcdef",
"transport": "websocket",
"orchestration": "twilio",
"encoding": "mulaw",
"sample_rate": 8000,
"channels": 1,
"record": true,
"started_at": "2026-10-19T09:30:00Z",
"ready_at": "2026-10-19T09:30:00Z",
"ended_at": "2026-10-19T09:31:12Z",
"end_reason": "client_end",
"audio_seconds": 71.4,
"billed_seconds": 71.4,
"latest": {
"type": "classification",
"seq": 1,
"version": 1,
"t": 4.2,
"label": "human",
"category": "human",
"confidence": 0.93,
"change": "initial",
"trigger": "speech",
"reason": "A person answered and greeted the caller."
},
"events": [
{
"type": "classification",
"seq": 1,
"version": 1,
"t": 4.2,
"label": "human",
"category": "human",
"confidence": 0.93,
"change": "initial",
"trigger": "speech",
"reason": "A person answered and greeted the caller."
}
],
"label": "human",
"category": "human",
"confidence": 0.93
}
],
"has_more": false
}Errors
| Status | Meaning |
|---|---|
400 |
The request is invalid, for example an API key in the URL or an unsupported parameter. |
401 |
The API key is missing, invalid or revoked. |
403 |
The key lacks the required scope, the e-mail address is not verified, or the account is suspended. |
429 |
Too many requests, or too many calls and file analyses at the same time. Wait for Retry-After seconds. |
500 |
Something went wrong on our side. |
Every error body has the shape described in Errors, with a stable error.code.
Example
curl "https://api.noesis.detectif.ai/v1/detect/sessions" \
-H "Authorization: Bearer $DETECTIF_API_KEY"import os
import requests
resp = requests.get(
"https://api.noesis.detectif.ai/v1/detect/sessions",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"},
timeout=30,
)
print(resp.status_code, resp.json())const res = await fetch("https://api.noesis.detectif.ai/v1/detect/sessions", {
headers: {
Authorization: `Bearer ${process.env.DETECTIF_API_KEY}`,
},
});
console.log(res.status, await res.json());Get your Noesis usage
GET /v1/detect/usage
Your Noesis calls and call minutes over the last days days (default 30): how many calls and file analyses, seconds of audio, billed minutes and what was charged, and how many run right now. Requires scope noesis:read.
Full URL: https://api.noesis.detectif.ai/v1/detect/usage. Send your API key as Authorization: Bearer <your API key>.
Request
Headers:
| Name | Type | Required | Description |
|---|---|---|---|
Authorization |
string | yes | Bearer <your API key>. Keys are created in the dashboard; see Authentication. |
Query parameters:
| Name | Type | Required | Description |
|---|---|---|---|
days |
integer | no | Length of the period in days, ending now (1-90). (1 to 90; default 30) |
Response
200: Success.
| Field | Type | Always there | Description |
|---|---|---|---|
request_id |
string | yes | |
object |
string | yes | (always "noesis.usage") |
days |
integer | yes | |
period |
object | yes | |
calls |
integer | yes | Calls and file analyses started in the period. |
calls_used |
integer | yes | Same as calls (kept for older clients). |
streams |
integer | yes | |
files |
integer | yes | |
audio_seconds |
number | yes | |
billed_seconds |
number | yes | |
minutes |
number | yes | Billed call minutes (billed_seconds / 60). |
credits_charged |
integer or null | no | What the calls used from your balance. |
active_sessions |
integer | yes | |
concurrent_limit |
integer | yes | How many calls or file analyses may run at the same time. |
plan |
string | yes | (one of free, unlimited) |
unlimited |
boolean | yes |
Example response:
{
"request_id": "req_8f14e45fceea167a5a36dedd",
"object": "noesis.usage",
"days": 30,
"period": {
"start": "2026-09-19T09:30:00Z",
"end": "2026-10-19T09:30:00Z"
},
"calls": 12,
"calls_used": 12,
"streams": 10,
"files": 2,
"audio_seconds": 1284.5,
"billed_seconds": 1280,
"minutes": 21.33,
"active_sessions": 1,
"concurrent_limit": 2,
"plan": "free",
"unlimited": false
}Errors
| Status | Meaning |
|---|---|
400 |
The request is invalid, for example an API key in the URL or an unsupported parameter. |
401 |
The API key is missing, invalid or revoked. |
403 |
The key lacks the required scope, the e-mail address is not verified, or the account is suspended. |
429 |
Too many requests, or too many calls and file analyses at the same time. Wait for Retry-After seconds. |
500 |
Something went wrong on our side. |
Every error body has the shape described in Errors, with a stable error.code.
Example
curl "https://api.noesis.detectif.ai/v1/detect/usage" \
-H "Authorization: Bearer $DETECTIF_API_KEY"import os
import requests
resp = requests.get(
"https://api.noesis.detectif.ai/v1/detect/usage",
headers={"Authorization": f"Bearer {os.environ['DETECTIF_API_KEY']}"},
timeout=30,
)
print(resp.status_code, resp.json())const res = await fetch("https://api.noesis.detectif.ai/v1/detect/usage", {
headers: {
Authorization: `Bearer ${process.env.DETECTIF_API_KEY}`,
},
});
console.log(res.status, await res.json());Check service health
GET /v1/health
Whether the service and its parts are up: status is ok, or degraded when a part is unavailable. No authentication needed.
Full URL: https://api.noesis.detectif.ai/v1/health. No API key needed.
Response
200: Success.
| Field | Type | Always there | Description |
|---|---|---|---|
request_id |
string | yes | |
status |
string | yes | (one of ok, degraded) |
version |
string | yes | |
database |
string | yes | (one of ok, unavailable) |
detection |
string | yes | (one of ok, unavailable) |
Example response:
{
"request_id": "req_8f14e45fceea167a5a36dedd",
"status": "ok",
"version": "1.0.0",
"database": "ok",
"detection": "ok"
}Errors
| Status | Meaning |
|---|---|
429 |
Too many requests, or too many calls and file analyses at the same time. Wait for Retry-After seconds. |
500 |
Something went wrong on our side. |
Every error body has the shape described in Errors, with a stable error.code.
Example
curl "https://api.noesis.detectif.ai/v1/health"import os
import requests
resp = requests.get(
"https://api.noesis.detectif.ai/v1/health",
timeout=30,
)
print(resp.status_code, resp.json())const res = await fetch("https://api.noesis.detectif.ai/v1/health");
console.log(res.status, await res.json());OpenAPI and Postman
- noesis-openapi.json and noesis-openapi.yaml
- Download the Postman collection: the Noesis endpoints are in the Noesis folder, with their own
noesisBaseUrlvariable.
MCP tools
The MCP server can analyse a recorded call and read call sessions. Live calls are not available through MCP: they use the WebSocket above.
| Tool | What it does | Inputs |
|---|---|---|
analyze_call_recording |
Find out who or what answered a recorded phone call: a person, voicemail, an IVR menu or another machine. | audio_base64, filename, call_id (optional), language (optional), remote_channel (optional), record (optional), idempotency_key (optional) |
get_call_analysis |
Status of a call-recording analysis: running (with progress from 0 to 1), succeeded (with the result: first and final answer and the timeline of answers) or failed (with the error; nothing is charged then). | operation_id |
get_call_session |
Read one Noesis call session of this account: live state while the call runs (status, latest answer, seconds of audio so far), the final answer afterwards. | session_id |