Skip to Content

Python SDK

1. Preparations

1) Obtain SDK Key Information

2) Obtain Project ID

3) Apply for SMS Signature

  • Domestic SMS: The content sent by domestic SMS consists of two parts: SMS signature and SMS content. You can apply for an SMS signature via self-service in the Domestic SMS/SMS Signature module of the SMS Service Console. For detailed application steps, refer to: How to Apply for SMS Signature.
  • International SMS: International SMS does not require an SMS signature.

4) Apply for SMS Template

  • Domestic SMS: The content sent by domestic SMS consists of two parts: SMS signature and SMS content. The SMS content is obtained by calling the SMS template. You can apply for an SMS template via self-service in the Domestic SMS/SMS Signature module of the SMS Service Console. For detailed application steps, refer to: How to Apply for SMS Template.
  • International SMS: You can apply for an SMS template via self-service in the International SMS/SMS Signature module of the SMS Service Console. For detailed application steps, refer to: How to Apply for SMS Template.

2. Configure the SDK

1) Install the SDK

Refer to UCloud Global SDK Quick Start to install the SDK.

2) Parameter Description

  • Phone Numbers (PhoneNumbers): Supports both international and domestic SMS. For international SMS, use the format (86)13812345678, which requires adding the international dialing code before the phone number.
  • SMS Template ID (TemplateId): When using for the first time, you need to apply for a template in the UCloud Global Console. After approval, pass the template ID here.
  • SMS Template Parameters List (TemplateParams): Variables can be passed in the SMS template. If there are several variables in the applied template, the same number needs to be passed in.
  • SMS Signature (SigContent): When using for the first time, you need to apply for a signature in the UCloud Global Console. After approval, pass the signature here. The first applied signature is the default signature. If a default signature exists, this parameter can be left blank.
  1. SMS content, whether in letters, Chinese characters, or punctuation marks in Chinese or English, is calculated as one character. The content length must not exceed 600 characters.

  2. Domestic: The upper limit of a single SMS is 70 characters. If it exceeds 70 characters, it will be counted as “1 SMS for every 67 characters.”

  3. The upper limit of SMS characters for a single send is 500 characters. Letters, Chinese characters, and punctuation marks in Chinese and English are calculated as one character each.

  4. SMS content should not contain special characters (you can enter the SMS package page and use the Sensitive Word Detection Tool to check).

3. Complete Example

Please contact technical support.

For other APIs such as Get SMS Receipt, please refer to Code Examples in UAPI.