SMS Campaigns
You can use the SMS campaign endpoints to send an SMS campaign, check the cost of sending an SMS campaign, view SMS campaign history, and cancel a scheduled SMS campaign. Add these endpoints as part of your workflow.
Relevant guides: SMS campaign analytics, Can we shorten a URL manually?, and How to send a SMS campaign?.
https://rest.clicksend.com/
Request
SMS Campaign Endpoint
You can post to a list with up to 20000 recipients
with each API call. You can only send to a single list containing up to 20,000 recipients. The response is far less detailed than the normal Send SMS endpoint. Use the SMS Send endpoint if you would like to send to less than 1000 recipients at once. You are required to add an opt-out message to the end of your message body if you are sending marketing message. This can be in the form of asking users to reply STOP to opt-out or by including StopMsg.me/xxxxx
which is a placeholder that will add a link that can be clicked to out-out. Refer to Status Codes for definitions of HTTP status code responses.
The list_id
of the contact list to send the message to. Use the View Contact List endpoint to see your contact lists. You can also use the other list endpoints to create and manage your contact list. You need to provide the to parameter or the list_id
parameter.
The sender of the message. This is also referred to as the Sender ID. You can use:
- Shared number: A number that is randomly selected from a pool if no number is specified. This is not available in the US and Canada. You can’t use a shared number if you have a dedicated number.
- Dedicated number: A number you've purchased from ClickSend. You can purchase a dedicated number using the Dashboard or the Purchase Dedicated Number endpoint. It should be in the international format (E.164).
- Alpha tag: A sender name, like the name of your business, used as the Sender ID instead of a number. Recipients cannot reply to an alpha tag. You can register an alpha tag using the dashboard or the Request Alpha Tag endpoint. Check which countries support alpha tags here.
- Own number: Your own number that is connected to your account. Replies from recipients are sent directly to your number. You can register your own number using the dashboard or the Request Own Number Verification OTP endpoint to get the verification_id and OTP code needed for the Verify Own Number OTP endpoint. This isn't available in the US and Canada. If your Sender ID has a different country code to the recipient’s, it'll be replaced by a local number, except in certain countries. If the sender number is blocked, a different number will replace it.
The message to send. The price of sending a message depends on the number of characters and the type of message. There are two types:
- Standard message - Contains only characters in the GSM set, with a maximum of 160 characters.
- Unicode message - Contains characters outside the GSM set, with a maximum of 70 characters.
Longer messages will be sent as multiple messages (parts), but the recipient will receive them as a single long message. Visit this page to learn more about the number of characters per message, and this page to count the number of characters.
The source of the request. For example, the name of your application. It's used to identify messages sent from various applications.
The time you want the message to be sent. It should be in Unix format.
The senders
property specifies sender IDs for each recipient country.
Want to leverage the default sender settings:
- If the
senders
property is missing or left empty, the system uses the default sender settings configured for each recipient country.
- If the
Want to override the default sender settings:
- When the
senders
property is provided, it should contain valid sender IDs for each recipient country listed under recipients. These IDs will override the default sender settings for the specified countries. - If an invalid sender ID is provided, or a sender ID for a specific recipient country is missing, the system will revert to using the default sender settings for that country.
- When the
Join the BETA Program:
Early access to Smart Assign is available. Contact the sales team to opt-in and participate in the BETA program.
The sender ID must be either an alpha tag or a phone number. It is a required field unless the sender type is a shared_longcode
.
If the sender ID is an alpha tag, it must be between 3 and 11 characters long and contains only letters, numbers, and pluses.
The type of sender ID, it only supports shared_longcode
at the moment.
The ISO 3166-1 alpha-2 country code that identifies the country associated with the sender’s number in a shared pool. This is affected only when sender_type
is set to shared_longcode
to determine the appropriate number based on the sender’s geographic location. If this field is not provided or left empty, it will default to the recipient's country code.
https://rest.clicksend.com/v3/sms-campaigns/send
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl --include \
--header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA==" \
--request POST \
--header "Content-Type: application/json" \
--data-binary "{
\"list_id\":428,
\"name\":\"My Campaign 1\",
\"body\":\"This is my new campaign message.\"
}" \
'https://rest.clicksend.com/v3/sms-campaigns/send'
{ "http_code": 200, "response_code": "SUCCESS", "response_msg": "Your new campaign has been added.", "data": { "sms_campaign_id": 7, "name": "My Campaign 1", "user_id": 1, "subaccount_id": 1, "list_id": 428, "from": "+61353787448", "body": "This is my new campaign message. StopMsg.me/xxxxx", "schedule": "1444821615", "status": "Queued", "date_added": "1444962630", "custom_string": null, "url_to_shorten": "string", "unsubscribe_link": 0, "source": null, "senders": [ … ], "_total_count": 10, "_list_name": "string" } }
Request
Calculate price for sms campaign
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
list_id | integer(int32) | true | none | Your list id. |
name | string | true | none | Your campaign name. |
body | string | true | none | Your campaign message. |
from | string | true | yes | Your sender id |
schedule | integer(int32) | false | none | Your schedule timestamp. |
Refer to Status Codes for definitions of HTTP status code responses.
https://rest.clicksend.com/v3/sms-campaigns/price
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl --include \
--header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA==" \
--request POST \
--header "Content-Type: application/json" \
--data-binary "{
\"list_id\":428,
\"name\":\"My Campaign 1\",
\"body\":\"(First Name), this is your new campaign message.\"
}" \
'https://rest.clicksend.com/v3/sms-campaigns/price'
{ "http_code": 200, "response_code": "SUCCESS", "response_msg": "Here is your price for your SMS Campaign.", "data": { "total_count": 1, "total_price": "0.035", "data": { … }, "_currency": { … } } }
Request
Update sms campaign
Parameters
Parameter | In | Type | Required | Description |
---|---|---|---|---|
sms_campaign_id | path | integer(int32) | true | ID of SMS campaign to update |
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
list_id | integer(int32) | true | none | Your list id. |
name | string | true | none | Your campaign name. |
body | string | true | none | Your campaign message. |
from | string | true | yes | Your sender id |
schedule | integer(int32) | false | none | Your schedule timestamp. |
Refer to Status Codes for definitions of HTTP status code responses.
https://rest.clicksend.com/v3/sms-campaigns/{sms_campaign_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl --include \
--header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA==" \
--request PUT \
--header "Content-Type: application/json" \
--data-binary "{
\"list_id\":428,
\"name\":\"Awesome campaign.\",
\"body\":\"his is an awesome message.\"
}" \
'https://rest.clicksend.com/v3/sms-campaigns/{sms_campaign_id}'
{ "http_code": 200, "response_code": "SUCCESS", "response_msg": "Your SMS Campaign has been updated.", "data": { "sms_campaign_id": 7, "name": "My Campaign 1", "user_id": 1, "subaccount_id": 1, "list_id": 428, "from": "+61353787448", "body": "This is my new campaign message. StopMsg.me/xxxxx", "schedule": "1444821615", "status": "Queued", "date_added": "1444962630", "custom_string": null, "url_to_shorten": "string", "unsubscribe_link": 0, "source": null, "senders": [ … ], "_total_count": 10, "_list_name": "string" } }
https://rest.clicksend.com/v3/sms-campaigns/{sms_campaign_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl --include \
--header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA==" \
'https://rest.clicksend.com/v3/sms-campaigns/{sms_campaign_id}'
Successful response
The response code of the operation. Visit Visit this page for more information.
{ "http_code": 200, "response_code": "SUCCESS", "response_msg": "Your SMS Campaign.", "data": { "sms_campaign_id": 7, "name": "My Campaign 1", "user_id": 1, "subaccount_id": 1, "list_id": 428, "from": "+61353787448", "body": "This is my new campaign message. StopMsg.me/xxxxx", "schedule": "1444821615", "status": "Queued", "date_added": "1444962630", "custom_string": null, "url_to_shorten": "string", "unsubscribe_link": 0, "source": null, "senders": [ … ], "_total_count": 10, "_list_name": "string" } }
https://rest.clicksend.com/v3/sms-campaigns/{sms_campaign_id}/cancel
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl --include \
--header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA==" \
--request PUT \
'https://rest.clicksend.com/v3/sms-campaigns/{sms_campaign_id}/cancel'
Successful response
The response code of the operation. Visit this page for more information.
{ "http_code": 200, "response_code": "SUCCESS", "response_msg": "Your SMS Campaign.", "data": { "sms_campaign_id": 2135501, "name": "kkde", "user_id": 496596, "subaccount_id": 563840, "list_id": 2484219, "from": "edwardo3312", "body": "new message2👍👎 smsu.io/xxxxx Reply STOP to opt-out ", "schedule": 2147483647, "status": "Scheduled", "date_added": 1726199079, "custom_string": "testz1", "url_to_shorten": "https://developers.clicksend.com/docs/", "unsubscribe_link": 0, "source": "new_soruce", "senders": [ … ], "_total_count": 5, "_list_name": "Opt-Out List" } }
The page number to retrieve. Use this parameter to navigate through the [pagination]/#pagination) results. The default value is 1.
The number of items to return per page. This parameter controls the size of each page of results. The default value is 15.
Allows filtering of results based on your search criteria. The query should be in the format field_name:value
.
Field Name: The field within the SMS campaign you want to filter by. You can use the following fields:
- sms_campaign_id,name,user_id,subaccount_id,list_id,from,body,schedule,status,date_added,custom_string,url_to_shorten,unsubscribe_link,source
Value: The text or keyword you're searching for within the specified field. If left empty after the colon, the filter will look for all templates with any value in the Field Name.
For example, if you are searching for a SMS campaign with the status of Scheduled, the final query would look like this:
q=status:Scheduled
Note:
Some characters have to be encoded. For example, if you are searching for SMS sent from the phone number +61437085284, your search query q would be:
- q=from:%2B61437085284
You can use the URL encoder to encode the text. If a character is not an alphanumeric character (A-Z, a-z, 0-9), it is typically either reserved or unsafe and should be encoded.
Specifies the field and order to sort the results by. The value is composed of the field name followed by a colon and the sort direction (asc for ascending or desc for descending). The default sort order is by date_added in ascending order. You can use the following fields:
- name: The name of the SMS campaign.
- status: The status of the SMS campaign.
- schedule: The schedule send date of the SMS campaign in the Unix format.
- from: The sender of the SMS campaign.
- date_added: This is the date you created or updated the SMS campaign in the Unix format.
For example, if you want to order by the most recently sent or scheduled SMS, you should sort by date in descending order. The query would look like this:
order_by=schedule:desc
Note:
You can also sort by these fields:
- sms_campaign_id,user_id,subaccount_id,list_id,body,custom_string,url_to_shorten,unsubscribe_link, and source.
But this is less common in practice.
Start date to filter results. It should be in Unix format.
End date to filter results. It should be in Unix format.
https://rest.clicksend.com/v3/sms-campaigns
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl --include \
--header "Authorization: Basic YXBpLXVzZXJuYW1lOmFwaS1wYXNzd29yZA==" \
'https://rest.clicksend.com/v3/sms-campaigns'
Successful response
The response code of the operation. Visit this page for more information.
A message describing the outcome of the operation.
The parameters related to the total SMS campaign shown. The response will depend on the query parameters.
{ "http_code": 200, "response_code": "SUCCESS", "response_msg": "Here are your SMS campaign(s) (shared included).", "data": { "total": 1, "per_page": 15, "current_page": 1, "last_page": 1, "next_page_url": null, "prev_page_url": null, "from": 1, "to": 1, "data": [ … ] } }