Skip to content

Add subscription to a contact

Request

You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in:

1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type.

2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type.

This will return a subscription type model for the subscription type that was added to the contact.

Security
bearerAuth
Path
contact_idstringrequired

The unique identifier for the contact which is given by Intercom

Example:63a07ddf05a32042dffac965
Headers
Intercom-Versionstring(intercom_version)

Intercom API version.
By default, it's equal to the version set in the app package.

Default:"2.16"
Enum:"1.0""1.1""1.2""1.3""1.4""2.0""2.1""2.2""2.3""2.4"
Example:2.16
Bodyapplication/json
idstringrequired

The unique identifier for the subscription which is given by Intercom

Example:"37846"
consent_typestringrequired

The consent_type of a subscription, opt_out or opt_in.

Example:"opt_in"
/**
 * Requires libcurl
 */

const contactId = "63a07ddf05a32042dffac965";
$curl = curl_init();

$payload = array(
  "id" => 106,
  "consent_type" => "opt_in"
);

curl_setopt_array($curl, [
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <YOUR_TOKEN_HERE>",
    "Content-Type: application/json",
    "Intercom-Version: 2.16"
  ],
  CURLOPT_POSTFIELDS => json_encode($payload),
  CURLOPT_URL => "https://api.intercom.io/contacts/" . contactId . "/subscriptions",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
]);

$response = curl_exec($curl);
$error = curl_error($curl);

curl_close($curl);

if ($error) {
  echo "cURL Error #:" . $error;
} else {
  echo $response;
}

Responses

Successful

Bodyapplication/json
typestring

The type of the object - subscription

Example:"subscription"
idstring

The unique identifier representing the subscription type.

Example:"123456"
statestring

The state of the subscription type.

Enum:"live""draft""archived"
Example:"live"
default_translationobject(Translation)

A translation object contains the localised details of a subscription type.

translationsArray of objects(Translation)

An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.

consent_typestring

Describes the type of consent.

Enum:"opt_out""opt_in"
Example:"opt_in"
content_typesArray of strings

The message types that this subscription supports - can contain email or sms_message.

Items Enum:"email""sms_message"
Example:
[ "email" ]
Response
{ "type": "subscription", "id": "106", "state": "live", "consent_type": "opt_in", "default_translation": { "name": "Newsletters", "description": "Lorem ipsum dolor sit amet", "locale": "en" }, "translations": [ {} ], "content_types": [ "sms_message" ] }