Skip to content

Telephony API Reference

Availability: Test environment Answers FORBIDDEN in production; enabled on the test environment on request. /status

Two groups of operations. Browser and app calls use a named API key from your server. The owner self-test (“Call my phone”) uses the signed-in workspace owner’s dashboard login and is refused for anyone else; the guide for it is Call my phone. Every error below is a GraphQL error with extensions.code as listed; see Error handling for the general shape.

mutation StartVoiceCall($input: SdkStartVoiceCallInput!) {
sdkStartVoiceCall(input: $input) {
sessionId
agentId
livekitUrl
livekitToken
roomName
expiresAt
}
}

Headers: x-api-key: <YOUR_API_KEY>, x-huat-platform: customer (see Authentication). Call it from your server. The API key must never reach a browser or app.

It starts a session exactly as sdkStart does (workspace scoping, the template gate and usage metering all apply) and mints a LiveKit join token for one fresh room. Variables go in variables:

{
"input": {
"agentId": 7,
"clientId": "call-2026-10-19-0042",
"context": { "source": "web-call", "plan": "trial" }
}
}
FieldTypeRequiredNotes
agentIdInt!YesAn agent in the API key’s workspace; NOT_FOUND otherwise. Its published workflow answers every turn, so make it voice-safe.
clientIdStringNoYour own identifier for the caller or the call, shown on the session. At most 255 characters. Generated when omitted.
contextJSONNoA flat per-call object, exposed to the workflow as ctx.session.context. Same rules as the context of sdkStart. Pass it through variables, not as an inline literal.
engineVoiceEngineNoWORKFLOW (default): the agent’s published workflow answers every turn. LIVE: a speech-to-speech model answers from the agent’s instructions only (no workflow, no tools); the transcript is stored after the call. See the live engine.
FieldTypeNotes
sessionIdInt!The session created for this call (the conversation record).
agentIdInt!The agent that will answer.
livekitUrlString!The LiveKit server URL (wss://...) to connect the LiveKit client to.
livekitTokenString!The join token for the one room of this call. See security.
roomNameString!The name of the room created for this call.
expiresAtDateTime!When the token stops being accepted for joining, about two minutes after the request. A call already joined continues.
  • It can join exactly one room, the one for this call, and no other.
  • The caller may publish audio and subscribe. There is no data channel and the caller cannot edit metadata.
  • It asks LiveKit to dispatch Wetel’s voice worker into the room as soon as the caller joins.
  • It is valid to join for about two minutes. Join immediately; mint a new call for a later attempt.
SituationCodeMessage
No API key headerUNAUTHENTICATEDMissing X-Api-Key header
Unknown or revoked keyUNAUTHENTICATEDInvalid API key
Voice not enabled on the environmentFORBIDDENVoice calls are not enabled on this environment
Platform header missingFORBIDDENPlatform is not specified!
Agent not in the key’s workspaceNOT_FOUNDthe agent was not found
LIVE requested where it is offBAD_REQUEST, extensions.originalError.code VOICE_ENGINE_UNAVAILABLEthe live engine is not enabled; availableEngines lists what works
The API key’s daily call cap reachedINTERNAL_SERVER_ERROR with extensions.status 429Daily voice call limit reached for this API key; try again tomorrow (UTC)
  • Per client address: 60 a minute by default, shared by every caller behind one server (that is, all of your calls from one server count together).
  • Per workspace: 30 call starts a minute. The ceiling is counted per API process, so with several API instances the effective ceiling can be higher.
  • Per API key per day: 1,000 call requests per UTC day by default (set per environment), counted across all servers. It resets at 00:00 UTC. Every request that passes the checks above counts, including one whose call then fails to start. Once reached, the mutation answers HTTP-429-style (extensions.status 429) with the message Daily voice call limit reached for this API key; try again tomorrow (UTC): do not retry that one until the next UTC day. This is a ceiling against a runaway script, not a plan limit.
  • The over-limit response is an error with a message and may not carry a specific extensions.code. Do not branch on a code: treat any error from this mutation as retryable after a short wait, with backoff, unless it is one of the codes above.
  • Usage is metered with the session (speech and model usage) and counts toward the monthly spend cap.

The join token’s contents are readable by the caller’s browser. It carries the credential the voice worker uses for that one session, the same kind of session credential sdkStart hands to the chat SDK. So:

  • Treat a token as belonging to one caller. Never hand one caller’s token to another.
  • Never log it, share it or paste it into a support ticket.
  • Never put your API key in a page. Only your server calls this mutation.
  • Authenticate your own caller before you mint a call, and rate-limit your own start endpoint.

See Start a call from your app for a complete Node example and the browser example.

A curl equivalent:

Terminal window
curl -sS "$WETEL_API_URL" \
-H 'content-type: application/json' \
-H "x-api-key: $WETEL_API_KEY" \
-H 'x-huat-platform: customer' \
--data '{
"query": "mutation($input: SdkStartVoiceCallInput!){ sdkStartVoiceCall(input:$input){ sessionId livekitUrl roomName expiresAt } }",
"variables": { "input": { "agentId": 7 } }
}'

