PUT
/sms-campaign/:id/Add recipient SMS campaign
You can add recipients to an existing SMS campaign.
| Attributes | Type | Required | Description |
|---|---|---|---|
| id | integer | yes | A unique identifier for the campaign which is given by User.com |
| description | string | no | A description of the SMS campaign. |
| eta | string | no | A datetime when a campaign should be sent. If not provided, the campaign will be sent right away. |
| name | string | yes | A SMS campaign name. |
| phone_number | string | yes | A phone number where SMS will be sent |
| recipients | object | no | A list of user_ids. |
| recipients_count | integer | no | A number of recipients. |
| status | integer | no | A status of your campaign (1 - draft, 2 - active, 3 - finished, 4- archived). |
| type | integer | no | A type of SMS campaign (1 - simple, 2 - automated). |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X PUT
"https://<your_app_subdomain>.user.com/api/public/sms-campaign/:id/"
-H 'Authorization: Token <your_64_char_api_key>'
-H 'Cache-Control: no-cache'
-H 'Content-Type: application/json'
-d '{
"name": "Sample SMS campaign",
"phone_number": {
"provider": "Phone number provider",
"phone_number": "123123123",
"name": "Custom name of your phone number"
},
"recipients": [5,6,7,8]
}'
var data = JSON.stringify({
"name": "Sample SMS campaign",
"phone_number": {
"provider": "Phone number provider",
"phone_number": "123123123",
"name": "Custom name of your phone number"
},
"recipients": [
5,6,7,8
]
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("PUT", "https://<your_app_subdomain>.user.com/api/public/sms-campaign/:id/");
xhr.setRequestHeader("Authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.send(data);
<?php
$request = new HttpRequest();
$request->setUrl('https://<your_app_subdomain>.user.com/api/public/sms-campaign/:id/');
$request->setMethod(HTTP_METH_PUT);
$request->setHeaders(array(
'Cache-Control' => 'no-cache',
'Content-Type' => 'application/json',
'Authorization' => 'Token <your_64_char_api_key>'
));
$request->setBody('{
"name": "Sample SMS campaign",
"phone_number": {
"provider": "Phone number provider",
"phone_number": "123123123",
"name": "Custom name of your phone number"
},
"recipients": [5,6,7,8]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
import http.client
conn = http.client.HTTPSConnection("<your_app_subdomain>.user.com")
payload = "{\n \"name\": \"Sample SMS campaign\",\n \"phone_number\": {\n \"provider\": \"Phone number provider\",\n \"phone_number\": \"123123123\",\n \"name\": \"Custom name of your phone number\"\n },\n \"recipients\": [5,6,7,8]\n}"
headers = {
'Authorization': "Token <your_64_char_api_key>",
'Content-Type': "application/json",
'Cache-Control': "no-cache"
}
conn.request("PUT", "/api/public/sms-campaign/:id/", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Response
{
"id": 8,
"name": "Sample SMS campaign",
"description": "",
"app": 1,
"phone_number": {
"id": 3,
"app": 1,
"provider": "Phone number provider",
"country": "",
"phone_number": "123123123",
"name": "Custom name of your phone number",
"description": "",
"sms": false,
"voice": false,
"price": "0.00",
"last_used_at": null,
"created_at": "2018-02-19T13:01:41.083625Z",
"updated_at": "2018-02-19T13:01:41.083655Z",
"record_incoming_calls": false
},
"type": 1,
"eta": null,
"status": 1,
"recipients": [
1,
2,
3,
4,
5,
6,
7,
8,
],
"recipients_ids": "[1,2,3,4,5,6,7,8]",
"recipients_count": 8,
"started_at": null,
"last_message_sent_at": null,
"finished_at": null,
"author": 1,
"created_at": "2018-02-19T13:01:41.097096Z",
"updated_at": "2018-02-19T13:01:41.097126Z"
}