Repository navigation
Releases
v6.0.2
ClickSend Python SDK v6.0.2
This is the current release of clicksend (import name clicksend), ClickSend's Python client generated fresh from the official OpenAPI v3 specification. It replaces the legacy clicksend-client SDK (import name clicksend_client) — same REST API, but a different import name, method-naming convention, request/response shape, and exception module throughout. Unlike the Go/PHP v2 SDKs, the import name itself changes (clicksend_client → clicksend), so a straight pip install/import swap will fail loudly at import time rather than silently compiling — the danger here isn't a masked import, it's that method names, request shapes, and error handling all changed underneath a similar-sounding package. Endpoint coverage is mostly carried over (26 classes, consolidated from the legacy SDK's 37), with a few products dropped and a few new resources added.
⚠️ This is not a drop-in replacement for the legacy SDK. Read the Migration Guide before upgrading — in particular §5 (method naming), §6 (request payloads), §8 (error handling), and §12 (the Voice naming trap).
Installation
The package name to publish under is unresolved (see below), so for now install straight from GitHub, as the README documents:
# Uninstall the legacy package
pip uninstall clicksend-client
# Install the current package
pip install git+https://github.com/ClickSend/clicksend-python-v2.gitimport clicksend
from clicksend.rest import ApiExceptionpyproject.toml declares the distribution name clicksend, but setup.py's internal NAME is clicksend-python, and the two disagree. Checking PyPI directly: clicksend is already registered — to an unrelated package (ClickSend v3.0 by a different author, nothing to do with this SDK) — so it cannot be published there under that name as-is. clicksend-python is unregistered and available. The legacy SDK's real PyPI name is clicksend-client (currently at 5.0.91), confirmed live on PyPI. Don't add clicksend to requirements.txt expecting to get this SDK — confirm whatever name eventually ships before pinning it.
Also bump to Python 3.10+: pyproject.toml's requires-python says >=3.9, but setup.py's PYTHON_REQUIRES and the README both say 3.10, and the SDK is only tested against 3.10+.
What's changed
-
Method names changed from
resource_path+ HTTP verb to each endpoint'soperationId(snake_cased) — there's no mechanical find/replace:# legacy sms_api.sms_send_post(collection) # v2 sms_api.send_sms(send_sms_request=request)
-
One dedicated
*Requestmodel per operation, replacing shared domain models (SmsMessage,SmsMessageCollection,Email,Voice,Contact, …, all gone) — themodels/folder went from 47 files to 383. A plaindictworks too since every request/response model is nowpydanticv2, which coerces and validates it:# v2 from clicksend import SendSmsRequest request = SendSmsRequest(messages=[{"to": "+61411111111", "body": "Hello!", "source": "sdk"}]) sms_api.send_sms(send_sms_request=request)
Every method also gained a leading, effectively-always-optional
content_typeparameter — always pass the payload by keyword (send_sms_request=...). A ported-verbatim positional call (sms_api.send_sms(collection)) silently landscollectionincontent_typeinstead and sends an empty body. -
Responses are typed
pydanticmodels, not raw strings. Legacy responses were alwaysstr, requiring manualjson.loads; v2 deserializes into a specific per-operation model (SendSms,ViewSmsHistory, …):response = sms_api.send_sms(send_sms_request=request) print(response.data) # typed attribute access print(response.to_dict()) # or a dict
Need status code/headers too? Use the
*_with_http_infovariant (returns anApiResponsewith.data/.status_code/.headers);*_without_preload_contentreturns the rawurllib3response for streaming. -
Error handling: import path moved, and v2 adds status-specific subclasses.
clicksend_client.rest.ApiException→clicksend.rest.ApiException, now based onclicksend.exceptions.OpenApiException, with new subclassesBadRequestException(400),UnauthorizedException(401),ForbiddenException(403),NotFoundException(404),ConflictException(409),UnprocessableEntityException(422),ServiceException(5xx).ApiExceptionalso gained.data(a deserialized error model, when parseable) alongside the existing.status/.reason/.body/.headers. Client-side validation failures now raisepydantic.ValidationError(orApiTypeError/ApiValueError) before the HTTP call even happens. -
26 classes instead of 37, named after resource/capability. Five email-related classes (
EmailMarketingApi,TransactionalEmailApi,MasterEmailTemplatesApi,UserEmailTemplatesApi,EmailDeliveryReceiptRulesApi) collapsed into oneEmailApi;AccountApisplit intoManagementApiandVerificationApi. -
⚠️ The Voice naming trap: legacyVoiceApi(send/history/price/languages/cancel/receipts) is renamed toVoiceMessagingApi, while the newVoiceApiis actually the oldVoiceDeliveryReceiptRulesApiunder the same name.clicksend.VoiceApi(api_client).send_voice_message(...)raisesAttributeError— useVoiceMessagingApi. -
async_reqthreading removed. The legacysms_api.sms_send_post(collection, async_req=True)→thread.get()pattern (backed bymultiprocessing.pool.ThreadPool) has no v2 equivalent — calls are synchronous only. In exchange, every method gained per-call keyword controls:_headers,_request_timeout,_request_auth,_host_index. Client-wide retries move toConfiguration(retries=urllib3.util.Retry(...)). -
ApiClientis now a context manager andConfiguration()takes constructor kwargs instead of post-construction attribute assignment:# v2 configuration = clicksend.Configuration(username=..., password=...) with clicksend.ApiClient(configuration) as api_client: sms_api = clicksend.SmsApi(api_client)
-
The sender field renamed internally: legacy exposed it as
_from(JSONfrom); v2's model attribute isvar_fromwithalias="from"— build it as{"from": "sdk"}in a dict orvar_from="sdk"via the constructor. -
sourcenow defaults to"sdk-python"on SMS, MMS, and voice message items if never set explicitly. Legacy had no such default. -
Default host changed from
https://rest.clicksend.com/v3tohttps://rest.clicksend.com, with/v3moved into each method's own path. The resolved URL is identical; only matters if you overrideconfiguration.host— drop the trailing/v3there. -
Ships an MIT
LICENSEfile (added in the v6.0.2 commit) and the migration guide insidedocs/MIGRATION.md(added in a follow-up v6.0.2 commit). -
Default
User-Agentbumped fromClickSend-SDK/6.0.1/pythontoClickSend-SDK/6.0.2/python(confirmed inclicksend/api_client.py), settable viaapi_client.user_agent = "...".
Not changed
- Same underlying ClickSend v3 REST API — no functional endpoint behavior changes, just a regenerated client.
- Authentication: HTTP Basic (username + API key) via
Configuration— same three building blocks (Configuration,ApiClient, an*Apiclass), just wired up differently (see above). - Basic exception shape: both SDKs raise on non-2xx with
.status,.reason,.body,.headersavailable. configuration.auth_settings()still exists, though its Basic-auth key changed from'BasicAuth'to'basicAuth'(lowercase b) — only matters if you read that dict directly.
Breaking changes
- Import name changed:
clicksend_client→clicksend, includingclicksend_client.rest.ApiException→clicksend.rest.ApiException. - Every method call needs updating: no mechanical rename rule from
resource_path+ verb tooperationId— full mapping in the migration guide §10–§11. - Request bodies rebuilt with per-operation
*Requestmodels (or plain dicts), passed as a keyword argument — a ported positional call silently sends an empty body instead of erroring. - Response handling rewritten: delete manual
json.loads/dict-digging, use direct attribute access on the returnedpydanticmodel. except clicksend_client.rest.ApiExceptionno longer catches anything — fix the import; optionally catch the new status-specific subclasses.async_req=Trueremoved entirely — no thread-pool concurrency; use your ownThreadPoolExecutorwith oneApiClientper worker.- Fax, Letters, Postcards, and address detection are not part of v2 — no class, no models. A few individual methods were also dropped even where their class survived (e.g.
MMSApi.mms_receipts_get,AccountApi.account_post) — full list in the migration guide §13. - Pagination parameters dropped from several surviving methods:
ListsApi.view_lists,ListsApi.view_list_contacts, andSubaccountsApi.view_subaccountsno longer takepage/limit/updated_after. ListsApi.create_new_contact'slist_idmoved from second positional argument to first, and changed type frominttostr.configuration.hostoverrides ending in/v3must drop that suffix.- Drops Python 2 support (no more
six) and the bundledcertifi.
Requirements
- Python 3.10+ (per
setup.py/README;pyproject.toml'srequires-pythonstill says>=3.9— treat 3.10 as the real floor) urllib3>=2.1,<3python-dateutil>=2.8.2pydantic>=2.11typing-extensions>=4.7.1
Migration
Full guide: [docs/MIGRATION.md](https://github.com/Cli...