Follow

Send Message with Custom Content

The Send Message with Custom Content command allows you to send a single transactional style message of custom content to a Subscriber defined in the JSON. 

Messages are individually created and sent but can be tracked together as a sticky campaign to collect data as a single campaign.   To group your data into a single campaign, either use the Campaign Name argument or use a List with Sticky Campaigns enabled. 

This command does not support the same features as the HTTP API, FTP API, or WebServices API Send commands, including the ability to define Google Analytics strings, Account Profile, or Subscriber Data for personalization.  If your content includes Subscriber or Custom Data, you must create the subscriber first and import the data you wish to fill the content before using this command.  

POST /lists

https://[siteurl]/rest/msg/sendWithContent/[listName]/?querystring

The following queries are supported:

format=[1,2,99], where 1=plain text, 2=html, and 99=MIME

campaignName=[string],
To track one-off message events, such as opens and click-throughs, define a campaign name. The Campaign Name can be no longer than 100 characters. A single list can have multiple campaigns by defining a different Campaign Name in a command.

respectOptout=[true,false],
If a subscriber has opted out, messages sent via the Send command will not be delivered. To override this restriction for transactional messages, such as order confirmations, set this argument to 'false'. DO NOT override opt outs for anything other than transactional messages, as this could be construed as spam.

subjectLine=[string], overrides the default Subject defined in the Template. Character limit is 48.

Request Body Parameters

The Send Message with Custom Content command requires the URI call with the List Name. Subject Line query is required.  Optional Filters include Format, Campaign Name, and Opt Out parameters. 

The query strings are case sensitive and must be defined as in the example.  If the query string is incorrect or missing, it is ignored and the command creates a Plain Text message without duplication, sending to the first subscriber found to match the posted JSON.

The command also requires the following in the Posted JSON:

  • Email: "email": [string]
  • HTML Content: "htmlContent": [string], Required if format=2,99
  • Plain Text Content: "textContent": [string] , Required if format=1,99
  • Customer Key: "customerKey": [string], Required in Customer Key enabled realm

The following are optional in the Posted JSON:

  • First Name: "firstName": [string]
  • From Address: "fromEmail": [email], Required if not defined in List Properties
  • Reply To Address: "replyToAddress": [email], Required if not defined in List Properties
  • Format: "format": [1,2,99], where 1=plain text, 2=html, and 99=MIME

Request Body Example

Using Send Message with Custom Content with all arguments, line breaks in JSON for readability:

curl --request POST \ 
--url 'https://mail.mydomain.com/rest/msg/sendWithContent/myList?format=99&campaignName=myContentSend&respectOptout=true&subjectLine=Read this content' \
--header 'authorization: Basic bXlBY2NvdW50Onh5enB3ZDEyMw==' \
--header 'content-type: application/json' \
--header 'accept: application/vnd.whatcounts-v1+json' \
--data '{ "email": "jon@mydomain.com",
"firstName": "Jon",
"fromEmail": "myFrom@mydomain.com",
"replyToEmail": "myReply@mydomain.com",
"htmlContent": "<body><p>This is the HTML message content.</p></body>", "textContent": "This is the Plain Text content." }' \
--include

Using Send Message with Custom Content with all arguments for Customer Key enabled realm, line breaks in JSON for readability:

curl --request POST \ 
--url 'https://mail.mydomain.com/rest/msg/sendWithContent/myList?format=99&campaignName=myContentSend&respectOptout=true&subjectLine=Read this content' \
--header 'authorization: Basic bXlBY2NvdW50Onh5enB3ZDEyMw==' \
--header 'content-type: application/json' \
--header 'accept: application/vnd.whatcounts-v1+json' \
--data '{ "customerKey":"ck1232",
"email": "jon@mydomain.com",
"firstName": "Jon",
"fromEmail": "myFrom@mydomain.com",
"replyToEmail": "myReply@mydomain.com",
"htmlContent": "<body><p>This is the HTML message content.</p></body>", "textContent": "This is the Plain Text content." }' \
--include

Response Body

The response returns a Success or Failure Error.  Based on the first example above, the response returns a 0 for Success:

HTTP/1.1 200 OK
Server: serverName
Content-Type: application/json
Content-Length: 1
Date: Fri, 17 Mar 2018 12:54:44 GMT
0

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 List ID is not found, if a Subscriber is not found, or content is not supplied in the JSON.

For example, if a Subscription does not exist for the Subscriber, the error would appear as:

{
"error": "Subscriber Not Found"
"status": "Not Found"
"statusCode": 404
}

Feature added in v13.04.0

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk