(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
- List - Get topic list filtered
- Delete - Delete topic
- Retrieve - Get topic
- Rename - Rename a topic
Create a topic
package main
import(
"context"
novugo "github.com/novuhq/novu-go"
"github.com/novuhq/novu-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Topics.Create(ctx, components.CreateTopicRequestDto{
Key: "<key>",
Name: "<value>",
}, nil)
if err != nil {
log.Fatal(err)
}
if res.CreateTopicResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
createTopicRequestDto |
components.CreateTopicRequestDto | ✔️ | N/A |
idempotencyKey |
*string | ➖ | A header for idempotency purposes |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TopicsControllerCreateTopicResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 414 | application/json |
apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.ErrorDto | 500 | application/json |
apierrors.APIError | 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 main
import(
"context"
novugo "github.com/novuhq/novu-go"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Topics.List(ctx, nil, nil, novugo.String("exampleKey"), nil)
if err != nil {
log.Fatal(err)
}
if res.FilterTopicsResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
page |
*int64 | ➖ | The page number to retrieve (starts from 0) | 0 |
pageSize |
*int64 | ➖ | The number of items to return per page (default: 10) | 10 |
key |
*string | ➖ | A filter key to apply to the results | exampleKey |
idempotencyKey |
*string | ➖ | A header for idempotency purposes | |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TopicsControllerListTopicsResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 414 | application/json |
apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.ErrorDto | 500 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Delete a topic by its topic key if it has no subscribers
package main
import(
"context"
novugo "github.com/novuhq/novu-go"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Topics.Delete(ctx, "<value>", nil)
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
topicKey |
string | ✔️ | The topic key |
idempotencyKey |
*string | ➖ | A header for idempotency purposes |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TopicsControllerDeleteTopicResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 414 | application/json |
apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.ErrorDto | 500 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get a topic by its topic key
package main
import(
"context"
novugo "github.com/novuhq/novu-go"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Topics.Retrieve(ctx, "<value>", nil)
if err != nil {
log.Fatal(err)
}
if res.GetTopicResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
topicKey |
string | ✔️ | The topic key |
idempotencyKey |
*string | ➖ | A header for idempotency purposes |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TopicsControllerGetTopicResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 414 | application/json |
apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.ErrorDto | 500 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Rename a topic by providing a new name
package main
import(
"context"
novugo "github.com/novuhq/novu-go"
"github.com/novuhq/novu-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Topics.Rename(ctx, "<value>", components.RenameTopicRequestDto{
Name: "<value>",
}, nil)
if err != nil {
log.Fatal(err)
}
if res.RenameTopicResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
topicKey |
string | ✔️ | The topic key |
renameTopicRequestDto |
components.RenameTopicRequestDto | ✔️ | N/A |
idempotencyKey |
*string | ➖ | A header for idempotency purposes |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TopicsControllerRenameTopicResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 414 | application/json |
apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.ErrorDto | 500 | application/json |
apierrors.APIError | 4XX, 5XX | */* |