The Add SMS Contact to Sender Code command allows you to subscribe an existing SMS contact to an SMS Sender Code.
POST /sms/addSubscriberToSenderCode
https://[siteurl]/rest/sms/addSubscriberToSenderCode/[email]/[phone]/[senderCode]?querystring
The following queries are supported:
groupName=[string]
first=[string]
customerKey=[string]
Request Body Parameters
The Add SMS Contact to Sender Code command requires the URI call with the Contact Email, Phone and SMS Sender Code. Optional Filter includes the Group Name and First name parameters. Customer Key is required in Realms with Customer Key enabled.
The query strings 'groupName', 'first', and 'customerKey' are case sensitive and must be defined as in the example above. A Group Name must be defined in order to save. If the query string is incorrect or missing, it is ignored and the command creates a message with no label.
Request Body Example
Using Add SMS Contact to Sender Code with all arguments, line breaks in JSON for readability:
curl --request POST \
--url 'https://mail.mydomain.com/rest/sms/addPhoneToSenderCode/jon.doe@mydomain.com/2065559696?groupName=weekly&first=Jon&customerKey=jDoe3214' \
--header 'authorization: Basic bXlBY2NvdW50Onh5enB3ZDEyMw==' \
--header 'content-type: application/json' \
--header 'accept: application/vnd.whatcounts-v1+json' \
--include
Response Body
The response returns JSON or an HTTP status code. Based on the first example above, the response returns:
HTTP/1.1 200 OK
Server: serverName
Content-Type: application/json
Content-Length: 456
Date: Fri, 16 Mar 2018 09:10:50 GMT
{
"success": true,
"createDate": "Jan 27, 2020 9:12:31 AM",
"updatedDate": "Jan 27, 2020 9:12:31 AM",
"realmId": 1,
"smsSubscriberId": 5,
"id": 7,
"groupName": "smsGroup",
"phone": "15558999520"
}
Error Response
Error Response Codes include both Client Errors (4xx) and Server Errors (5xx). Descriptions of each can be found in Response Codes. An error will occur if Message Name or Text is blank, or a Message with the same Name already exists.
For example, if a Subscription already exists for the Contact, the error would appear as:
{
"error": "Unable to create subscriber record. A subscriber with this phone number already exists."
"status": "Internal Server Error"
"statusCode": 500
}
Feature added in v12.16.0