(Subscribers)
- List - Get subscribers
- Create - Create subscriber
- Get - Get subscriber
- Update - Update subscriber
- Delete - Delete subscriber
- CreateBulk - Bulk create subscribers
- UpdateOnlineStatus - Update subscriber online status
Returns a list of subscribers, could paginated using the page
and limit
query parameter
package main
import(
"context"
"os"
novugo "github.com/novuhq/novu-go"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
)
res, err := s.Subscribers.List(ctx, nil, novugo.Float64(10))
if err != nil {
log.Fatal(err)
}
if res.Object != nil {
for {
// handle items
res, err = res.Next()
if err != nil {
// handle error
}
if res == nil {
break
}
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
page |
*float64 | ➖ | N/A |
limit |
*float64 | ➖ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SubscribersControllerListSubscribersResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
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 main
import(
"context"
"os"
novugo "github.com/novuhq/novu-go"
"github.com/novuhq/novu-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
)
res, err := s.Subscribers.Create(ctx, components.CreateSubscriberRequestDto{
SubscriberID: "<id>",
})
if err != nil {
log.Fatal(err)
}
if res.SubscriberResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.CreateSubscriberRequestDto | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SubscribersControllerCreateSubscriberResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Get subscriber by your internal id used to identify the subscriber
package main
import(
"context"
"os"
novugo "github.com/novuhq/novu-go"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
)
res, err := s.Subscribers.Get(ctx, "<id>", nil)
if err != nil {
log.Fatal(err)
}
if res.SubscriberResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
subscriberID |
string | ✔️ | N/A |
includeTopics |
*bool | ➖ | Includes the topics associated with the subscriber |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SubscribersControllerGetSubscriberResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Used to update the subscriber entity with new information
package main
import(
"context"
"os"
novugo "github.com/novuhq/novu-go"
"github.com/novuhq/novu-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
)
res, err := s.Subscribers.Update(ctx, "<id>", components.UpdateSubscriberRequestDto{
Email: novugo.String("[email protected]"),
FirstName: novugo.String("John"),
LastName: novugo.String("Doe"),
Phone: novugo.String("+1234567890"),
Avatar: novugo.String("https://example.com/avatar.jpg"),
Locale: novugo.String("en-US"),
Data: map[string]any{
"preferences": map[string]any{
"notifications": true,
"theme": "dark",
},
"tags": []any{
"premium",
"newsletter",
},
},
})
if err != nil {
log.Fatal(err)
}
if res.SubscriberResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
subscriberID |
string | ✔️ | N/A |
updateSubscriberRequestDto |
components.UpdateSubscriberRequestDto | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SubscribersControllerUpdateSubscriberResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Deletes a subscriber entity from the Novu platform
package main
import(
"context"
"os"
novugo "github.com/novuhq/novu-go"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
)
res, err := s.Subscribers.Delete(ctx, "<id>")
if err != nil {
log.Fatal(err)
}
if res.DeleteSubscriberResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
subscriberID |
string | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SubscribersControllerRemoveSubscriberResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 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 main
import(
"context"
"os"
novugo "github.com/novuhq/novu-go"
"github.com/novuhq/novu-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
)
res, err := s.Subscribers.CreateBulk(ctx, components.BulkSubscriberCreateDto{
Subscribers: []components.CreateSubscriberRequestDto{
components.CreateSubscriberRequestDto{
SubscriberID: "<id>",
},
},
})
if err != nil {
log.Fatal(err)
}
if res.BulkCreateSubscriberResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
components.BulkSubscriberCreateDto | ✔️ | The request object to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SubscribersControllerBulkCreateSubscribersResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |
Used to update the subscriber isOnline flag.
package main
import(
"context"
"os"
novugo "github.com/novuhq/novu-go"
"github.com/novuhq/novu-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := novugo.New(
novugo.WithSecurity(os.Getenv("NOVU_API_KEY")),
)
res, err := s.Subscribers.UpdateOnlineStatus(ctx, "<id>", components.UpdateSubscriberOnlineFlagRequestDto{
IsOnline: true,
})
if err != nil {
log.Fatal(err)
}
if res.SubscriberResponseDto != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
subscriberID |
string | ✔️ | N/A |
updateSubscriberOnlineFlagRequestDto |
components.UpdateSubscriberOnlineFlagRequestDto | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SubscribersControllerUpdateSubscriberOnlineFlagResponse, error
Error Type | Status Code | Content Type |
---|---|---|
apierrors.ErrorDto | 400, 404, 409 | application/json |
apierrors.ValidationErrorDto | 422 | application/json |
apierrors.APIError | 4XX, 5XX | */* |