How to Use the RetellAI API — Basic Steps for Developers

RetellAI is a powerful platform that enables developers to create automated phone calls and integrate AI-driven voice technology into their applications. With its flexible API, you can easily connect these capabilities to your projects using popular progr

2025-08-11

RetellAI is a powerful platform that enables developers to create automated phone calls and integrate AI-driven voice technology into their applications. With its flexible API, you can easily connect these capabilities to your projects using popular programming languages like Node.js or PHP.

This guide walks you through the basic steps to get started.

Why Use the RetellAI API?

RetellAI provides a range of features that make it a strong choice for integrating AI-powered calling into your projects:

AI-driven automated phone calls.

Simple and well-documented endpoints for call creation and management.

Scalable architecture for growing applications.

Suitable for use cases like customer support, appointment reminders, surveys, and notifications.

Core RetellAI API Endpoints

Some key request types include:

Create Phone Call – Start an automated call with a specified message.

Get Call Status – Check the progress or result of a call.

List Calls – Retrieve a list of calls associated with your account.

Cancel Call – Stop a scheduled or ongoing call.

In this tutorial, we’ll focus on creating a call and retrieving its status. For a full reference, see the documentation:
https://docs.retellai.com/api-references/create-phone-call

Prerequisites

Before you begin, you’ll need:

API Key – Sign up on RetellAI and get your API key from the dashboard.

Node.js or PHP environment – Installed on your system.

HTTP Client Library – e.g., Axios (Node.js) or cURL (PHP).

Note: RetellAI also supports Python, Java, and Go — refer to the documentation for those examples.

Using RetellAI API with Node.js

Step 1 – Install Axios

In your project folder, run:

bash

CopyEdit

npm install axios

Step 2 – Create a Phone Call

Create a file named createCall.js and paste:

javascript

CopyEdit

const axios = require('axios');

const API_KEY = 'Enter_Your_Api_Key_Here';
const BASE_URL = 'https://api.retellai.com/v1';

const createPhoneCall = async () => {
try {
const response = await axios.post(
`${BASE_URL}/phone-calls`,
{
phoneNumber: '+1234567890',
message: 'Hello! This is an automated call using RetellAI.',
},
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
}
);
console.log('Phone call created:', response.data);
} catch (error) {
console.error('Error creating phone call:', error.response?.data || error.message);
}
};

createPhoneCall();

Step 3 – Retrieve Call Status

Create a file named getCallStatus.js and paste:

javascript

CopyEdit

const axios = require('axios');

const API_KEY = 'Enter_Your_Api_Key_Here';
const BASE_URL = 'https://api.retellai.com/v1';

const getCallStatus = async (callId) => {
try {
const response = await axios.get(
`${BASE_URL}/phone-calls/${callId}`,
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
},
}
);
console.log('Call status:', response.data);
} catch (error) {
console.error('Error retrieving call status:', error.response?.data || error.message);
}
};

getCallStatus('Enter_your_call_id_here');

Step 4 – Run the Scripts

bash

CopyEdit

node createCall.js
node getCallStatus.js

Using RetellAI API with PHP

Step 1 – Ensure cURL is Enabled

Verify that the cURL extension is active in your PHP setup.

Step 2 – Create a Phone Call

Create a file named createCall.php and paste:

php

CopyEdit

<?php

$apiKey = 'Enter_Your_API_Key_Here';
$baseUrl = 'https://api.retellai.com/v1';

$data = [
'phoneNumber' => '+1234567890',
'message' => 'Hello! This is an automated call using RetellAI.',
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$baseUrl/phone-calls");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo 'Phone call created: ' . $response;
}

curl_close($ch);

Step 3 – Retrieve Call Status

Create a file named getCallStatus.php and paste:

php

CopyEdit

<?php

$apiKey = 'Enter_Your_API_Key_Here';
$baseUrl = 'https://api.retellai.com/v1';
$callId = 'Enter_your_call_id_here';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$baseUrl/phone-calls/$callId");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);

if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo 'Call status: ' . $response;
}

curl_close($ch);

Step 4 – Run the Scripts

bash

CopyEdit

php createCall.php
php getCallStatus.php

✅ You’ve now integrated RetellAI into your Node.js or PHP project. You can expand from here to schedule calls, track analytics, and connect the API to your CRM, support platform, or notification system.

Share Blog