PATCH
/
v1
/
subscribers
/
{subscriberId}
/
preferences
/
{templateId}
import co.novu.common.base.Novu;
import co.novu.api.subscribers.requests.UpdateSubscriberPreferenceRequest;
import co.novu.api.subscribers.responses.SingleSubscriberPrefResponse;

public class Main {
    public static void main(String[] args) {
        String apiKey = "<NOVU_API_KEY>";
        Novu novu = new Novu(apiKey);
        String subscriberId = "<SUBSCRIBER_ID>";
        String templateId = "<TEMPLATE_ID>";

        PreferenceChannel channel = new PreferenceChannel();
        channel.setType("<TYPE>");
        channel.setEnabled(true);

        UpdateSubscriberPreferenceRequest request = new UpdateSubscriberPreferenceRequest();
        request.setEnabled(false);
        request.setChannel(channel);

        SingleSubscriberPrefResponse response = novu.updateSubscriberPreferences(request, subscriberId, templateId);
    }
}
{
  "data": {
    "preference": {
      "channels": {
        "chat": "boolean",
        "email": "boolean",
        "in_app": "boolean",
        "push": "boolean",
        "sms": "boolean"
      },
      "enabled": "boolean"
    },
    "template": {
      "_id": "string",
      "critical": "boolean",
      "name": "string"
    }
  }
}

Enter your API key in the Authorization field like the example shown below:

E.g ApiKey 18d2e625f05d80e

Path Parameters

subscriberId
string
required
templateId
string
required

Body

application/json
channel
object

The subscriber preferences for every ChannelTypeEnum for the workflow assigned.

enabled
boolean

Sets if the workflow is fully enabled for all channels or not for the subscriber.

Response

200 - application/json
data
object