Skip to main content

Callstorm SDK para Python

SDK oficial de la API de Callstorm: campañas de voz salientes con audio, voicebot, agente conversacional con IA y agentes humanos; listas de leads, llamadas, exportaciones y webhooks.

  • Sin dependencias: solo la biblioteca estándar, Python 3.9 o superior.
  • Reintentos seguros, paginación con for, errores tipados y verificación de webhooks.
  • Tipado (py.typed) con TypedDict para los objetos principales.

Instalación

pip install callstorm

Inicio rápido

from callstorm import Callstorm

client = Callstorm(api_key="vx_live_…")   # o vx_test_… contra el sandbox

me = client.me()
print(me["account"]["companyName"], me["account"]["balanceMicros"] / 1_000_000, "US$")

# Sube una lista de leads y espera a que esté validada.
with open("leads.csv", "rb") as f:
    lead_list = client.lead_lists.create_from_file(
        "Vencimientos octubre", f.read(), "leads.csv",
        column_mapping={"telefono": "phone", "nombre": "nombre_cliente"}, country="CL",
    )
client.lead_lists.wait_until_ready(lead_list["leadListId"])

# Crea un borrador a partir de una plantilla y lánzalo.
campaign = client.campaigns.create({"general": {...}, "templateId": "tpl_…", "leadListId": lead_list["leadListId"]})
client.campaigns.launch(campaign["campaignId"], idempotency_key=f"launch-{campaign['campaignId']}")

# Recorre los resultados.
for call in client.calls.list(campaign_id=campaign["campaignId"]):
    print(call["phone"], call.get("disposition"), call.get("resultCode"))

El ejemplo completo está en examples/run_campaign.py.

Autenticación y entornos

La clave se crea en Configuración › Integraciones y viaja en la cabecera X-Api-Key (o Authorization: Bearer con use_bearer=True). Cada clave tiene scopes; una operación sin el scope necesario lanza ForbiddenError.

Entorno base_url
Producción (por defecto) https://api.callstorm.ai/v1/ext
Sandbox https://api-dev.callstorm.ai/v1/ext
client = Callstorm(api_key, base_url="https://api-dev.callstorm.ai/v1/ext", timeout=15, max_retries=3)

Recursos

Recurso Métodos
client.campaigns list, create, get, update, delete, patch (ajuste en vivo), set_lead_lists, estimate, launch, pause, resume, stop, archive, duplicate
client.templates list, create, get, update, delete, duplicate
client.lead_lists list, create, get, delete, leads, create_from_file, wait_until_ready
client.files presign, upload, upload_path, content_type_for
client.dnc list, add, remove
client.calls list, summary, get (transcripción y URLs de grabación)
client.exports list, create, get, wait_until_done
client.account cells, trunks, create_trunk, trunk, update_trunk, delete_trunk, test_trunk, caller_ids, create_caller_id, update_caller_id, delete_caller_id
client.agents list, get, create, update, delete, set_status, sip_credentials, session_token
client.credits ledger, payments, packages, pricing, checkout_options, checkout
client.webhooks list, create, delete
client.api_keys list, create, delete (crear y revocar requieren sesión de usuario)
client me, dashboard, get, post, put, patch, delete, request

Los objetos se devuelven como dict con las claves de la API (campaignId, resultCode…). Los importes van en micro-dólares (1 US$ = 1 000 000) salvo los campos terminados en Usd. El parámetro from de los filtros se llama from_ en Python.

Paginación

Las listas grandes devuelven páginas con nextCursor. El Paginator las recorre por ti:

for call in client.calls.list(campaign_id=campaign_id, limit=200): ...
first = client.calls.list(campaign_id=campaign_id).first_page()      # {"items", "nextCursor"?, "total"?}
top = client.campaigns.list(status="RUNNING").all(50)
for page in client.dnc.list().pages(): print(len(page["items"]))

Una página puede venir corta o vacía con nextCursor presente: el paginador sigue hasta que la API deja de devolver cursor.

Idempotencia y reintentos

Toda escritura acepta idempotency_key (letras, dígitos, _ . : -, hasta 128 caracteres). La API guarda la primera respuesta 24 horas y la repite ante el mismo valor; client.last_replayed indica cuándo pasó.

client.campaigns.launch(campaign_id, idempotency_key=f"launch-{campaign_id}")

El SDK reintenta solo:

  • 429: espera hasta que se abra la ventana (details.resetAt, máximo 60 s) y vuelve a intentar.
  • 502, 503, 504 y fallos de red: espera 0,5 s, 1 s, 2 s… (máximo 8 s). Solo en lecturas o en escrituras con idempotency_key; una escritura sin clave no se repite nunca.

