Skip to Content

Calls

Every conversation becomes a record you can find, read, act on while it's live, and delete.

A call record tells you when a conversation happened, what was said, which tools ran, and how it ended. Ordinary reads are PII-redacted. Raw artifacts require audited access.

curl 'https://api.kejue.co/v1/calls?direction=inbound&handled_by=ai&limit=25' \
  -H "Authorization: Bearer $KEJUE_API_KEY"

Placing outbound calls is a separate workflow — Outbound calling.

Listing and filtering

GET /v1/calls returns non-eval, non-purged calls by default and paginates with an opaque cursor (Pagination). Filters combine with AND:

AxisParameters
Agentagent_id, agent_name, or repeated agent_ids (any listed agent)
Statestatus, lifecycle/display outcome, call direction
Who handled ithandled_by=ai|human — agent-run vs ingested human calls
Time and sizestart-time range, call/total duration ranges, turn-count range
Flagsrecording, legal-hold, purged state
Extraction resultsup to 20 repeated ef filters
Campaign and channelcampaign_id, campaign_name, flow_id, channel, repeated channel_not
Call identitycall_id + call_id_match, caller_number + caller_match, platform_number, human_agent, failure_code
Guardrailsguardrail_name, guardrail_id, guardrail_severity, guardrail_set_slug
Tool callstool_slug, tool_name, tool_kind, tool_ok, tool_error_kind
Orderingsort field and direction

Unknown or duplicated singleton parameters return 400. The repeatable parameters are ef (at most 20), agent_ids (at most 120 UUIDs), and channel_not (at most six channels). Agent IDs combine with OR inside the scope; channel exclusions combine with AND. Both combine with all other filters using AND. An ef filter is unpadded base64url of JSON: object (extraction-object UUID), field, a type-compatible op, value — operators per field type in the CallExtractionFilter schema (API reference).

The guardrail and tool axes are existence tests over a child table: a call matches when it has a guardrail trigger (or tool invocation) with those properties. All parameters in one family must describe the same row — tool_slug=book_appointment&tool_ok=false returns calls where that specific tool failed, not calls that called it and separately failed something else. The two families are independent of each other.

call_id and caller_number are text searches (1–64 characters, trimmed, no number normalization). Their match parameter picks the comparison:

Match valuecall_id_matchcaller_match
starts_withdefaultprefix
containssubstringdefault
isexact UUIDexact value, case-sensitive

call_id searches ignore case, so a pasted short ID prefix finds the call. Search caller_number the way the number is stored — +9715 and 9715 are different prefixes. An invalid match value returns 400 invalid_query_parameter.

Filters that name a nullable column match only rows where it is set: human_agent is null on agent-run calls, channel is null on rows predating its backfill, and failure_code is null on calls that succeeded.

For example, this scopes calls to either agent while excluding web tests and transfer briefs:

curl --get 'https://api.kejue.co/v1/calls' \
  --data-urlencode "agent_ids=$AGENT_A" \
  --data-urlencode "agent_ids=$AGENT_B" \
  --data-urlencode 'channel_not=web_test' \
  --data-urlencode 'channel_not=transfer_brief' \
  -H "Authorization: Bearer $KEJUE_API_KEY"

channel_not uses the same channel vocabulary as channel. Null channels do not satisfy an exclusion, matching the analysis query's neq behavior. Existing agent_id and channel filters remain supported and can further narrow this scope.

Reading a call

GET /v1/calls/{id}/summary returns just the post-call summary. Its status is queued, running, done, or error; read the summary text when it is done. 404 call_summary_not_found means no summary is available yet.

GET /v1/calls/{id} returns the full record: timing and lifecycle, outcome, direction, safe number metadata, contact, exact deployed agent version, redacted transcript with entity metadata, redacted tool invocations, actions, injected-context delivery state, summary/extraction/webhook-delivery results, recording metadata, turn metrics, caller-turn clips, and legal-hold/purge state.

Four fields say what kind of call it was:

