Comms SDK Reference
SDK Reference
The CommsSDK functions are the same across all supported SDKs. Only naming style differs by language (e.g., sendSMS in Java/C# vs send_sms in Python/Ruby).
Authentication and Environment
| Function | Parameters | Returns | Notes |
|---|---|---|---|
| authenticate | username, apiKey | SDK instance | Creates and validates an SDK instance. |
| useSandBox / use_sandbox | none | void | Switches to the sandbox API URL. |
| useLiveServer / use_live_server | none | void | Switches to the live API URL. |
| withSenderId / with_sender_id | senderId | SDK instance | Sets a default sender ID for outgoing messages. |
| isAuthenticated / is_authenticated | none | boolean | Returns whether the SDK instance is currently authenticated. |
Send SMS
| Function | Parameters | Returns | Notes |
|---|---|---|---|
| sendSMS / send_sms | number or numbers, message, optional senderId, optional priority | boolean | Sends SMS and returns success or failure. |
| querySendSMS / query_send_sms | number or numbers, message, optional senderId, optional priority | ApiResponse | Sends SMS and returns the full API response. |
Balance
| Function | Parameters | Returns | Notes |
|---|---|---|---|
| getBalance / get_balance | optional walletType | number | Returns the account balance. Defaults to the local wallet. |
| queryBalance / query_balance | optional walletType | ApiResponse | Returns the full API response with balance details. Defaults to the local wallet. |
Model Reference
This section summarizes the SDK response models that map to the API responses.
ApiResponseCode (Enum)
Represents the status of an API call.
- OK – The request was successful.
- Failed – The request failed.
ApiResponse
Responses from sdk.querySendSMS() and sdk.queryBalance() use this structure:
| Field | Type | Description |
|---|---|---|
| status | ApiResponseCode | Status of the request. |
| message | String | Reason for the failure. Only populated when status is Failed. |
| cost | Double | Cost of sending the message (available only on SendSms). Not always a whole number. |
| messageFollowUpCode | String | Unique code for tracking each successful request. |
| balance | Double | User account balance (available only when fetching balance). |
MessagePriority (Enum)
Sets SMS sending priority. Lower value = higher priority.
| Name | Value | Description |
|---|---|---|
| HIGHEST | 0 | Urgent |
| HIGH | 1 | High, default |
| MEDIUM | 2 | Normal |
| LOW | 3 | Low |
| LOWEST | 4 | Defer/send later |
WalletType (Enum)
Selects which wallet to query a balance from.
| Name | Value | Description |
|---|---|---|
| LOCAL | "Local" | Local wallet (default if omitted). |
| INTERNATIONAL | "International" | International wallet. |
ApiRequest
Represents an API request payload.
| Field | Type | Description |
|---|---|---|
| method | String | One of: "SendSms" or "Balance". |
| userdata | UserData | The user’s credentials (username & API key). |
| messageData | List<MessageModel> | Messages & recipients for the request. |
| walletType | WalletType | Which wallet to query (Balance requests only). Defaults to LOCAL if omitted. |
MessageModel
Describes a single message to be sent.
| Field | Type | Description |
|---|---|---|
| number | String | Recipient’s phone number. |
| message | String | Message content. |
| senderId | String | Sender ID shown to the recipient. |
| priority | MessagePriority | Priority of this message. |
UserData
Credentials used to authenticate API requests.
| Field | Type | Description |
|---|---|---|
| username | String | Your API username, found in Comms API settings. |
| apikey | String | Your API key (also called "password"), found in Comms API settings. |
Next steps
- Sending SMS — send messages with the SDK.
- Balance Inquiry — check your balance with the SDK.
- Error Handling — what
ApiResponseCode.Failedmeans and how to troubleshoot it.