max_retries (2 por defecto) limita el total. client.rate_limit guarda la última ventana vista (limit, remaining, reset_at).

Errores

Todas las excepciones extienden CallstormError y exponen status, code, details y replayed.

Clase HTTP Cuándo
ValidationError 400 cuerpo o filtros inválidos; issues lista cada campo
AuthenticationError 401 clave ausente, inválida, revocada o vencida
InsufficientCreditsError 402 el saldo no cubre la operación
ForbiddenError 403 falta el scope o la cuenta está suspendida
NotFoundError 404 el recurso no existe
ConflictError 409 estado incompatible (INVALID_TRANSITION, NOT_DRAFT, IN_USE…)
PreconditionError 412 falta configurar algo (CARRIER_NOT_CONFIGURED)
PayloadTooLargeError 413 archivo demasiado grande
RateLimitError 429 límite por minuto; reset_at, retry_after_seconds
ServerError 5xx fallo de la API o de un proveedor
NetworkError — sin respuesta: DNS, TLS, timeout
WaitTimeoutError, ProcessingFailedError — de wait_until_ready / wait_until_done
WebhookSignatureError — firma de webhook inválida
from callstorm import ConflictError, InsufficientCreditsError

try:
    client.campaigns.launch(campaign_id)
except InsufficientCreditsError:
    ...  # recargar saldo
except ConflictError as e:
    if e.code == "INVALID_TRANSITION": ...  # ya lanzada
    else: raise

Subida de archivos

files.upload pide una URL prefirmada y sube el archivo con el tipo y tamaño exactos que la firma exige. Listas de leads: CSV, XLS, XLSX o texto plano hasta 10 MB. Audios: WAV o MP3 hasta 20 MB.

key = client.files.upload_path("audio", "mensaje.mp3")

Webhooks

Cada entrega trae X-Voxcore-Signature: sha256=<HMAC-SHA256 del cuerpo con el secreto>. Verifica sobre el cuerpo crudo, nunca sobre el JSON ya parseado:

from callstorm import parse_event, WebhookSignatureError

# Flask
@app.post("/hook")
def hook():
    try:
        event = parse_event(request.get_data(), request.headers, WEBHOOK_SECRET)
    except WebhookSignatureError:
        return "", 401
    if event.is_call_completed:
        call = event.data
    elif event.is_campaign_status_changed:   # campaign.started, .paused, .completed o .status_changed
        ...
    return "", 200

Eventos: call.completed, campaign.status_changed (alias campaign.started, campaign.completed, campaign.paused), lead_list.processed, balance.low (alias credits.low) y payment.succeeded. Responde 2xx en menos de 8 segundos y procesa después. Un receptor sin framework está en examples/webhook_server.py.

Consola de agente en tu CRM

session = client.agents.session_token(agent_id, ttl_sec=8 * 3600)
# Entrega session["embedUrl"] al navegador y muéstralo en un <iframe allow="microphone">.

Versionado

Semver. Mientras la versión sea 0.x, los cambios incompatibles pueden llegar en versiones menores y se anuncian en CHANGELOG.md. Los objetos conservan los campos nuevos que agregue la API.

Desarrollo

cd sdk/python
python -m venv .venv && . .venv/bin/activate      # en Windows: .venv\Scripts\activate
pip install -e .[dev]
pytest
python -m build                                   # dist/ con wheel y sdist

Licencia MIT. Soporte: support@callstorm.ai.

Metadata

Release files for callstorm 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for callstorm 0.1.0
File Size Uploaded Provenance Actions
callstorm-0.1.0.tar.gz 30.2 kB With provenance Details for callstorm-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for callstorm 0.1.0
File Interpreter ABI Platform Actions
callstorm-0.1.0-py3-none-any.whl Python 3 none any Details for callstorm-0.1.0-py3-none-any.whl

Total release size: 58.4 kB

Release files / callstorm-0.1.0.tar.gz

Download URL callstorm-0.1.0.tar.gz
Size 30.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2f21320e40ea6d64f7b4192ac8616797126d04b4a3094626bd0eea692b59d59e
BLAKE2b-256 checksum
How to use checksums
f577cef7a719270407cefa261bde5e1a42a1f8367bc7b3330174d4244daa6db9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / callstorm-0.1.0-py3-none-any.whl

Download URL callstorm-0.1.0-py3-none-any.whl
Size 28.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8668af09285668fa40a979e190a567cdb01fb5c0dc3b892db304f6fd140d324d
BLAKE2b-256 checksum
How to use checksums
d128e7f0aa406cb41eea68244359ebb4be41fd5b576bbe8b82db1159ed01962c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Security for callstorm 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for callstorm-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page