(subscribers())
A subscriber in Novu represents someone who should receive a message. A subscriber’s profile information contains important attributes about the subscriber that will be used in messages (name, email). The subscriber object can contain other key-value pairs that can be used to further personalize your messages.
https://docs.novu.co/subscribers/subscribers
Creates a subscriber entity, in the Novu platform. The subscriber will be later used to receive notifications, and access notification feeds. Communication credentials such as email, phone number, and 3 rd party credentials i.e slack tokens could be later associated to this entity.
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
CreateSubscriberRequestDto req = CreateSubscriberRequestDto.builder()
.subscriberId("<value>")
.build();
SubscribersControllerCreateSubscriberResponse res = sdk.subscribers().create()
.request(req)
.call();
if (res.subscriberResponseDto().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerCreateSubscriberResponse>
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
/ |
Using this endpoint you can create multiple subscribers at once, to avoid multiple calls to the API.
The bulk API is limited to 500 subscribers per request.
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
BulkSubscriberCreateDto req = BulkSubscriberCreateDto.builder()
.subscribers(java.util.List.of(
CreateSubscriberRequestDto.builder()
.subscriberId("<value>")
.build()))
.build();
SubscribersControllerBulkCreateSubscribersResponse res = sdk.subscribers().createBulk()
.request(req)
.call();
// handle response
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerBulkCreateSubscribersResponse>
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
/ |
Deletes a subscriber entity from the Novu platform
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
SubscribersControllerRemoveSubscriberResponse res = sdk.subscribers().delete()
.subscriberId("<value>")
.call();
if (res.deleteSubscriberResponseDto().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
subscriberId |
String |
✔️ |
N/A |
Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerRemoveSubscriberResponse>
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
/ |
Returns a list of subscribers, could paginated using the page
and limit
query parameter
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
SubscribersControllerListSubscribersResponse res = sdk.subscribers().list()
.page(7685.78d)
.limit(10d)
.call();
while (true) {
if (res.object().isPresent()) {
// handle response
Optional<SubscribersControllerListSubscribersResponse> nextRes = res.next();
if (nextRes.isPresent()) {
res = nextRes.get();
} else {
break;
}
}
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
page |
Optional<? extends Double> |
➖ |
N/A |
limit |
Optional<? extends Double> |
➖ |
N/A |
Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerListSubscribersResponse>
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
/ |
Get subscriber by your internal id used to identify the subscriber
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
SubscribersControllerGetSubscriberResponse res = sdk.subscribers().retrieve()
.subscriberId("<value>")
.call();
if (res.subscriberResponseDto().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter |
Type |
Required |
Description |
subscriberId |
String |
✔️ |
N/A |
Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerGetSubscriberResponse>
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
/ |
Used to update the subscriber entity with new information
package hello.world;
import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Novu sdk = Novu.builder()
.apiKey("<YOUR_API_KEY_HERE>")
.build();
SubscribersControllerUpdateSubscriberResponse res = sdk.subscribers().update()
.subscriberId("<value>")
.updateSubscriberRequestDto(UpdateSubscriberRequestDto.builder()
.build())
.call();
if (res.subscriberResponseDto().isPresent()) {
// handle response
}
} catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerUpdateSubscriberResponse>
Error Object |
Status Code |
Content Type |
models/errors/SDKError |
4xx-5xx |
/ |