Eedesy
Book Demo
HomeProductsContact
Number Masking API
  • Introduction
  • Quick Start
  • Authentication
  • Call Lifecycle
  • Complete Example
  • Overview
  • Create a Session
  • Manage a Session
  • Dynamic Routing Webhook
  • Event Webhooks
  • Enroll Your Own Numbers
  • Overview
  • Initiate a Call
  • Get Call Status
  • Get Call Recording
  • List Call Logs
  • Get Usage Stats
  • Get Wallet Balance
  • Webhooks
  • Error Codes

Related Products

  • AI Voice Agent
  • AI Voice Assistant
  • Try Free
Number Masking API
  • Introduction
  • Quick Start
  • Authentication
  • Call Lifecycle
  • Complete Example
  • Overview
  • Create a Session
  • Manage a Session
  • Dynamic Routing Webhook
  • Event Webhooks
  • Enroll Your Own Numbers
  • Overview
  • Initiate a Call
  • Get Call Status
  • Get Call Recording
  • List Call Logs
  • Get Usage Stats
  • Get Wallet Balance
  • Webhooks
  • Error Codes
  1. Docs
  2. Number Masking API
  3. Getting Started
  4. Complete Example

Complete Example

End-to-end script that initiates a masked call, polls until it ends, and fetches the recording — in Node.js, Python, and PHP.

Complete Example

A runnable script that initiates a call, polls until it ends, then fetches the recording URL. Copy it, replace the API key, and run.

Node.js

// Node.js 18+ — uses built-in fetch
const API_KEY = "vp_YOUR_API_KEY";
const BASE = "https://voice-api.edesy.in/v1";

async function call(path, init = {}) {
  const res = await fetch(BASE + path, {
    ...init,
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      "Content-Type": "application/json",
      ...(init.headers || {}),
    },
  });
  const json = await res.json();
  if (!res.ok) throw new Error(json?.error?.message || res.statusText);
  return json.data;
}

// 1. Dial
const { call_sid } = await call("/masking/calls", {
  method: "POST",
  body: JSON.stringify({ party_a: "9876543210", party_b: "9123456789" }),
});
console.log("Call initiated:", call_sid);

// 2. Poll status every 2 seconds until terminal
const terminal = new Set(["completed", "failed", "no-answer"]);
let status;
while (true) {
  const log = await call(`/masking/calls/${call_sid}`);
  status = log.status;
  console.log("Status:", status);
  if (terminal.has(status)) break;
  await new Promise((r) => setTimeout(r, 2000));
}

// 3. Fetch the recording (if any)
if (status === "completed") {
  try {
    const rec = await call(`/masking/calls/${call_sid}/recording`);
    console.log("Recording URL (valid 1h):", rec.url);
  } catch (e) {
    console.log("No recording:", e.message);
  }
}

Python

# Python 3.7+ — requires "pip install requests"
import time
import requests

API_KEY = "vp_YOUR_API_KEY"
BASE = "https://voice-api.edesy.in/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}

def call(method, path, **kwargs):
    res = requests.request(method, BASE + path, headers=HEADERS, **kwargs)
    body = res.json()
    if not res.ok:
        raise RuntimeError(body.get("error", {}).get("message", res.reason))
    return body["data"]

# 1. Dial
result = call("POST", "/masking/calls", json={"party_a": "9876543210", "party_b": "9123456789"})
call_sid = result["call_sid"]
print("Call initiated:", call_sid)

# 2. Poll status until terminal
TERMINAL = {"completed", "failed", "no-answer"}
while True:
    log = call("GET", f"/masking/calls/{call_sid}")
    status = log["status"]
    print("Status:", status)
    if status in TERMINAL:
        break
    time.sleep(2)

# 3. Fetch the recording
if status == "completed":
    try:
        rec = call("GET", f"/masking/calls/{call_sid}/recording")
        print("Recording URL (valid 1h):", rec["url"])
    except RuntimeError as e:
        print("No recording:", e)

PHP

<?php
// PHP 7.4+ — uses built-in curl extension
$API_KEY = "vp_YOUR_API_KEY";
$BASE    = "https://voice-api.edesy.in/v1";

function call($method, $path, $body = null) {
    global $API_KEY, $BASE;
    $ch = curl_init($BASE . $path);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        "Authorization: Bearer " . $API_KEY,
        "Content-Type: application/json",
    ]);
    if ($body !== null) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
    }
    $resp = curl_exec($ch);
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    $json = json_decode($resp, true);
    if ($code >= 400) {
        throw new Exception($json["error"]["message"] ?? "HTTP $code");
    }
    return $json["data"];
}

// 1. Dial
$result = call("POST", "/masking/calls", [
    "party_a" => "9876543210",
    "party_b" => "9123456789",
]);
$call_sid = $result["call_sid"];
echo "Call initiated: $call_sid\n";

