Voice & Calls
pepe.business Voice lets you make and receive calls via API, with integrated browser softphone.
Prerequisites
- Have purchased a number (
POST /v1/phone-numbers/purchase) - Enable voice on this number:
POST /v1/phone-numbers/{phoneNumberId}/enable-calling
Make a call
POST /v1/voice/calls
{
"from": "+33612345678",
"to": "+33698765432",
"answerUrl": "https://your-app.com/voice/answer"
}
When the call is answered, pepe.business fetches answerUrl which must return TwiML-like instructions:
<Response>
<Say language="fr-FR">Hello, you have reached pepe.business.</Say>
<Connect>
<Stream url="wss://your-app.com/voice/stream" />
</Connect>
</Response>
Browser softphone
Build a phone directly in the browser with the JS SDK:
import { PepeVoice } from "@pepe/voice-sdk";
const voice = new PepeVoice({ token });
const session = await voice.dial("+33698765432");
session.on("connected", () => console.log("Connected"));
session.on("ended", () => console.log("Ended"));
Transfer
POST /v1/voice/calls/{callId}/transfer
{ "to": "+33611111111" }
Hang up
POST /v1/voice/calls/{callId}/hangup
Recording
Recording is billed at $0.004/min:
POST /v1/voice/calls/{callId}/record
When the recording is ready, you receive call.recording.ready with the URL.
Call history
GET /v1/voice/calls?range=30d
{
"calls": [
{
"id": "call_xxx",
"from": "+33612345678",
"to": "+33698765432",
"duration": 142,
"direction": "outbound",
"cost": 1.42,
"currency": "USD",
"recordingUrl": null
}
]
}
Estimated cost
POST /v1/voice/estimate-cost
{ "to": "+33698765432", "duration": 120 }
{ "estimatedCost": 1.20, "currency": "USD" }
Webhooks
call.incoming: incoming call on your numbercall.completed: call endedcall.recording.ready: recording available