(This example leaves out livekitToken on purpose, so it does not land in your shell history or logs.)

A call is a session. Read its transcript with the sessions API. A call nobody joins is closed by the platform: about 10 minutes after the request (checked every 5 minutes, so within about 15 minutes) its session is set to EXPIRED, with no evaluation and no events. A call counts as joined once the caller’s first turn reached the session.

engine: LIVE on either start mutation hands the call to a speech-to-speech model that answers from the agent’s instructions only: no workflow, no guardrail nodes, no tools, and the reply is faster (about 1.5 s against 3 to 5 s). It is a deployment-level switch with its own status row; where the switch is off, a request with engine: LIVE is refused with BAD_REQUEST (extensions.originalError.code VOICE_ENGINE_UNAVAILABLE, with availableEngines) before anything is created or counted. A call that does not set engine behaves as before. A short guide with an example is in Choosing a voice engine.

For a LIVE call the voice worker stores the transcript afterwards with sdkRecordVoiceTranscript, using the call’s own token. It is not meant to be called from a browser or with an API key: it appends the spoken lines (at most 200 lines of 2,000 characters, 60,000 characters in total, in order) to the call’s session once, without running the agent, and only for a voice call session that is active or ended within the last 30 minutes. It returns true when the lines were stored and false when the call already has a transcript.

Makes one of your AI employees place a phone call to the workspace owner’s own number: the “Call my phone” self-test. It uses the signed-in workspace owner’s login (a dashboard JWT), not an API key, and only the workspace owner may call it. The number must be confirmed first; see Confirming your phone number. Availability: status row. The guide is Call my phone.

mutation StartOutboundCall($input: StartOutboundCallInput!) {
startOutboundCall(input: $input) {
callId
status
maxDurationSeconds
}
}
{
"input": {
"agentId": 7,
"toNumber": "+60123456789",
"selfTest": true,
"maxDurationSeconds": 120
}
}
FieldTypeRequiredNotes
agentIdInt!YesThe AI employee that places the call. NOT_FOUND when it is not in your workspace.
toNumberString!YesE.164: a plus and 8 to 15 digits. For a self-test it must equal the phone number on the owner’s own profile and start with an allowed prefix.
selfTestBoolean!YesMust be true. false is refused with “not available yet”.
maxDurationSecondsIntNoHard maximum call length, 15 to 300. Default 120. The call is ended at this limit.
engineVoiceEngineNoWORKFLOW (default) or LIVE, as for sdkStartVoiceCall.

Allowed destination prefixes are +1 and +60 unless the workspace sets its own list.

FieldTypeNotes
callIdInt!Id of the outbound call record.
statusString!Always queued: the dial happens asynchronously a moment later.
maxDurationSecondsInt!The maximum call length that applies.

The mutation returns at once. The phone rings a moment later and the AI says one short opening sentence that identifies it as an AI assistant. The result never contains a join token or the phone number.

SituationCode
Outbound calling is off for the environment or for the workspace, or the platform kill switch is onFORBIDDEN
The workspace’s daily call or minute limit is reachedFORBIDDEN
The destination prefix is not allowed, or toNumber is not your own profile numberFORBIDDEN
The number has not been confirmed with a spoken code yetFORBIDDEN
Caller is not the workspace ownerFORBIDDEN
toNumber is not valid E.164, selfTest is false, the duration is outside 15 to 300, or LIVE is not enabledBAD_REQUEST
agentId is not in your workspaceNOT_FOUND

Each call record moves through queued, dialing, ringing, answered, then an end state: completed, voicemail, no_answer, busy, declined, failed, cancelled or blocked. A watcher records completed with the call’s duration and end reason once an answered call ends; the voice worker detects voicemail, and a voicemail call is hung up without leaving a message. The mutation itself only ever reports queued; read the later states with outboundCall.

Reading a call: outboundCall and outboundAvailability

Section titled “Reading a call: outboundCall and outboundAvailability”

Both use the signed-in workspace owner’s login and are refused for anyone else. They are reads: they never place a call.

