callstorm 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. callstorm-0.1.0/LICENSE +21 -0
  2. callstorm-0.1.0/PKG-INFO +234 -0
  3. callstorm-0.1.0/README.md +203 -0
  4. callstorm-0.1.0/pyproject.toml +48 -0
  5. callstorm-0.1.0/setup.cfg +4 -0
  6. callstorm-0.1.0/src/callstorm/__init__.py +29 -0
  7. callstorm-0.1.0/src/callstorm/client.py +244 -0
  8. callstorm-0.1.0/src/callstorm/errors.py +123 -0
  9. callstorm-0.1.0/src/callstorm/pagination.py +51 -0
  10. callstorm-0.1.0/src/callstorm/py.typed +0 -0
  11. callstorm-0.1.0/src/callstorm/resources/__init__.py +18 -0
  12. callstorm-0.1.0/src/callstorm/resources/account.py +48 -0
  13. callstorm-0.1.0/src/callstorm/resources/agents.py +44 -0
  14. callstorm-0.1.0/src/callstorm/resources/api_keys.py +22 -0
  15. callstorm-0.1.0/src/callstorm/resources/calls.py +40 -0
  16. callstorm-0.1.0/src/callstorm/resources/campaigns.py +72 -0
  17. callstorm-0.1.0/src/callstorm/resources/credits.py +32 -0
  18. callstorm-0.1.0/src/callstorm/resources/dnc.py +21 -0
  19. callstorm-0.1.0/src/callstorm/resources/exports.py +34 -0
  20. callstorm-0.1.0/src/callstorm/resources/files.py +40 -0
  21. callstorm-0.1.0/src/callstorm/resources/lead_lists.py +57 -0
  22. callstorm-0.1.0/src/callstorm/resources/templates.py +28 -0
  23. callstorm-0.1.0/src/callstorm/resources/webhooks.py +18 -0
  24. callstorm-0.1.0/src/callstorm/types.py +213 -0
  25. callstorm-0.1.0/src/callstorm/webhooks.py +111 -0
  26. callstorm-0.1.0/src/callstorm.egg-info/PKG-INFO +234 -0
  27. callstorm-0.1.0/src/callstorm.egg-info/SOURCES.txt +31 -0
  28. callstorm-0.1.0/src/callstorm.egg-info/dependency_links.txt +1 -0
  29. callstorm-0.1.0/src/callstorm.egg-info/requires.txt +3 -0
  30. callstorm-0.1.0/src/callstorm.egg-info/top_level.txt +1 -0
  31. callstorm-0.1.0/tests/test_client.py +131 -0
  32. callstorm-0.1.0/tests/test_resources.py +137 -0
  33. callstorm-0.1.0/tests/test_webhooks.py +44 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 I&D Tecnology SpA (Callstorm)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,234 @@
1
+ Metadata-Version: 2.4
2
+ Name: callstorm
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the Callstorm API: outbound voice campaigns (audio, voicebot, AI agent, human agents), leads, calls, exports and webhooks.
5
+ Author-email: I&D Tecnology SpA <support@callstorm.ai>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://callstorm.ai/developers
8
+ Project-URL: Documentation, https://github.com/dvalenci/voxcore/tree/main/sdk/python#readme
9
+ Project-URL: Repository, https://github.com/dvalenci/voxcore
10
+ Project-URL: Changelog, https://github.com/dvalenci/voxcore/blob/main/sdk/python/CHANGELOG.md
11
+ Keywords: callstorm,voxcore,voice,calls,campaigns,voicebot,sdk,api
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Communications :: Telephony
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=8; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ # Callstorm SDK para Python
33
+
34
+ SDK oficial de la [API de Callstorm](https://callstorm.ai/developers): campañas de voz salientes con audio, voicebot,
35
+ agente conversacional con IA y agentes humanos; listas de leads, llamadas, exportaciones y webhooks.
36
+
37
+ - Sin dependencias: solo la biblioteca estándar, Python 3.9 o superior.
38
+ - Reintentos seguros, paginación con `for`, errores tipados y verificación de webhooks.
39
+ - Tipado (`py.typed`) con `TypedDict` para los objetos principales.
40
+
41
+ ## Instalación
42
+
43
+ ```bash
44
+ pip install callstorm
45
+ ```
46
+
47
+ ## Inicio rápido
48
+
49
+ ```python
50
+ from callstorm import Callstorm
51
+
52
+ client = Callstorm(api_key="vx_live_…") # o vx_test_… contra el sandbox
53
+
54
+ me = client.me()
55
+ print(me["account"]["companyName"], me["account"]["balanceMicros"] / 1_000_000, "US$")
56
+
57
+ # Sube una lista de leads y espera a que esté validada.
58
+ with open("leads.csv", "rb") as f:
59
+ lead_list = client.lead_lists.create_from_file(
60
+ "Vencimientos octubre", f.read(), "leads.csv",
61
+ column_mapping={"telefono": "phone", "nombre": "nombre_cliente"}, country="CL",
62
+ )
63
+ client.lead_lists.wait_until_ready(lead_list["leadListId"])
64
+
65
+ # Crea un borrador a partir de una plantilla y lánzalo.
66
+ campaign = client.campaigns.create({"general": {...}, "templateId": "tpl_…", "leadListId": lead_list["leadListId"]})
67
+ client.campaigns.launch(campaign["campaignId"], idempotency_key=f"launch-{campaign['campaignId']}")
68
+
69
+ # Recorre los resultados.
70
+ for call in client.calls.list(campaign_id=campaign["campaignId"]):
71
+ print(call["phone"], call.get("disposition"), call.get("resultCode"))
72
+ ```
73
+
74
+ El ejemplo completo está en [`examples/run_campaign.py`](examples/run_campaign.py).
75
+
76
+ ## Autenticación y entornos
77
+
78
+ La clave se crea en Configuración › Integraciones y viaja en la cabecera `X-Api-Key` (o `Authorization: Bearer` con
79
+ `use_bearer=True`). Cada clave tiene *scopes*; una operación sin el scope necesario lanza `ForbiddenError`.
80
+
81
+ | Entorno | `base_url` |
82
+ | --- | --- |
83
+ | Producción (por defecto) | `https://api.callstorm.ai/v1/ext` |
84
+ | Sandbox | `https://api-dev.callstorm.ai/v1/ext` |
85
+
86
+ ```python
87
+ client = Callstorm(api_key, base_url="https://api-dev.callstorm.ai/v1/ext", timeout=15, max_retries=3)
88
+ ```
89
+
90
+ ## Recursos
91
+
92
+ | Recurso | Métodos |
93
+ | --- | --- |
94
+ | `client.campaigns` | `list`, `create`, `get`, `update`, `delete`, `patch` (ajuste en vivo), `set_lead_lists`, `estimate`, `launch`, `pause`, `resume`, `stop`, `archive`, `duplicate` |
95
+ | `client.templates` | `list`, `create`, `get`, `update`, `delete`, `duplicate` |
96
+ | `client.lead_lists` | `list`, `create`, `get`, `delete`, `leads`, `create_from_file`, `wait_until_ready` |
97
+ | `client.files` | `presign`, `upload`, `upload_path`, `content_type_for` |
98
+ | `client.dnc` | `list`, `add`, `remove` |
99
+ | `client.calls` | `list`, `summary`, `get` (transcripción y URLs de grabación) |
100
+ | `client.exports` | `list`, `create`, `get`, `wait_until_done` |
101
+ | `client.account` | `cells`, `trunks`, `create_trunk`, `trunk`, `update_trunk`, `delete_trunk`, `test_trunk`, `caller_ids`, `create_caller_id`, `update_caller_id`, `delete_caller_id` |
102
+ | `client.agents` | `list`, `get`, `create`, `update`, `delete`, `set_status`, `sip_credentials`, `session_token` |
103
+ | `client.credits` | `ledger`, `payments`, `packages`, `pricing`, `checkout_options`, `checkout` |
104
+ | `client.webhooks` | `list`, `create`, `delete` |
105
+ | `client.api_keys` | `list`, `create`, `delete` (crear y revocar requieren sesión de usuario) |
106
+ | `client` | `me`, `dashboard`, `get`, `post`, `put`, `patch`, `delete`, `request` |
107
+
108
+ Los objetos se devuelven como `dict` con las claves de la API (`campaignId`, `resultCode`…). Los importes van en
109
+ micro-dólares (`1 US$ = 1 000 000`) salvo los campos terminados en `Usd`. El parámetro `from` de los filtros se llama
110
+ `from_` en Python.
111
+
112
+ ## Paginación
113
+
114
+ Las listas grandes devuelven páginas con `nextCursor`. El `Paginator` las recorre por ti:
115
+
116
+ ```python
117
+ for call in client.calls.list(campaign_id=campaign_id, limit=200): ...
118
+ first = client.calls.list(campaign_id=campaign_id).first_page() # {"items", "nextCursor"?, "total"?}
119
+ top = client.campaigns.list(status="RUNNING").all(50)
120
+ for page in client.dnc.list().pages(): print(len(page["items"]))
121
+ ```
122
+
123
+ Una página puede venir corta o vacía con `nextCursor` presente: el paginador sigue hasta que la API deja de devolver
124
+ cursor.
125
+
126
+ ## Idempotencia y reintentos
127
+
128
+ Toda escritura acepta `idempotency_key` (letras, dígitos, `_ . : -`, hasta 128 caracteres). La API guarda la primera
129
+ respuesta 24 horas y la repite ante el mismo valor; `client.last_replayed` indica cuándo pasó.
130
+
131
+ ```python
132
+ client.campaigns.launch(campaign_id, idempotency_key=f"launch-{campaign_id}")
133
+ ```
134
+
135
+ El SDK reintenta solo:
136
+
137
+ - 429: espera hasta que se abra la ventana (`details.resetAt`, máximo 60 s) y vuelve a intentar.
138
+ - 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
139
+ `idempotency_key`; una escritura sin clave no se repite nunca.
140
+
141
+ `max_retries` (2 por defecto) limita el total. `client.rate_limit` guarda la última ventana vista (`limit`,
142
+ `remaining`, `reset_at`).
143
+
144
+ ## Errores
145
+
146
+ Todas las excepciones extienden `CallstormError` y exponen `status`, `code`, `details` y `replayed`.
147
+
148
+ | Clase | HTTP | Cuándo |
149
+ | --- | --- | --- |
150
+ | `ValidationError` | 400 | cuerpo o filtros inválidos; `issues` lista cada campo |
151
+ | `AuthenticationError` | 401 | clave ausente, inválida, revocada o vencida |
152
+ | `InsufficientCreditsError` | 402 | el saldo no cubre la operación |
153
+ | `ForbiddenError` | 403 | falta el scope o la cuenta está suspendida |
154
+ | `NotFoundError` | 404 | el recurso no existe |
155
+ | `ConflictError` | 409 | estado incompatible (`INVALID_TRANSITION`, `NOT_DRAFT`, `IN_USE`…) |
156
+ | `PreconditionError` | 412 | falta configurar algo (`CARRIER_NOT_CONFIGURED`) |
157
+ | `PayloadTooLargeError` | 413 | archivo demasiado grande |
158
+ | `RateLimitError` | 429 | límite por minuto; `reset_at`, `retry_after_seconds` |
159
+ | `ServerError` | 5xx | fallo de la API o de un proveedor |
160
+ | `NetworkError` | — | sin respuesta: DNS, TLS, timeout |
161
+ | `WaitTimeoutError`, `ProcessingFailedError` | — | de `wait_until_ready` / `wait_until_done` |
162
+ | `WebhookSignatureError` | — | firma de webhook inválida |
163
+
164
+ ```python
165
+ from callstorm import ConflictError, InsufficientCreditsError
166
+
167
+ try:
168
+ client.campaigns.launch(campaign_id)
169
+ except InsufficientCreditsError:
170
+ ... # recargar saldo
171
+ except ConflictError as e:
172
+ if e.code == "INVALID_TRANSITION": ... # ya lanzada
173
+ else: raise
174
+ ```
175
+
176
+ ## Subida de archivos
177
+
178
+ `files.upload` pide una URL prefirmada y sube el archivo con el tipo y tamaño exactos que la firma exige. Listas de
179
+ leads: CSV, XLS, XLSX o texto plano hasta 10 MB. Audios: WAV o MP3 hasta 20 MB.
180
+
181
+ ```python
182
+ key = client.files.upload_path("audio", "mensaje.mp3")
183
+ ```
184
+
185
+ ## Webhooks
186
+
187
+ Cada entrega trae `X-Voxcore-Signature: sha256=<HMAC-SHA256 del cuerpo con el secreto>`. Verifica sobre el cuerpo
188
+ crudo, nunca sobre el JSON ya parseado:
189
+
190
+ ```python
191
+ from callstorm import parse_event, WebhookSignatureError
192
+
193
+ # Flask
194
+ @app.post("/hook")
195
+ def hook():
196
+ try:
197
+ event = parse_event(request.get_data(), request.headers, WEBHOOK_SECRET)
198
+ except WebhookSignatureError:
199
+ return "", 401
200
+ if event.is_call_completed:
201
+ call = event.data
202
+ elif event.is_campaign_status_changed: # campaign.started, .paused, .completed o .status_changed
203
+ ...
204
+ return "", 200
205
+ ```
206
+
207
+ Eventos: `call.completed`, `campaign.status_changed` (alias `campaign.started`, `campaign.completed`,
208
+ `campaign.paused`), `lead_list.processed`, `balance.low` (alias `credits.low`) y `payment.succeeded`. Responde 2xx
209
+ en menos de 8 segundos y procesa después. Un receptor sin framework está en
210
+ [`examples/webhook_server.py`](examples/webhook_server.py).
211
+
212
+ ## Consola de agente en tu CRM
213
+
214
+ ```python
215
+ session = client.agents.session_token(agent_id, ttl_sec=8 * 3600)
216
+ # Entrega session["embedUrl"] al navegador y muéstralo en un <iframe allow="microphone">.
217
+ ```
218
+
219
+ ## Versionado
220
+
221
+ Semver. Mientras la versión sea 0.x, los cambios incompatibles pueden llegar en versiones menores y se anuncian en
222
+ [CHANGELOG.md](CHANGELOG.md). Los objetos conservan los campos nuevos que agregue la API.
223
+
224
+ ## Desarrollo
225
+
226
+ ```bash
227
+ cd sdk/python
228
+ python -m venv .venv && . .venv/bin/activate # en Windows: .venv\Scripts\activate
229
+ pip install -e .[dev]
230
+ pytest
231
+ python -m build # dist/ con wheel y sdist
232
+ ```
233
+
234
+ Licencia MIT. Soporte: support@callstorm.ai.
@@ -0,0 +1,203 @@
1
+ # Callstorm SDK para Python
2
+
3
+ SDK oficial de la [API de Callstorm](https://callstorm.ai/developers): campañas de voz salientes con audio, voicebot,
4
+ agente conversacional con IA y agentes humanos; listas de leads, llamadas, exportaciones y webhooks.
5
+
6
+ - Sin dependencias: solo la biblioteca estándar, Python 3.9 o superior.
7
+ - Reintentos seguros, paginación con `for`, errores tipados y verificación de webhooks.
8
+ - Tipado (`py.typed`) con `TypedDict` para los objetos principales.
9
+
10
+ ## Instalación
11
+
12
+ ```bash
13
+ pip install callstorm
14
+ ```
15
+
16
+ ## Inicio rápido
17
+
18
+ ```python
19
+ from callstorm import Callstorm
20
+
21
+ client = Callstorm(api_key="vx_live_…") # o vx_test_… contra el sandbox
22
+
23
+ me = client.me()
24
+ print(me["account"]["companyName"], me["account"]["balanceMicros"] / 1_000_000, "US$")
25
+
26
+ # Sube una lista de leads y espera a que esté validada.
27
+ with open("leads.csv", "rb") as f:
28
+ lead_list = client.lead_lists.create_from_file(
29
+ "Vencimientos octubre", f.read(), "leads.csv",
30
+ column_mapping={"telefono": "phone", "nombre": "nombre_cliente"}, country="CL",
31
+ )
32
+ client.lead_lists.wait_until_ready(lead_list["leadListId"])
33
+
34
+ # Crea un borrador a partir de una plantilla y lánzalo.
35
+ campaign = client.campaigns.create({"general": {...}, "templateId": "tpl_…", "leadListId": lead_list["leadListId"]})
36
+ client.campaigns.launch(campaign["campaignId"], idempotency_key=f"launch-{campaign['campaignId']}")
37
+
38
+ # Recorre los resultados.
39
+ for call in client.calls.list(campaign_id=campaign["campaignId"]):
40
+ print(call["phone"], call.get("disposition"), call.get("resultCode"))
41
+ ```
42
+
43
+ El ejemplo completo está en [`examples/run_campaign.py`](examples/run_campaign.py).
44
+
45
+ ## Autenticación y entornos
46
+
47
+ La clave se crea en Configuración › Integraciones y viaja en la cabecera `X-Api-Key` (o `Authorization: Bearer` con
48
+ `use_bearer=True`). Cada clave tiene *scopes*; una operación sin el scope necesario lanza `ForbiddenError`.
49
+
50
+ | Entorno | `base_url` |
51
+ | --- | --- |
52
+ | Producción (por defecto) | `https://api.callstorm.ai/v1/ext` |
53
+ | Sandbox | `https://api-dev.callstorm.ai/v1/ext` |
54
+
55
+ ```python
56
+ client = Callstorm(api_key, base_url="https://api-dev.callstorm.ai/v1/ext", timeout=15, max_retries=3)
57
+ ```
58
+
59
+ ## Recursos
60
+
61
+ | Recurso | Métodos |
62
+ | --- | --- |
63
+ | `client.campaigns` | `list`, `create`, `get`, `update`, `delete`, `patch` (ajuste en vivo), `set_lead_lists`, `estimate`, `launch`, `pause`, `resume`, `stop`, `archive`, `duplicate` |
64
+ | `client.templates` | `list`, `create`, `get`, `update`, `delete`, `duplicate` |
65
+ | `client.lead_lists` | `list`, `create`, `get`, `delete`, `leads`, `create_from_file`, `wait_until_ready` |
66
+ | `client.files` | `presign`, `upload`, `upload_path`, `content_type_for` |
67
+ | `client.dnc` | `list`, `add`, `remove` |
68
+ | `client.calls` | `list`, `summary`, `get` (transcripción y URLs de grabación) |
69
+ | `client.exports` | `list`, `create`, `get`, `wait_until_done` |
70
+ | `client.account` | `cells`, `trunks`, `create_trunk`, `trunk`, `update_trunk`, `delete_trunk`, `test_trunk`, `caller_ids`, `create_caller_id`, `update_caller_id`, `delete_caller_id` |
71
+ | `client.agents` | `list`, `get`, `create`, `update`, `delete`, `set_status`, `sip_credentials`, `session_token` |
72
+ | `client.credits` | `ledger`, `payments`, `packages`, `pricing`, `checkout_options`, `checkout` |
73
+ | `client.webhooks` | `list`, `create`, `delete` |
74
+ | `client.api_keys` | `list`, `create`, `delete` (crear y revocar requieren sesión de usuario) |
75
+ | `client` | `me`, `dashboard`, `get`, `post`, `put`, `patch`, `delete`, `request` |
76
+
77
+ Los objetos se devuelven como `dict` con las claves de la API (`campaignId`, `resultCode`…). Los importes van en
78
+ micro-dólares (`1 US$ = 1 000 000`) salvo los campos terminados en `Usd`. El parámetro `from` de los filtros se llama
79
+ `from_` en Python.
80
+
81
+ ## Paginación
82
+
83
+ Las listas grandes devuelven páginas con `nextCursor`. El `Paginator` las recorre por ti:
84
+
85
+ ```python
86
+ for call in client.calls.list(campaign_id=campaign_id, limit=200): ...
87
+ first = client.calls.list(campaign_id=campaign_id).first_page() # {"items", "nextCursor"?, "total"?}
88
+ top = client.campaigns.list(status="RUNNING").all(50)
89
+ for page in client.dnc.list().pages(): print(len(page["items"]))
90
+ ```
91
+
92
+ Una página puede venir corta o vacía con `nextCursor` presente: el paginador sigue hasta que la API deja de devolver
93
+ cursor.
94
+
95
+ ## Idempotencia y reintentos
96
+
97
+ Toda escritura acepta `idempotency_key` (letras, dígitos, `_ . : -`, hasta 128 caracteres). La API guarda la primera
98
+ respuesta 24 horas y la repite ante el mismo valor; `client.last_replayed` indica cuándo pasó.
99
+
100
+ ```python
101
+ client.campaigns.launch(campaign_id, idempotency_key=f"launch-{campaign_id}")
102
+ ```
103
+
104
+ El SDK reintenta solo:
105
+
106
+ - 429: espera hasta que se abra la ventana (`details.resetAt`, máximo 60 s) y vuelve a intentar.
107
+ - 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
108
+ `idempotency_key`; una escritura sin clave no se repite nunca.
109
+
110
+ `max_retries` (2 por defecto) limita el total. `client.rate_limit` guarda la última ventana vista (`limit`,
111
+ `remaining`, `reset_at`).
112
+
113
+ ## Errores
114
+
115
+ Todas las excepciones extienden `CallstormError` y exponen `status`, `code`, `details` y `replayed`.
116
+
117
+ | Clase | HTTP | Cuándo |
118
+ | --- | --- | --- |
119
+ | `ValidationError` | 400 | cuerpo o filtros inválidos; `issues` lista cada campo |
120
+ | `AuthenticationError` | 401 | clave ausente, inválida, revocada o vencida |
121
+ | `InsufficientCreditsError` | 402 | el saldo no cubre la operación |
122
+ | `ForbiddenError` | 403 | falta el scope o la cuenta está suspendida |
123
+ | `NotFoundError` | 404 | el recurso no existe |
124
+ | `ConflictError` | 409 | estado incompatible (`INVALID_TRANSITION`, `NOT_DRAFT`, `IN_USE`…) |
125
+ | `PreconditionError` | 412 | falta configurar algo (`CARRIER_NOT_CONFIGURED`) |
126
+ | `PayloadTooLargeError` | 413 | archivo demasiado grande |
127
+ | `RateLimitError` | 429 | límite por minuto; `reset_at`, `retry_after_seconds` |
128
+ | `ServerError` | 5xx | fallo de la API o de un proveedor |
129
+ | `NetworkError` | — | sin respuesta: DNS, TLS, timeout |
130
+ | `WaitTimeoutError`, `ProcessingFailedError` | — | de `wait_until_ready` / `wait_until_done` |
131
+ | `WebhookSignatureError` | — | firma de webhook inválida |
132
+
133
+ ```python
134
+ from callstorm import ConflictError, InsufficientCreditsError
135
+
136
+ try:
137
+ client.campaigns.launch(campaign_id)
138
+ except InsufficientCreditsError:
139
+ ... # recargar saldo
140
+ except ConflictError as e:
141
+ if e.code == "INVALID_TRANSITION": ... # ya lanzada
142
+ else: raise
143
+ ```
144
+
145
+ ## Subida de archivos
146
+
147
+ `files.upload` pide una URL prefirmada y sube el archivo con el tipo y tamaño exactos que la firma exige. Listas de
148
+ leads: CSV, XLS, XLSX o texto plano hasta 10 MB. Audios: WAV o MP3 hasta 20 MB.
149
+
150
+ ```python
151
+ key = client.files.upload_path("audio", "mensaje.mp3")
152
+ ```
153
+
154
+ ## Webhooks
155
+
156
+ Cada entrega trae `X-Voxcore-Signature: sha256=<HMAC-SHA256 del cuerpo con el secreto>`. Verifica sobre el cuerpo
157
+ crudo, nunca sobre el JSON ya parseado:
158
+
159
+ ```python
160
+ from callstorm import parse_event, WebhookSignatureError
161
+
162
+ # Flask
163
+ @app.post("/hook")
164
+ def hook():
165
+ try:
166
+ event = parse_event(request.get_data(), request.headers, WEBHOOK_SECRET)
167
+ except WebhookSignatureError:
168
+ return "", 401
169
+ if event.is_call_completed:
170
+ call = event.data
171
+ elif event.is_campaign_status_changed: # campaign.started, .paused, .completed o .status_changed
172
+ ...
173
+ return "", 200
174
+ ```
175
+
176
+ Eventos: `call.completed`, `campaign.status_changed` (alias `campaign.started`, `campaign.completed`,
177
+ `campaign.paused`), `lead_list.processed`, `balance.low` (alias `credits.low`) y `payment.succeeded`. Responde 2xx
178
+ en menos de 8 segundos y procesa después. Un receptor sin framework está en
179
+ [`examples/webhook_server.py`](examples/webhook_server.py).
180
+
181
+ ## Consola de agente en tu CRM
182
+
183
+ ```python
184
+ session = client.agents.session_token(agent_id, ttl_sec=8 * 3600)
185
+ # Entrega session["embedUrl"] al navegador y muéstralo en un <iframe allow="microphone">.
186
+ ```
187
+
188
+ ## Versionado
189
+
190
+ Semver. Mientras la versión sea 0.x, los cambios incompatibles pueden llegar en versiones menores y se anuncian en
191
+ [CHANGELOG.md](CHANGELOG.md). Los objetos conservan los campos nuevos que agregue la API.
192
+
193
+ ## Desarrollo
194
+
195
+ ```bash
196
+ cd sdk/python
197
+ python -m venv .venv && . .venv/bin/activate # en Windows: .venv\Scripts\activate
198
+ pip install -e .[dev]
199
+ pytest
200
+ python -m build # dist/ con wheel y sdist
201
+ ```
202
+
203
+ Licencia MIT. Soporte: support@callstorm.ai.
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "callstorm"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for the Callstorm API: outbound voice campaigns (audio, voicebot, AI agent, human agents), leads, calls, exports and webhooks."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ authors = [{ name = "I&D Tecnology SpA", email = "support@callstorm.ai" }]
14
+ keywords = ["callstorm", "voxcore", "voice", "calls", "campaigns", "voicebot", "sdk", "api"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.9",
22
+ "Programming Language :: Python :: 3.10",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Topic :: Communications :: Telephony",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
28
+ "Typing :: Typed",
29
+ ]
30
+ dependencies = []
31
+
32
+ [project.urls]
33
+ Homepage = "https://callstorm.ai/developers"
34
+ Documentation = "https://github.com/dvalenci/voxcore/tree/main/sdk/python#readme"
35
+ Repository = "https://github.com/dvalenci/voxcore"
36
+ Changelog = "https://github.com/dvalenci/voxcore/blob/main/sdk/python/CHANGELOG.md"
37
+
38
+ [project.optional-dependencies]
39
+ dev = ["pytest>=8"]
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
43
+
44
+ [tool.setuptools.package-data]
45
+ callstorm = ["py.typed"]
46
+
47
+ [tool.pytest.ini_options]
48
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,29 @@
1
+ """Official Python SDK for the Callstorm API.
2
+
3
+ from callstorm import Callstorm
4
+
5
+ client = Callstorm(api_key="vx_live_…")
6
+ for call in client.calls.list(campaign_id="cmp_…"):
7
+ print(call["phone"], call["disposition"])
8
+ """
9
+ from .client import DEFAULT_BASE_URL, VERSION, Callstorm, RateLimit, Response, Transport, urllib_transport
10
+ from .errors import (
11
+ ApiError, AuthenticationError, CallstormError, ConflictError, ForbiddenError, InsufficientCreditsError, NetworkError, NotFoundError,
12
+ PayloadTooLargeError, PreconditionError, ProcessingFailedError, RateLimitError, ServerError, ValidationError, WaitTimeoutError,
13
+ WebhookSignatureError, error_from_response,
14
+ )
15
+ from .pagination import Page, Paginator
16
+ from .webhooks import (
17
+ DELIVERY_HEADER, EVENT_HEADER, SIGNATURE_HEADER, WEBHOOK_EVENTS, WebhookEvent, is_balance_low, is_campaign_status_changed, parse_event,
18
+ sign_payload, verify_signature,
19
+ )
20
+
21
+ __version__ = VERSION
22
+ __all__ = [
23
+ "Callstorm", "DEFAULT_BASE_URL", "VERSION", "RateLimit", "Response", "Transport", "urllib_transport", "Page", "Paginator",
24
+ "ApiError", "AuthenticationError", "CallstormError", "ConflictError", "ForbiddenError", "InsufficientCreditsError", "NetworkError",
25
+ "NotFoundError", "PayloadTooLargeError", "PreconditionError", "ProcessingFailedError", "RateLimitError", "ServerError", "ValidationError",
26
+ "WaitTimeoutError", "WebhookSignatureError", "error_from_response",
27
+ "DELIVERY_HEADER", "EVENT_HEADER", "SIGNATURE_HEADER", "WEBHOOK_EVENTS", "WebhookEvent", "is_balance_low", "is_campaign_status_changed",
28
+ "parse_event", "sign_payload", "verify_signature",
29
+ ]