FieldValues
channelsip_inbound, sip_outbound, web_sdk (web calls), web_test (dashboard test calls), eval, transfer_brief (a warm transfer's consult leg); null for human-handled calls
directioninbound or outbound. Web and test calls are inbound.
metadata.sourcereal_call, web_call, test_call, or eval_call
agent_version_is_drafttrue when the call ran the agent's unpublished draft — test calls usually do. agent_version is then null, since a draft has no number.

caller_number is always the external party: the caller on an inbound call, the dialed destination on an outbound one. platform_number is our side — the number dialed, or the caller ID presented. Text calls report recording_enabled: false.

A failed call explains itself. failure_code is a stable code to branch on, failure_reason a customer-safe sentence, and ended_reason why the call ended (null while it is live). Detail adds the evidence behind them — see Why a call failed.

Calls in another workspace and eval-backed calls return the same 404 call_not_found; while purge cleanup or a delivery is in flight, the response carries Retry-After.

Transcript rows

Every row has speaker, text, timestamp (Unix epoch seconds), kind, and leg. speaker is agent, caller, tool_call, tool_result, system, wait, or noise; kind is empty on ordinary rows and otherwise dtmf_received, dtmf, dtmf_sent, transcription_failed, agent_handoff, or tool_interrupted — meanings on webhook events.

Rows that need more carry it: speech_id and interrupted on agent rows, name and is_error on tool rows, and dtmf_masked with digit_count where the caller used the keypad — we publish how many keys were pressed and never the digits. reason explains a non-empty kind or a masked value from a closed vocabulary. Handoff rows add from_agent and to_agent, the agent slugs either side. Full field list: API reference.

Latency and Requests

The dashboard's Latency tab shows the call summary and one compact row per turn. Response, transcription, model and speech-synthesis timings are visible together; you do not need to expand each turn to compare measurements.

Each turn's reply time is split into the parts that add up to it: end-of-turn wait, transcription wait, model time to first token, tool wait, first-sentence buffering, speech synthesis to first audio, and the remaining hand-off. The Latency tab draws them as one bar per turn, so the slowest part stands out. In GET /v1/calls/{id}, each turn_metrics row carries them as eou_delay_ms, transcribe_wait_ms, model_first_token_ms, tool_wait_ms, first_chunk_ms, tts_first_audio_ms and handoff_ms. When breakdown_version is 1, they sum exactly to response_latency_ms; when a part is unknown it is null. model_hidden_ms is model time that ran before the caller finished speaking and is not part of the sum.

Each turn’s model_name is the catalog display name, or null when no unambiguous public name is available. model_role describes the work the model performed. Internal model_family diagnostics are omitted. An absent measurement is unavailable; a measured zero is still zero.

The Requests tab lists every provider request in order, with timing, token or audio usage, and failures inline — filterable to a single turn. Long calls paginate beyond the first 200 requests. Older records without an exact turn correlation are marked as estimates.

The public event ledger also accepts a turn_index with session_id to inspect one conversational turn. See Usage and metering.

Trace and timeline

The Trace button on a call opens every event of the call on one timeline: caller and agent audio, transcription, end-of-turn decisions, model and speech-synthesis requests, tool runs, transfers, SIP signalling and errors, laid over the recording. Click an error for its stage, HTTP status, request ID, model and provider. Download trace exports the same data as Chrome Trace Event JSON.

The same data comes from GET /v1/calls/{id}/timeline:

curl https://api.kejue.co/v1/calls/CALL_ID/timeline \
  -H "Authorization: Bearer $KEJUE_API_KEY"

Every time is milliseconds from anchor, the moment the agent joined the call; connection and SIP events can be negative because they happen first.

KeyContents
eventsEvery event, sorted by t: id, t, nullable duration d, track, kind, turn, speech_id, level (info, warn, error), label, source, attrs
turnsPer-turn latency: response, endpointing, transcription, model, speech-synthesis and tool milliseconds, plus outcome and model
transcriptThe redacted transcript on the same clock
modelsPer model: requests, errors, average time to first token
recordingOffset and duration of the ready recording, or null
sources, truncatedWhich evidence was available, and whether an event cap was reached
trackWhat it holds
call, stateLifecycle (joined, answered, ended) and agent state (listening, thinking, speaking)
caller_speech, agent_speech, vadWho was speaking, playout, barge-ins
stt, endpoint, turn, decisionTranscripts, end-of-turn waits and verdicts, turn commits
llm, ttsModel and synthesis requests, with first-token and first-byte marks
tool, transfer, guardrail, dtmfTool runs, transfer steps, guardrail triggers, keypad input (digits masked)
sipSIP requests and responses for the call's legs
degradedA fallback the agent switched to, with attrs.reason
errorReal failures: provider_error, stt_error, tts_error, llm_error, tool_error, session_error, session_open_failed

An error event’s attrs carry classified evidence — stage, a safe message, http_status, request_id, the service’s display name in provider, and error_class where known. Use these fields and support IDs to report the failing stage; raw upstream diagnostic text isn't returned.

You can read the timeline while a call is live. Events update periodically, and the sip track fills in when a leg ends. Errors and degraded-mode events are always kept when a cap truncates the timeline. Calls handled before timelines were recorded return model requests, tool runs, turns and transcript only. The operation takes no query parameters and is not paginated.

Why a call failed

failure_code is stable, so you can branch on it. Treat anything you don't recognize as unknown.

CodeMeaning
caller_hangup_pre_answerThe caller hung up before the agent answered, or nobody joined a web call within about three minutes
agent_dispatch_timeoutNo agent was available to answer
provider_busy, provider_no_answerBusy, or no answer
provider_rejected, provider_forbiddenThe carrier refused or declined the call
provider_authenticationThe carrier rejected our credentials
destination_invalid, caller_id_invalidThe carrier rejected the destination or the caller ID
provider_capacity, provider_rate_limitedThe route was at capacity or rate-limited
provider_route_unavailableThe carrier returned a server error
provider_unknownThe provider never confirmed an outcome
media_pipeline_errorThe media session failed
dncr_blocked, dncr_unavailable, dncr_configuration_invalidDo Not Call Registry outcomes
unknownNo more specific cause

The dashboard labels calls the callee's side didn't take by outcome rather than "Failed": provider_busy → Busy, provider_no_answer → No answer (or Rejected when sip_failure shows the far end refused it), provider_rejected → Declined (SIP 603) or Rejected, destination_invalid → Invalid number, provider_forbidden → Blocked. status stays failed for all of them.

A vague code can sharpen later — provider_no_answer can become destination_invalid when the carrier's final response turns out to be a 404.

On calls through our SIP service, GET /v1/calls/{id} also carries the SIP evidence (Twilio Media Streams and web calls have none):

FieldContents
sip_failureThe final SIP status, status_text, reason, the carrier-visible call_id, the derived class, and — when the far end sent a Reason: Q.850 header — q850_cause and q850_text. source: "capture" marks an answer taken from Kejue Voice's own SIP capture (the carrier refused a call the provider reported as a plain hang-up). null without a SIP failure
sip_messagesCaptured messages for each leg's setup — the first INVITE, an auth challenge, the authenticated INVITE, and the final response — oldest first. hop is sonus for our SIP service and edge for our SIP edge; on a trunk that signals through the edge, edge messages are exactly what your carrier sent and received, with transport (udp, tcp or tls)
sip_rejectionsSIP-level refusals linked to this call (same shape as the trunk rejection list)
timeline_availableWhether the timeline has anything beyond start, answer and end — agent events, model requests, tool runs, turns, transcript, transfers, SIP or a recording

Raw provider and agent diagnostics aren't returned. Stable failure codes, SIP evidence, and request or call IDs are what you troubleshoot with.

Captured messages hold the start line and headers only — bodies are dropped, and digest response and cnonce values are redacted. They purge with the call.

Acting on a live call

Hang up

POST /v1/calls/{id}/hangup (no body) durably records the intent, then instructs the telephony provider to terminate the call.

curl -X POST https://api.kejue.co/v1/calls/CALL_ID/hangup \
  -H "Authorization: Bearer $KEJUE_API_KEY" \
  -H "Idempotency-Key: incident-884-hangup-1"

200 means the provider confirmed termination or the call was already over — never a guess. The response: call_id, terminal status, changed, provider_confirmation (confirmed|already_terminal), and reconciliation_status (scheduled = outbound-job linkage still healing; it doesn't weaken the confirmation).

Inject context

POST /v1/calls/{id}/context queues an encrypted system message the agent sees mid-call — a verified identity, an updated case status. content is UTF-8 up to 4,096 bytes; urgency is immediate, soon (default), or later. Not a prompt-variable update; send an Idempotency-Key.

The 202 returns a durable message (delivery_status: pending) and a Location for the parent call; poll after Retry-After and match the message id in data_messages — delivery moves pending → publishing → retrying → published | failed; stop at published or failed.

Media

GET /v1/calls/{id}/recording downloads call audio (Ogg/Opus); the written reason (8–500 characters) is audited. Select an exact recording_id or a role/leg/segment tuple (roles agent|caller|mixed; legs caller, transfer brief; zero-based segments) — mixing selectors is a 400. Call metadata reports recording|encrypting|ready|failed, duration, and size. One RFC 9110 Range is honored (206 + Content-Range; malformed or multiple ranges: JSON 416); download=true sets attachment disposition; 409 not ready; 410 audio gone, metadata kept.

GET /v1/calls/{id}/turn-audio?turn_index=N&leg=caller|brief — one short-lived WAV clip of a caller turn, from the list in call detail. Same recording permission, audited, accepts download and one byte range; 410 once the clip expires.

Transfer history

GET /v1/calls/{id}/transfers returns every transfer attempt with its append-only event timeline; payloads pass a fail-closed public allowlist and flag payload_redacted when internal keys were removed. Needs transfers:read; configuration is in Call actions. Handoffs to another agent appear here too, as kind: agent with method: handoff — see Handoffs.

Retention and deletion

Calls age out after the workspace's retention_days (Workspace settings); a purge tombstone records manual vs retention.

DELETE /v1/calls/{id} purges on demand — PHI and diagnostic content removed; a tombstone, billing aggregates, and scrubbed audit evidence remain. The call must be ended, past post-call processing, and off legal hold. 200: cleanup done; 202: durable recording/PCAP/turn-audio deletion jobs still running — follow Location/Retry-After and watch purge_cleanup counts.

POST /v1/calls/batch-delete (1–200 unique call UUIDs; Idempotency-Key required) returns one typed result per input: purged, purging, already_purged, legal_hold, active, processing, or not_found. Poll each purging entry's own poll_url — the batch is not one shared job.

Audited access and compliance

Some call data is too sensitive for routine reads. These operations are permission-gated, always audited, and hidden from the API-reference navigation while remaining in the published OpenAPI document, served normally. Approval friction is governed by pii_access_mode — workflow in Compliance.

  • GET /v1/calls/{id}/transcript-raw?leg=caller|brief&reason=... — newest encrypted raw transcript. Needs pii-access:unmask.
  • GET /v1/calls/{id}/tools/{toolId}/raw?reason=... — one tool invocation's original JSON request and response. Needs pii-access:unmask.
  • GET /v1/calls/{id}/sip-pcap/summary — pollable packet/byte/capture state, no packet bytes; 503 when capture isn't deployed.
  • GET /v1/calls/{id}/sip-pcap?reason=... — decrypted, validated PCAP download; one byte range. Needs calls:read-sip-pcap.
  • PUT /v1/calls/{id}/legal-hold with {"held": true} or {"held": false} — idempotent, returns changed, takes If-Match. A held call cannot be purged (manually or by retention); a purged call's hold can't change. A real change needs calls:legal-hold plus the legal_hold entitlement (403 entitlement_required, details.feature: "legal_hold"); re-sending the current state is a permitted no-op.

Never copy raw responses into logs, analytics, prompts, or support tickets; prefer the redacted call detail whenever it answers the question.

Permissions

PermissionGrants
calls:readlist, redacted detail, and timeline
calls:hanguplive-call termination
calls:inject-contextlive context injection
calls:download-recordingrecordings and caller-turn audio
transfers:readtransfer history
pii-access:unmaskraw transcript and raw tool I/O
calls:read-sip-pcapPCAP summary and download
calls:legal-holdhold changes
calls:deleteindividual and batch purge

See also Human-handled calls, Compliance, and Errors.

On this page