Pinnacle

Voice Calls

Start calls, connect WebSockets, send commands, and retrieve recordings.

Voice has two surfaces:

  • REST endpoints under /calls for call lifecycle, stream tokens, events, and recordings.
  • A bidirectional WebSocket from POST /calls/{id}/stream-token for live audio and commands.

For calls with more than two people, see Conference Calls.

Start an outbound call

These examples use the HTTP API directly and do not depend on an unreleased SDK. API reference pages show SDK examples only when the method is available in the verified stable package.

Set PINNACLE_API_KEY, PINNACLE_FROM_NUMBER, and PINNACLE_TO_NUMBER in your server environment. Set PINNACLE_IDEMPOTENCY_KEY to a new UUID for each intended call, and retain it when retrying that call. Only call recipients who have agreed to receive the call.

These examples create a call and a stream token. They do not enable recording. Enable recording only after obtaining the consent required for your use case; see recordings.

Requires Node.js 24 or later.

TypeScript
const apiKey = process.env.PINNACLE_API_KEY;
const from = process.env.PINNACLE_FROM_NUMBER;
const to = process.env.PINNACLE_TO_NUMBER;
const key = process.env.PINNACLE_IDEMPOTENCY_KEY;
if (!apiKey || !from || !to || !key) throw new Error("Set the four required environment variables");

async function post<T>(path: string, body: unknown, headers: Record<string, string> = {}): Promise<T> {
  const response = await fetch(`https://api.pinnacle.sh${path}`, {
    method: "POST",
    headers: { "PINNACLE-API-Key": apiKey!, "Content-Type": "application/json", ...headers },
    body: JSON.stringify(body),
    signal: AbortSignal.timeout(30_000),
  });
  if (!response.ok) throw new Error(`Pinnacle returned HTTP ${response.status}`);
  return await response.json() as T;
}

const call = await post<{ id: string }>("/calls", { from, to }, { "Idempotency-Key": key });
const stream = await post<{ stream_url: string }>(`/calls/${encodeURIComponent(call.id)}/stream-token`, {
  commands_enabled: true,
  stream_id: "agent",
});
// Pass stream.stream_url to your WebSocket client; do not log this bearer credential.

Manual REST flow

  1. Create the call with POST /calls, or use an existing inbound or outbound call ID.
  2. Create a short-lived token with POST /calls/{id}/stream-token.
  3. Open the returned stream_url with your WebSocket client and wait for the connection to open before sending commands. See Voice WebSockets.

Create a fresh stream token when reconnecting after expiry. The examples do not automatically reconnect. Use a bounded retry policy with backoff and stop when the call has ended.

Retrying safely

A create request that times out or fails mid-flight leaves you unsure whether a call was placed. Retrying blindly dials the recipient twice. Send an Idempotency-Key header and the call happens at most once, no matter how many times you repeat the request.

Shell
curl -X POST https://api.pinnacle.sh/calls \
  -H "PINNACLE-API-KEY: $PINNACLE_API_KEY" \
  -H "Idempotency-Key: 2f1c8b34-9a1e-4a51-8f0f-6c4a1f4c21f7" \
  -H "Content-Type: application/json" \
  -d '{"from":"+14155559876","to":"+14155551234","record":true}'

Reusing the key returns the original call rather than placing another:

SituationResponse
First use of the key201 with the new call
Same key, same request200 with the original call — nothing was dialled
Same key, different request422 — the key is bound to its first request
Same key, first attempt still running409 — retry once it settles

The 200 is how you tell a replay from a fresh call. Treat 409 as "wait and retry with the same key"; sending a new key at that point is what causes the second dial you were trying to avoid.

Keys are scoped to your team and expire after 24 hours, so the same value can be reused for a genuinely new call after that. Two requests count as the same when to, from, record and metadata match — metadata key order does not matter.

If a call cannot be confirmed — a network timeout, or a 5xx — the key stays bound rather than being released. That is deliberate: we cannot tell whether the call was placed, and the safe assumption is that it was.

Pricing

CallPrice
Outbound$0.01 per minute
Inbound$0.0085 per minute

You pay for answered time only, rounded up to the whole minute, deducted from your credits when the call ends. Calls that never connect (busy, no answer, failed) are free. Recording is included. People in a conference also pay a conference fee on top of their call.

Direction and status values

Call objects use state; CALL.STATUS webhook payloads use status. Both fields share the same lifecycle values.

Direction values:

ValueMeaning
INBOUNDThe call originated from an external caller and was received by one of your Pinnacle voice-enabled phone numbers.
OUTBOUNDThe call was created from Pinnacle and dialed out from one of your voice-enabled phone numbers.

Status values:

ValueMeaning
INITIATEDPinnacle accepted the call request and is setting up the call with the voice provider.
RINGINGThe call is ringing and has not been answered yet.
ANSWEREDThe call has been answered and is active.
BRIDGEDThe call is connected to another call leg, such as after a transfer or bridge command.
ENDEDThe call ended normally.
FAILEDThe call could not be established or could not continue because of a provider or system failure.
NO_ANSWERThe call rang until timeout without being answered.
BUSYThe destination was busy.
CANCELEDThe call was canceled before normal completion.

Commands and audio frames

Voice WebSockets are bidirectional. Your app sends command frames to control the call and optional media frames when you generate live outbound audio. Pinnacle sends ack, event, and media frames back.

Command frame

Every command has the same envelope:

JSON
{
  "event": "command",
  "command_id": "cmd_welcome",
  "action": "audio.play",
  "params": {
    "text": "Thanks for calling. How can I help?",
    "voice": "female",
    "language": "en-US"
  }
}
FieldMeaning
eventAlways command for commands sent by your app.
command_idYour unique ID for matching the later ack; generate a new ID for each command.
actionThe command to run. See the catalog below.
paramsCommand-specific options. Omit it for commands with no options.

Pinnacle acknowledges each command with the same command_id:

JSON
{
  "event": "ack",
  "command_id": "cmd_welcome",
  "action": "audio.play",
  "status": "ok",
  "sequence_number": 12
}

Command catalog

See the Voice Command Reference for all 19 commands, required and optional fields, and example payloads.

Common command examples

Answer and start the conversation:

JSON
{
  "event": "command",
  "command_id": "cmd_answer",
  "action": "call.answer",
  "params": {
    "as": "Support"
  }
}

Play text-to-speech:

JSON
{
  "event": "command",
  "command_id": "cmd_play_tts",
  "action": "audio.play",
  "params": {
    "text": "Thanks for calling. Please hold while I look that up.",
    "voice": "female",
    "language": "en-US"
  }
}

Play a public audio URL. Replace the placeholder URL with your publicly accessible audio file:

JSON
{
  "event": "command",
  "command_id": "cmd_play_url",
  "action": "audio.play",
  "params": {
    "url": "https://example.com/hold.wav",
    "loop": 1,
    "overlay": true
  }
}

Collect keypad input:

JSON
{
  "event": "command",
  "command_id": "cmd_input_digits",
  "action": "input.get",
  "params": {
    "prompt": {
      "text": "Enter your four digit PIN, then press pound."
    },
    "minDigits": 4,
    "maxDigits": 4,
    "terminatingDigit": "#",
    "timeoutMs": 8000
  }
}

Collect structured speech:

JSON
{
  "event": "command",
  "command_id": "cmd_input_ai",
  "action": "input.get",
  "params": {
    "prompt": {
      "text": "Briefly describe what you need help with."
    },
    "ai": {
      "extract": {
        "type": "object",
        "properties": {
          "intent": {
            "type": "string"
          }
        },
        "required": ["intent"]
      },
      "instructions": "Classify the caller's support intent."
    }
  }
}

Update call metadata:

JSON
{
  "event": "command",
  "command_id": "cmd_state",
  "action": "call.update_state",
  "params": {
    "metadata": {
      "ticket_id": "tkt_123",
      "handoff": "billing"
    }
  }
}

Audio frames

Use command helpers for most audio playback. Send raw media frames only when your app generates live audio itself.

Outbound media from your app to the call:

JSON
{
  "event": "media",
  "media": {
    "track": "outbound",
    "payload": "base64-mulaw-audio",
    "chunk": 1,
    "timestamp": "2026-06-24T00:00:00.000Z"
  }
}

Inbound media from Pinnacle to your app:

JSON
{
  "event": "media",
  "stream_sid": "stream_123",
  "sequence_number": 42,
  "media": {
    "track": "inbound",
    "payload": "base64-mulaw-audio",
    "chunk": 7,
    "timestamp": "2026-06-24T00:00:01.400Z"
  }
}

The stream uses 8 kHz, 8-bit mu-law audio. payload is base64-encoded audio bytes. sequence_number is monotonic for server frames and should be used for ordering.

Outbound audio is queued and played at real-time speed, so you can send it faster than real time. To interrupt it, for example when the caller starts talking, send the audio.clear command: it stops what's playing and drops what's still queued.

Server events

Pinnacle sends lifecycle and command-result events as event frames:

JSON
{
  "event": "event",
  "type": "call.answered",
  "stream_sid": "stream_123",
  "sequence_number": 8,
  "payload": {
    "call_id": "call_123"
  }
}

Listen for ack when you care whether a command was accepted. Listen for event for call lifecycle and input results. Listen for media for inbound audio.

Webhooks and recordings

Attach a webhook to a phone number with event: "CALL.STATUS" to receive call lifecycle updates. Recording download URLs are available from GET /calls/{id}/recording after the call is terminal and the recording has finished processing.

Reading recording status

record and recording_state answer different questions, and you need both to tell a problem from a non-event:

recordrecording_stateMeaning
falsenullNo recording was asked for.
truenullAsked for, none yet. While the call is live this is normal; once the call is terminal it means none was produced.
truePENDINGAudio uploaded, still being assembled. GET .../recording answers 425 until it is ready.
trueREADYDownloadable.
trueFAILEDUpload exhausted its retries. The audio is not recoverable.
anyDELETEDRemoved on request or by retention. Deliberate, not lost.

Download URLs are short-lived signed credentials. Fetch one when you need it rather than storing it, and treat it as a secret: anyone holding it can fetch the audio until it expires.

Recording is off unless you ask for it, per call. What we do not do is anything about consent — that stays with you:

  • Obtaining consent. Some jurisdictions require every participant to consent, others only one. We do not detect jurisdiction or verify consent.
  • Announcing the recording. No notice or beep is played. If one is required, play it yourself.
  • Honouring withdrawal mid-call. recording.stop is available, but nothing triggers it automatically.

Recordings are retained for 90 days, after which they are deleted along with their stored audio and recording_state becomes DELETED. Deletion runs on a daily sweep, so treat the deadline as 90 days plus up to a day rather than exactly 90. You can delete a recording sooner with DELETE /calls/{id}/recording.

Voice is not currently supported for HIPAA or other PHI traffic. That needs a separate agreement and data-flow review — talk to us before sending it.

Pinnacle referenceAsk Pinnacle

Get a sourced answer from the published documentation.

ViewingPinnacle documentation

Conversations are saved for analysis.

Try asking