Skip to content
Get Started

FaceTime API

Initiate FaceTime calls programmatically via WebRTC

Initiate FaceTime calls programmatically and connect to the audio stream via WebRTC using Agora’s SDK.

POST https://api.sendblue.co/facetime/start-call
ParameterTypeRequiredDescription
phoneNumberstringYesThe phone number to call (E.164 format)
fromNumberstringYesYour Sendblue FaceTime number (E.164 format)
Terminal window
curl -X POST 'https://api.sendblue.co/facetime/start-call' \
-H 'sb-api-key-id: YOUR_API_KEY' \
-H 'sb-api-secret-key: YOUR_API_SECRET' \
-H 'Content-Type: application/json' \
-d '{
"phoneNumber": "+14155550123",
"fromNumber": "+18885550199"
}'
{
"status": "OK",
"message": "Call started",
"agora": {
"appId": "a1b2c3d4e5f6789012345678abcdef90",
"channelName": "ft_call_9f8e7d6c5b4a3210",
"token": "007eJxTYDhw4MCBAwcOHDhw4MCB...",
"uid": 0
}
}
FieldTypeDescription
statusstringRequest status (OK on success)
messagestringHuman-readable status message
agora.appIdstringAgora application ID for joining the channel
agora.channelNamestringUnique channel name for this call
agora.tokenstringAuthentication token for joining the channel
agora.uidnumberUser ID to use when joining (use 0 for auto-assign)

Once you receive the Agora credentials, use the Agora Voice SDK to join the channel and stream audio to/from the FaceTime call.

import AgoraRTC from "agora-rtc-sdk-ng";
const client = AgoraRTC.createClient({ mode: "rtc", codec: "vp8" });
// Join using credentials from the API response
await client.join(
response.agora.appId,
response.agora.channelName,
response.agora.token,
response.agora.uid
);
// Create and publish your microphone track
const microphoneTrack = await AgoraRTC.createMicrophoneAudioTrack();
await client.publish([microphoneTrack]);
// Listen for remote audio (the FaceTime call audio)
client.on("user-published", async (user, mediaType) => {
await client.subscribe(user, mediaType);
if (mediaType === "audio") {
user.audioTrack.play();
}
});

  • Phone numbers must be in E.164 format (e.g., +1 followed by the 10-digit number for US numbers)
  • The fromNumber must be a FaceTime-enabled Sendblue number on your account
  • Agora tokens are time-limited; initiate your call promptly after receiving credentials