Plivo

4.59.6 · active · verified Fri Mar 27

Python SDK for Plivo communications API — SMS, voice calls, WhatsApp, and Plivo XML generation. Current version is 4.59.6. Legacy version 0.11.3 has a completely different API (plivo.RestAPI vs plivo.RestClient). pip install --upgrade plivo may NOT cleanly upgrade from legacy — manual uninstall required.

Warnings

Install

Imports

Quickstart

Send SMS, make a call, generate Plivo XML. Store credentials in env vars.

import plivo
import os

# Use env vars: PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN
client = plivo.RestClient()

# Send SMS
sms = client.messages.create(
    src='+12025551234',   # Your Plivo number in E.164 format
    dst='+14155551234',   # Destination in E.164 format
    text='Hello from Plivo!'
)
print('SMS sent:', sms)

# Make a call
call = client.calls.create(
    from_='+12025551234',
    to_='+14155551234',
    answer_url='https://yourapp.com/answer_url'  # Returns Plivo XML
)
print('Call made:', call)

# Generate Plivo XML (for answer_url endpoint)
from plivo import plivoxml
xml = plivoxml.ResponseElement()
xml.add(plivoxml.SpeakElement('Hello! This call is powered by Plivo.'))
print(xml.to_string())

view raw JSON →