Work with Contacts to Reset Passwords, Send Mailings, and Run Marketing Campaigns

You can use the REST API to perform standard CRUD (create, read, update, delete) operations on the contacts REST resource. However, starting with the May 2016 release, the following operations have been added to cover additional use cases for working with contacts:

Reset the Password of a Contact

You can reset the password of a contact using REST APIs. Let's look at an example to understand this better.

Greta Emerson, a customer of Vision Corporation, contacts Vision Corporation customer support requesting help with resetting her password as she has forgotten her existing password. Dan Grayson, the customer support representative, can help her with the request by using the REST API as follows:

Use the POST method with the following syntax to reset a contact's password:

  1. Make a note of the contact ID of the contact. The contact ID of Greta is 751
  2. Construct the request URL for the Reset password for a contact operation using the contact ID
  3. Run the request using the POST HTTP method to reset the password

Dan runs the REST API request, which sends an email to Greta with a link to reset the password. Greta resets the password via the link emailed to her and then logs in to the B2C Service page of Vision Corporation.

Example URL

Here's the complete URL with the POST HTTP method.

POST
https://mysite.example.com/services/rest/connect/v1.4/contacts/751/resetPassword

cURL Command

curl -X POST https://mysite.example.com/services/rest/connect/v1.4/contacts/751/resetPassword -H 'Authorization: Basic YWRtaW46' -H 'Content-Type: application/json' -H 'OSvC-CREST-Application-Context: Reset password'

Example Response

The status 200 OK is returned, indicating that the request was successful. An email with the "Reset Password" link is sent to the contact.

Send a Mailing to a Contact

You can send a transactional mailing or survey to a contact at a scheduled time using the REST API. Let's look at an example to understand this better.

Dan Grayson, a customer support representative at Vision Corporation closes an incident raised by Greta Emerson, a customer of Vision Corporation. While closing the incident, Dan can schedule a mailing to Greta to notify her about product updates using the REST API as follows:

  1. Get the contact ID of the contact
  2. Get the mailing ID of the mailing to be sent
  3. Get the incident ID of the incident being closed
  4. Decide the date and time when the mailing should be sent
  5. Construct the request URL for the Send a transactional mailing to a contact operation
  6. Run the request using the POST HTTP method

Example URL

Here's the complete URL with the POST HTTP method.

POST
https://mysite.example.com/services/rest/connect/v1.4/contacts/751/sendMailing

Example Request

You can use the following request parameters:

Parameter Description

mailing

Required. ID of the mailing.

incident or opportunity

Incident or opportunity ID. You can't use both.

scheduledTime

Time when the mailing will be sent, in ISO-8601 format. If scheduledTime isn't specified, the mailing will be sent immediately.

{
"mailing": {"id": 123},
"incident": {"id": 12},
"scheduledTime": "2016-02-28T04:00:00Z"
}

cURL Command

curl -X POST https://mysite.example.com/services/rest/connect/v1.4/contacts/751/sendMailing -H 'Authorization: Basic YWRtaW46' -H 'Content-Type: application/json' -H 'OSvC-CREST-Application-Context: Send Mailing' -d '{ "mailing": {"id": 123}, "incident": {"id": 12}, "scheduledTime": "2019-07-28T04:00:00Z" }'

Example Response

The status 200 OK is returned, indicating that the mailing has been scheduled.

Run a Marketing Campaign or Flow

You can start a marketing campaign or flow by providing an entry point and relevant details using the REST API. Let's look at an example to understand this better.

Jeff Rendall, a marketing execute at Vision Corporation wants to include Greta Emerson, a customer of Vision Corporation in a marketing campaign. Jeff can do this using the REST API as follows:

  1. Get the contact ID of the contact
  2. Get the campaign ID of the campaign
  3. Retrieve the entry point within the campaign flow where the contact will start
  4. Construct the request URL for the Send a contact through a campaign flow starting at the specified entry point operation
  5. Run the request using the POST HTTP method

Example URL

Here's the complete URL with the POST HTTP method.

POST
https://mysite.example.com/services/rest/connect/v1.4/contacts/751/executeMarketingFlow

Example Request

You can use the following request parameters:

Parameter Description

campaign or flow

Campaign or flow ID. You can't use both.

entryPoint

Entry point to the flow.

{
"campaign": {"id": 123},
"entryPoint": "entry0"
}

cURL Command

curl -X POST https://mysite.example.com/services/rest/connect/v1.4/contacts/751/executeMarketingFlow -H 'Authorization: Basic YWRtaW46' -H 'Content-Type: application/json' -H 'OSvC-CREST-Application-Context: run marketing' -d '{ "campaign": {"id": 123}, "entryPoint": "entry0" }

Example Response

The status 200 OK is returned, indicating that the marketing campaign has been run.