(topics())
Topics are a way to group subscribers together so that they can be notified of events at once. A topic is identified by a custom key. This can be helpful for things like sending out marketing emails or notifying users of new features. Topics can also be used to send notifications to the subscribers who have been grouped together based on their interests, location, activities and much more.
https://docs.novu.co/subscribers/topics
- create - Topic creation
- delete - Delete topic
- list - Filter topics
- rename - Rename a topic
- retrieve - Get topic
Create a topic
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();
CreateTopicRequestDto req = CreateTopicRequestDto.builder()
.key("<value>")
.name("<value>")
.build();
TopicsControllerCreateTopicResponse res = sdk.topics().create()
.request(req)
.call();
if (res.createTopicResponseDto().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 |
---|---|---|---|
request |
co.novu.co.novu.sdk.models.components.CreateTopicRequestDto | ✔️ | The request object to use for the request. |
Optional<? extends co.novu.co.novu.sdk.models.operations.TopicsControllerCreateTopicResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | / |
Delete a topic by its topic key if it has no subscribers
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();
TopicsControllerDeleteTopicResponse res = sdk.topics().delete()
.topicKey("<value>")
.call();
// 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 |
---|---|---|---|
topicKey |
String | ✔️ | N/A |
Optional<? extends co.novu.co.novu.sdk.models.operations.TopicsControllerDeleteTopicResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | / |
Returns a list of topics that can be paginated using the page
query parameter and filtered by the topic key with the key
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();
TopicsControllerListTopicsRequest req = TopicsControllerListTopicsRequest.builder()
.build();
TopicsControllerListTopicsResponse res = sdk.topics().list()
.request(req)
.call();
if (res.filterTopicsResponseDto().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 |
---|---|---|---|
request |
co.novu.co.novu.sdk.models.operations.TopicsControllerListTopicsRequest | ✔️ | The request object to use for the request. |
Optional<? extends co.novu.co.novu.sdk.models.operations.TopicsControllerListTopicsResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | / |
Rename a topic by providing a new name
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();
TopicsControllerRenameTopicResponse res = sdk.topics().rename()
.topicKey("<value>")
.renameTopicRequestDto(RenameTopicRequestDto.builder()
.name("<value>")
.build())
.call();
if (res.renameTopicResponseDto().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 |
---|---|---|---|
topicKey |
String | ✔️ | N/A |
renameTopicRequestDto |
co.novu.co.novu.sdk.models.components.RenameTopicRequestDto | ✔️ | N/A |
Optional<? extends co.novu.co.novu.sdk.models.operations.TopicsControllerRenameTopicResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | / |
Get a topic by its topic key
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();
TopicsControllerGetTopicResponse res = sdk.topics().retrieve()
.topicKey("<value>")
.call();
if (res.getTopicResponseDto().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 |
---|---|---|---|
topicKey |
String | ✔️ | N/A |
Optional<? extends co.novu.co.novu.sdk.models.operations.TopicsControllerGetTopicResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/SDKError | 4xx-5xx | / |