Skip to content

Releases

v6.0.2

Choose a tag to compare

@niharaCS niharaCS released this 25 Sep 06:58
c522813

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.git
import clicksend
from clicksend.rest import ApiException

⚠️ Package-name conflict, not just ambiguity. pyproject.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's operationId (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 *Request model per operation, replacing shared domain models (SmsMessage, SmsMessageCollection, Email, Voice, Contact, …, all gone) — the models/ folder went from 47 files to 383. A plain dict works too since every request/response model is now pydantic v2, 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_type parameter — always pass the payload by keyword (send_sms_request=...). A ported-verbatim positional call (sms_api.send_sms(collection)) silently lands collection in content_type instead and sends an empty body.

  • Responses are typed pydantic models, not raw strings. Legacy responses were always str, requiring manual json.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_info variant (returns an ApiResponse with .data/.status_code/.headers); *_without_preload_content returns the raw urllib3 response for streaming.

  • Error handling: import path moved, and v2 adds status-specific subclasses. clicksend_client.rest.ApiException → clicksend.rest.ApiException, now based on clicksend.exceptions.OpenApiException, with new subclasses BadRequestException (400), UnauthorizedException (401), ForbiddenException (403), NotFoundException (404), ConflictException (409), UnprocessableEntityException (422), ServiceException (5xx). ApiException also gained .data (a deserialized error model, when parseable) alongside the existing .status/.reason/.body/.headers. Client-side validation failures now raise pydantic.ValidationError (or ApiTypeError/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 one EmailApi; AccountApi split into ManagementApi and VerificationApi.

  • ⚠️ The Voice naming trap: legacy VoiceApi (send/history/price/languages/cancel/receipts) is renamed to VoiceMessagingApi, while the new VoiceApi is actually the old VoiceDeliveryReceiptRulesApi under the same name. clicksend.VoiceApi(api_client).send_voice_message(...) raises AttributeError — use VoiceMessagingApi.

  • async_req threading removed. The legacy sms_api.sms_send_post(collection, async_req=True) → thread.get() pattern (backed by multiprocessing.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 to Configuration(retries=urllib3.util.Retry(...)).

  • ApiClient is now a context manager and Configuration() 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 (JSON from); v2's model attribute is var_from with alias="from" — build it as {"from": "sdk"} in a dict or var_from="sdk" via the constructor.

  • source now 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/v3 to https://rest.clicksend.com, with /v3 moved into each method's own path. The resolved URL is identical; only matters if you override configuration.host — drop the trailing /v3 there.

  • Ships an MIT LICENSE file (added in the v6.0.2 commit) and the migration guide inside docs/MIGRATION.md (added in a follow-up v6.0.2 commit).

  • Default User-Agent bumped from ClickSend-SDK/6.0.1/python to ClickSend-SDK/6.0.2/python (confirmed in clicksend/api_client.py), settable via api_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 *Api class), just wired up differently (see above).
  • Basic exception shape: both SDKs raise on non-2xx with .status, .reason, .body, .headers available.
  • 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, including clicksend_client.rest.ApiException → clicksend.rest.ApiException.
  • Every method call needs updating: no mechanical rename rule from resource_path + verb to operationId — full mapping in the migration guide §10–§11.
  • Request bodies rebuilt with per-operation *Request models (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 returned pydantic model.
  • except clicksend_client.rest.ApiException no longer catches anything — fix the import; optionally catch the new status-specific subclasses.
  • async_req=True removed entirely — no thread-pool concurrency; use your own ThreadPoolExecutor with one ApiClient per 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, and SubaccountsApi.view_subaccounts no longer take page/limit/updated_after.
  • ListsApi.create_new_contact's list_id moved from second positional argument to first, and changed type from int to str.
  • configuration.host overrides ending in /v3 must drop that suffix.
  • Drops Python 2 support (no more six) and the bundled certifi.

Requirements

  • Python 3.10+ (per setup.py/README; pyproject.toml's requires-python still says >=3.9 — treat 3.10 as the real floor)
  • urllib3>=2.1,<3
  • python-dateutil>=2.8.2
  • pydantic>=2.11
  • typing-extensions>=4.7.1

Migration

Full guide: [docs/MIGRATION.md](https://github.com/Cli...

Read more