// 2. Poll status until terminal
$terminal = ["completed", "failed", "no-answer"];
while (true) {
    $log = call("GET", "/masking/calls/$call_sid");
    $status = $log["status"];
    echo "Status: $status\n";
    if (in_array($status, $terminal)) break;
    sleep(2);
}

// 3. Fetch the recording
if ($status === "completed") {
    try {
        $rec = call("GET", "/masking/calls/$call_sid/recording");
        echo "Recording URL (valid 1h): " . $rec["url"] . "\n";
    } catch (Exception $e) {
        echo "No recording: " . $e->getMessage() . "\n";
    }
}
Previous
Call Lifecycle
Next
Overview

On this page

  • Node.js
  • Python
  • PHP

Stay Updated

Get the latest updates on AI voice technology, product releases, and exclusive resources.

Get Started

Try our products for free
AI Voice Agent
Build voice AI for calls
WhatsApp AI Bot
Automate WhatsApp chats
Website Chatbot
AI chat for websites
Edesy CRM
Manage leads & customers
Book a DemoCall UsEmail Us
Eedesy

Your all-in-one platform for digital innovation. We build AI-powered solutions that transform how businesses operate.

[email protected]+91 95475 31359

Products

  • AI Voice Assistant
  • Voice AI Suite
  • Telephony Suite
  • Messaging Suite
  • Business Apps Suite
  • WhatsApp Voice AI
  • WhatsApp Bot Builder
  • AI Website Chatbot
  • AI-SDR
  • Number Masking
  • Shopify Apps
  • View All Products

Solutions

  • For E-commerce
  • For Healthcare
  • For Real Estate
  • For Restaurants
  • For Appointments
  • View All Use Cases

Services

  • AI Chatbot Development
  • Voice AI Development
  • Shopify Development
  • SaaS Development
  • WhatsApp API Integration
  • View All Services

Resources

  • Documentation
  • Voice Agent Docs
  • API Reference
  • Number Masking API Docs
  • Blog
  • Changelog
  • Book a Demo

Company

  • About Us
  • Contact
  • Careers
  • Privacy Policy
  • Terms of Service

Products

  • AI Voice Assistant
  • Voice AI Suite
  • Telephony Suite
  • Messaging Suite
  • Business Apps Suite
  • WhatsApp Voice AI
  • WhatsApp Bot Builder
  • AI Website Chatbot
  • AI-SDR
  • Number Masking
  • Shopify Apps
  • View All Products

Solutions

  • For E-commerce
  • For Healthcare
  • For Real Estate
  • For Restaurants
  • For Appointments
  • View All Use Cases

Services

  • AI Chatbot Development
  • Voice AI Development
  • Shopify Development
  • SaaS Development
  • WhatsApp API Integration
  • View All Services

Resources

  • Documentation
  • Voice Agent Docs
  • API Reference
  • Number Masking API Docs
  • Blog
  • Changelog
  • Book a Demo

Company

  • About Us
  • Contact
  • Careers
  • Privacy Policy
  • Terms of Service
  • AI Voice Assistant
  • Voice AI Suite
  • Telephony Suite
  • Messaging Suite
  • Business Apps Suite
  • WhatsApp Voice AI
  • WhatsApp Bot Builder
  • AI Website Chatbot
  • AI-SDR
  • Number Masking
  • Shopify Apps
  • View All Products
  • For E-commerce
  • For Healthcare
  • For Real Estate
  • For Restaurants
  • For Appointments
  • View All Use Cases
  • AI Chatbot Development
  • Voice AI Development
  • Shopify Development
  • SaaS Development
  • WhatsApp API Integration
  • View All Services
  • Documentation
  • Voice Agent Docs
  • API Reference
  • Number Masking API Docs
  • Blog
  • Changelog
  • Book a Demo
  • About Us
  • Contact
  • Careers
  • Privacy Policy
  • Terms of Service

Popular Free Tools

Compress PDFMerge PDFPDF to WordGST CalculatorEMI CalculatorSIP CalculatorJSON FormatterBase64 EncoderImage CompressorQR Code GeneratorVoice AI ROI CalculatorAmazon FBA CalculatorAI Email WriterVideo to GIFPrivacy Policy GeneratorCRM ROI CalculatorMeeting Cost Calculator
Categories:PDF ToolsDeveloper ToolsFinance CalculatorsImage ToolsVideo ToolsAI Writing ToolsAudio ToolsWhatsApp ToolsDocument GeneratorsVoice AI ToolsE-commerce ToolsView All Tools

© 2026 Edesy Technology Labs Pvt Ltd

SSL Secured
99.9% Uptime