query OutboundAvailability {
outboundAvailability {
available
reason
phoneLast4
phoneCountry
defaultDurationSeconds
}
}
query OutboundCall($id: Int!) {
outboundCall(id: $id) {
id
status
toCountry
toNumberLast4
durationSeconds
endReason
sessionId
}
}

outboundAvailability tells a screen whether the “Call my phone” self-test could start now, so a button can be hidden or disabled without placing a call. available is false with a plain reason: NOT_ENABLED, NO_PHONE, COUNTRY_NOT_ALLOWED, PHONE_NOT_VERIFIED, DAILY_LIMIT or UNAVAILABLE. NOT_ENABLED covers every kind of “off” together on purpose, so it does not tell an abuser which control to target. It does not check the AI employee or whether the voice worker is online. The usage limits are hidden unless the workspace has calls enabled, and the full number is never returned (only phoneLast4 and phoneCountry). Feature-detect this query before showing a call button: a backend that does not have it answers with a validation error for the whole query.

outboundCall(id) returns the state of one call in your workspace, using the callId from startOutboundCall. An id from another workspace answers not found. Poll about every 2 seconds while the status is queued, dialing or ringing, every 5 seconds while answered, and stop at an end state. It returns only the last four digits and the country of the called number, never the number, its hash or a join token. endReason is a short machine code, not text to show as it is.

Before a self-test can dial the number on the owner’s profile, the owner must prove the number is theirs: an AI employee calls it and reads a six-digit code, and the owner sends that code back. The outbound self-test is still an owner testing their own phone. It never calls prospects, customers or anyone else. Availability: status row.

All four operations are workspace owner only and use a dashboard JWT.

mutation RequestPhoneVerification($input: RequestPhoneVerificationInput!) {
requestPhoneVerification(input: $input) {
callId
status
codeExpiresAt
maxAttempts
}
}
mutation ConfirmPhoneVerification($code: String!) {
confirmPhoneVerification(code: $code) {
state
phoneLast4
verifiedUntil
}
}
query PhoneVerificationStatus {
phoneVerificationStatus {
state
phoneLast4
requiredForCalls
verifiedAt
verifiedUntil
codeExpiresAt
attemptsLeft
}
}
mutation CancelOutboundCall($id: Int!) {
cancelOutboundCall(id: $id) {
id
status
}
}
  • requestPhoneVerification(input: { agentId }) starts an outbound call from that AI employee to the phone number on your profile. It returns at once with a callId and status: "queued"; the phone rings a moment later and an AI voice reads the code twice. The code is never returned to you in the API. The call uses the workflow engine and lasts at most 45 seconds. A new request replaces the previous code.
  • confirmPhoneVerification(code) takes the six digits as a string (so a leading zero survives, for example "048215") and returns the new status, VERIFIED, on success.
  • phoneVerificationStatus says where the profile number stands: NOT_ENABLED, NO_PHONE, UNVERIFIED, CODE_SENT (with codeExpiresAt and attemptsLeft), VERIFIED (with verifiedAt and verifiedUntil) or UNAVAILABLE (treat as not verified). It returns only the last four digits of the number. requiredForCalls says whether this deployment insists on a confirmed number before a self-test.
  • cancelOutboundCall(id) hangs up a call that has not been answered yet (queued, dialing or ringing); the call becomes cancelled and the AI voice is released. It is idempotent, an already answered call is refused with BAD_REQUEST (hang up on your phone), and an id from another workspace answers not found. It is available even when outbound calling is switched off, because stopping a call must never be blocked. A cancel after dialing started still counts against the daily allowance.

Code rules.

RuleValue
Code6 digits, single use
Valid for10 minutes
Wrong guesses3, then the code is locked and you must request a new one
Confirmation lasts90 days, then the number must be confirmed again
Changing the phoneThe new number is unconfirmed straight away; no reset step is needed
Every failureThe same BAD_REQUEST, “That code is not correct or has expired”: wrong, expired, none pending, or locked

A verification call counts against the workspace’s daily call limit. Besides that it is limited to one call that reached the phone per number per day and three requests per user per day. requestPhoneVerification is refused with FORBIDDEN when phone verification or outbound calling is off for the environment or the workspace, the platform kill switch is on, or a limit is reached, and with BAD_REQUEST when the profile has no usable phone. phoneVerificationStatus answers NOT_ENABLED for every kind of “off” on purpose.

A deployment can be set to skip the confirmation (requiredForCalls: false); the default is that it is required.

The destination number of an outbound call is never stored in clear. Wetel keeps a per-workspace keyed hash of it, plus the last four digits and the country. Call audio is not recorded; see Call controls, privacy and compliance.