Follow

Create Subscription

The Create Subscription command allows you to add a new Subscription to a List for a specific Subscriber.  See REST API Subscriptions Overview for a table of Subscription data available to POST.  Subscription creation does not result in a tracking event.  It also does not allow you to overwrite opt outs using a Force Subscribe option.

POST /subscriptions

https://[siteurl]/rest/subscriptions

Request Body Parameters

The Create Subscription command requires the following in the Posted JSON:

  • Subscriber ID: "subscriberId": [subscriberId], an integer > 0
  • List ID: "listId": [listId], an integer > 0
  • Format: "formatId": [0,1,99], where 0=plain text, 1=html, and 99=MIME

All other POST-able fields are optional, and can be found in the Data Fields table in REST API Subscriptions Overview.   

Request Body Example

Using Create Subscriber with all arguments, line breaks in JSON for readability:

curl --request POST \ 
--url 'https://mail.mydomain.com/rest/subscriptions' \
--header 'authorization: Basic bXlBY2NvdW50Onh5enB3ZDEyMw==' \
--header 'content-type: application/json' \
--header 'accept: application/vnd.whatcounts-v1+json' \
--data '{ "subscriberId": 7160984, "listId": 5, "formatId": 99 }' \
--include

Response Body

The response returns all available Subscription data.  Based on the example above, the response returns:


HTTP/1.1 200 OK
Server: serverName
Content-Type: application/json
Content-Length: 926
Link: <https://mail.mydomain.com/rest/subscribers>;
Date: Fri, 17 Jun 2016 12:54:44 GMT
{
"subscriptionId": 120002
"subscriberId": 7160984 "listId": 5 "formatId": 99 "createdDate": "Jun 17, 2016 1:12:54 PM" }

Error Response

Error Response Codes include both Client Errors (4xx) and Server Errors (5xx).  Descriptions of each can be found in Response Codes

For example, if a Subscription already exists for the Subscriber, the error would appear as:

{
"error": "Cannot insert duplicate subscription"
"status": "Internal Server Error"
"statusCode": 500
}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk