Only authorized technology partners have access to partner endpoints. To make authorized calls to partner endpoints, you must include your API key in the x-api-key header and the JSON Web Token (JWT) in the Authorization header. The JWT automatically expires in one hour (3,600 seconds) and cannot be refreshed. You must re-authenticate each time a JWT expires.
To unsubscribe one or more contacts under a specific partner’s client account, or to unsubscribe one contact from all client accounts under a partner, make a POST call to the /partner/accounts/{encoded_account_id}/unsubscribe endpoint.
-
Identify a partner’s client account using the required
encoded_account_idpath parameter. -
Identify which contacts to unsubscribe by specifying their email addresses using the required
email_addressarray in the request body. If unsubscribing one contact under all partner client accounts (global unsubscribe), only specify that contact’semail_addressand also setglobal_unsubscribetotrue. -
Specify the required
update_source(Account,Contact, orSystem) in the request body. -
To delete contacts you are unsubscribing, set the
delete_cotactstotruein the request body. The default isfalse. -
Optionally, use
opt_out_reasonin the request body to include the reason a contact opted out.
Example Request
The following header parameters are required:
x-api-key: Enter the API key associated with your application.Authorization: Enter the JWT to use.
The following example request unsubscribes a single user from a partner client account.
POST https://api.cc.email/v3/partner/accounts/{encoded_account_id}/unsubscribe
<?php
$url = "https://api.cc.email/v3/partner/accounts/a07e1lxbqqo0/contacts/unsubscribe";
$accessToken = "{your_access_token}";
$apiKey = "{your_api_key}";
$data = [
"email_addresses" => ["lang.carry@anymail.com"],
"update_source" => "Account",
"opt_out_reason" => "Lost interest",
"delete_contacts" => false,
"global_unsubscribe" => false
];
$ch = curl_init($url);
curl_setopt_all($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $accessToken",
"x-api-key: $apiKey",
"Content-Type: application/json"
]
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo "Status: $status\n";
echo "Response: $response\n";
}
curl_close($ch);
?>
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class UnsubscribeContact {
public static void main(String[] args) {
String accessToken = "{your_access_token}";
String apiKey = "{your_api_key}";
String url = "https://api.cc.email/v3/partner/accounts/a07e1lxbqqo0/contacts/unsubscribe";
// JSON Payload
String jsonBody = """
{
"email_addresses": ["lang.carry@anymail.com"],
"update_source": "Account",
"opt_out_reason": "Lost interest",
"delete_contacts": false,
"global_unsubscribe": false
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + accessToken)
.header("x-api-key", apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
client.sendAsync(request, HttpResponse.BodyHandlers.ofString())
.thenApply(HttpResponse::body)
.thenAccept(System.out::println)
.join();
}
}
curl -X POST https://api.cc.email/v3/partner/accounts/a07e1lxbqqo0/contacts/unsubscribe \
-H "Authorization: Bearer {your_access_token}" \
-H "x-api-key: {your_api_key}" \
-H "Content-Type: application/json" \
-d '{
"email_addresses": ["lang.carry@anymail.com"],
"update_source": "Account",
"opt_out_reason": "Lost interest",
"delete_contacts": false,
"global_unsubscribe": false
}'
Response Example
{
"unsubscribed_count": 1
}