Unsubscribe Contacts Under Partner Client Accounts
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.
https://api.cc.email/v3/partner/accounts/{encoded_account_id}/unsubscribeimport 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();
}
}Response Example
{
"unsubscribed_count": 1
}