Constant
Contact
API Guide

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_id path parameter.

  • Identify which contacts to unsubscribe by specifying their email addresses using the required email_address array in the request body. If unsubscribing one contact under all partner client accounts (global unsubscribe), only specify that contact's email_address and also set global_unsubscribe to true.

  • Specify the required update_source (Account, Contact, or System) in the request body.

  • To delete contacts you are unsubscribing, set the delete_cotacts to true in the request body. The default is false.

  • Optionally, use opt_out_reason in 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
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();
    }
}

Response Example

{
  "unsubscribed_count": 1
}

On this page