This is still a work in progress, expect breaking changes until v1.0.0
go get -u github.com/tizz98/magicbell-go
package main
import (
"fmt"
"github.com/tizz98/magicbell-go"
)
func main() {
magicbell.Init(magicbell.Config{
APIKey: "my-key",
APISecret: "my-secret",
})
notification, _ := magicbell.CreateNotification(magicbell.CreateNotificationRequest{
Title: "Welcome to MagicBell",
Recipients: []magicbell.NotificationRecipient{
{Email: "[email protected]"},
{ExternalID: "some-id"},
},
Content: "The notification inbox for your product. Get started in minutes.",
CustomAttributes: map[string]interface{}{
"order": map[string]string{
"id": "1234567",
"title": "A title you can use in your templates",
},
},
ActionURL: "https://developer.magicbell.io",
Category: "new_message",
})
fmt.Printf("Created notification %s\n", notification.ID)
}
package main
import (
"fmt"
"github.com/tizz98/magicbell-go"
)
func main() {
magicbell.Init(magicbell.Config{
APIKey: "my-key",
APISecret: "my-secret",
})
user, _ := magicbell.CreateUser(magicbell.CreateUserRequest{
ExternalID: "56780",
Email: "[email protected]",
FirstName: "Hana",
LastName: "Mohan",
CustomAttributes: map[string]interface{}{
"plan": "enterprise",
"pricing_version": "v10",
"preferred_pronoun": "She",
},
})
fmt.Printf("%#v\n", user)
}
Download the latest release for your OS from https://github.com/tizz98/magicbell-go/releases
and add the binary to your PATH
.
mbctl --version
mbctl --help
This will save your API key and API secret in a config.yaml
file.
mbctl config init
Commands related to Notifications.
Send a notification to a set of users. Separate multiple recipients with a comma.
Any string with an @
will be considered an email address and sent to the API in that field.
mbctl notifications create \
--title="CLI test" \
--recipients [email protected],[email protected],my-external-id \
--content="Notification content" \
--action-url https://google.com \
--category new_message
Commands related to Users.
Generate and return a base64-encoded HMAC signature of the provided email. The HMAC key is the API secret.
mbctl users generate-hmac [email protected]