- Add subscription to a contact
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.
Intercom API version.
By default, it's equal to the version set in the app package.
- The production API serverhttps://api.intercom.io/contacts/{contact_id}/subscriptions
- The european API serverhttps://api.eu.intercom.io/contacts/{contact_id}/subscriptions
- The australian API serverhttps://api.au.intercom.io/contacts/{contact_id}/subscriptions
- Successful
- Contact not found
- Resource not found
/**
* 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;
}Successful
A translation object contains the localised details of a subscription type.
An array of translations objects with the localised version of the subscription type in each available locale within your translation settings.
{ "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" ] }