API (v2) Reference
Introduction
Base URL: https://api.magicbell.com/v2
For authentication, rate limits, and errors, please refer to the API documentation.
Create a broadcast
/broadcasts
Creates a new broadcast. When a broadcast is created, it generates individual notifications for relevant users within the project.
Request body
The timestamp when the broadcast was created.
The unique id for this broadcast.
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
The number of recipients that the broadcast was sent to.
The number of failures while processing the broadcast.
Show child attributesHide child attributes
Show child attributesHide child attributes
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/broadcasts"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
email := broadcasts.Email{
ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }),
Content: util.ToPointer("Content"),
Title: util.ToPointer("Title"),
}
inApp := broadcasts.InApp{
ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }),
Content: util.ToPointer("Content"),
Title: util.ToPointer("Title"),
}
mobilePush := broadcasts.MobilePush{
ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }),
Content: util.ToPointer("Content"),
Title: util.ToPointer("Title"),
}
sms := broadcasts.Sms{
ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }),
Content: util.ToPointer("Content"),
Title: util.ToPointer("Title"),
}
overridesChannels := broadcasts.OverridesChannels{
Email: &email,
InApp: &inApp,
MobilePush: &mobilePush,
Sms: &sms,
}
providers := broadcasts.Providers{
Apns: []byte{},
Expo: []byte{},
Fcm: []byte{},
Mailgun: []byte{},
Sendgrid: []byte{},
Ses: []byte{},
Slack: []byte{},
Teams: []byte{},
Twilio: []byte{},
WebPush: []byte{},
}
overrides := broadcasts.Overrides{
Channels: &overridesChannels,
Providers: &providers,
}
user := shared.User{
CreatedAt: util.ToPointer(util.Nullable[string]{ Value: "CreatedAt" }),
CustomAttributes: []byte{},
Email: util.ToPointer(util.Nullable[string]{ Value: "Email" }),
ExternalId: util.ToPointer(util.Nullable[string]{ Value: "ExternalId" }),
FirstName: util.ToPointer(util.Nullable[string]{ Value: "FirstName" }),
Id: util.ToPointer("Id"),
LastName: util.ToPointer(util.Nullable[string]{ Value: "LastName" }),
LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: "LastNotifiedAt" }),
LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: "LastSeenAt" }),
UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: "UpdatedAt" }),
}
errors := broadcasts.Errors{
Message: util.ToPointer("Message"),
}
statusStatus := broadcasts.STATUS_STATUS_ENQUEUED
summary := broadcasts.Summary{
Failures: util.ToPointer(int64(123)),
Total: util.ToPointer(int64(123)),
}
broadcastStatus := broadcasts.BroadcastStatus{
Errors: []broadcasts.Errors{errors},
Status: &statusStatus,
Summary: &summary,
}
request := broadcasts.Broadcast{
ActionUrl: util.ToPointer(util.Nullable[string]{ Value: "ActionUrl" }),
Category: util.ToPointer(util.Nullable[string]{ Value: "Category" }),
Content: util.ToPointer(util.Nullable[string]{ Value: "Content" }),
CreatedAt: util.ToPointer("CreatedAt"),
CustomAttributes: []byte{},
Id: util.ToPointer("Id"),
Overrides: &overrides,
Recipients: []shared.User{user},
Status: &broadcastStatus,
Title: util.ToPointer("Title"),
Topic: util.ToPointer(util.Nullable[string]{ Value: "Topic" }),
}
response, err := client.Broadcasts.CreateBroadcast(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "d1b3b3b3-3b3b-3b3b-3b3b-3b3b3b3b3b3b",
"title": "Hello, World!",
"content": "I come from broadcast",
"action_url": "https://example.com",
"category": "example",
"topic": "example",
"custom_attributes": {},
"recipients": [
{
"external_id": "83d987a-83fd034",
"email": "test@example.com",
"first_name": "Person",
"last_name": "Doe",
"custom_attributes": {
"plan": "enterprise",
"pricing_version": "v10",
"preferred_pronoun": "They"
},
"phone_numbers": ["+1 5005550001"]
}
],
"overrides": {}
}
Fetch a broadcast
/broadcasts/{broadcast_id}
Retrieves detailed information about a specific broadcast by its ID. Includes the broadcast's configuration and current status.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Broadcasts.FetchBroadcast(context.Background(), "broadcastId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "d1b3b3b3-3b3b-3b3b-3b3b-3b3b3b3b3b3b",
"title": "Hello, World!",
"content": "I come from broadcast",
"action_url": "https://example.com",
"category": "example",
"topic": "example",
"custom_attributes": {},
"recipients": [
{
"external_id": "83d987a-83fd034",
"email": "test@example.com",
"first_name": "Person",
"last_name": "Doe",
"custom_attributes": {
"plan": "enterprise",
"pricing_version": "v10",
"preferred_pronoun": "They"
},
"phone_numbers": ["+1 5005550001"]
}
],
"overrides": {}
}
List all broadcasts
/broadcasts
Retrieves a paginated list of broadcasts for the project. Returns basic information about each broadcast including its creation time and status.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/broadcasts"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := broadcasts.ListBroadcastsRequestParams{
}
response, err := client.Broadcasts.ListBroadcasts(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"id": "d1b3b3b3-3b3b-3b3b-3b3b-3b3b3b3b3b3b",
"title": "Hello, World!",
"content": "I come from broadcast",
"action_url": "https://example.com",
"category": "example",
"topic": "example",
"custom_attributes": {},
"recipients": [
{
"external_id": "83d987a-83fd034",
"email": "test@example.com",
"first_name": "Person",
"last_name": "Doe",
"custom_attributes": {
"plan": "enterprise",
"pricing_version": "v10",
"preferred_pronoun": "They"
},
"phone_numbers": ["+1 5005550001"]
}
],
"overrides": {}
}
],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save an APNs token
/channels/mobile_push/apns/tokens
Saves the APNs token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel.
Request body
(Optional) The bundle identifier of the application that is registering this token. Use this field to override the default identifier specified in the projects APNs integration.
(Optional) The APNs environment the token is registered for. If none is provided we assume the token is used in production
.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
apnsTokenPayloadInstallationId := channels.APNS_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT
request := channels.ApnsTokenPayload{
AppId: util.ToPointer("AppId"),
DeviceToken: util.ToPointer("DeviceToken"),
InstallationId: &apnsTokenPayloadInstallationId,
}
response, err := client.Channels.SaveApnsToken(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"installation_id": "development"
}
Fetch an APNs token
/channels/mobile_push/apns/tokens/{token_id}
Fetches details of a specific APNs token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchApnsToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"installation_id": "development",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an APNs token
/channels/mobile_push/apns/tokens/{token_id}
Deletes one of the authenticated user's APNs tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteApnsToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List all APNs tokens
/channels/mobile_push/apns/tokens
Lists all APNs tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListApnsTokensRequestParams{
}
response, err := client.Channels.ListApnsTokens(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"installation_id": "development",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save an Expo token
/channels/mobile_push/expo/tokens
Saves the Expo token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel.
Request body
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := channels.ExpoTokenPayload{
DeviceToken: util.ToPointer("DeviceToken"),
}
response, err := client.Channels.SaveExpoToken(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"device_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]"
}
Fetch an Expo token
/channels/mobile_push/expo/tokens/{token_id}
Fetches details of a specific Expo token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchExpoToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an Expo token
/channels/mobile_push/expo/tokens/{token_id}
Deletes one of the authenticated user's Expo tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteExpoToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List all Expo tokens
/channels/mobile_push/expo/tokens
Lists all Expo tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListExpoTokensRequestParams{
}
response, err := client.Channels.ListExpoTokens(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a FCM token
/channels/mobile_push/fcm/tokens
Saves the FCM token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel.
Request body
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
fcmTokenPayloadInstallationId := channels.FCM_TOKEN_PAYLOAD_INSTALLATION_ID_DEVELOPMENT
request := channels.FcmTokenPayload{
DeviceToken: util.ToPointer("DeviceToken"),
InstallationId: &fcmTokenPayloadInstallationId,
}
response, err := client.Channels.SaveFcmToken(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"installation_id": "development"
}
Fetch a FCM token
/channels/mobile_push/fcm/tokens/{token_id}
Fetches details of a specific FCM token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchFcmToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"installation_id": "development",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete a FCM token
/channels/mobile_push/fcm/tokens/{token_id}
Deletes one of the authenticated user's FCM tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteFcmToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List all FCM tokens
/channels/mobile_push/fcm/tokens
Lists all FCM tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListFcmTokensRequestParams{
}
response, err := client.Channels.ListFcmTokens(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"installation_id": "development",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save an Inbox token
/channels/in_app/inbox/tokens
Saves the Inbox token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel.
Request body
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := channels.InboxToken{
ConnectionId: util.ToPointer(util.Nullable[string]{ Value: "ConnectionId" }),
Token: util.ToPointer("Token"),
}
response, err := client.Channels.SaveInboxToken(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt"
}
Fetch an Inbox token
/channels/in_app/inbox/tokens/{token_id}
Fetches details of a specific Inbox token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchInboxToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an Inbox token
/channels/in_app/inbox/tokens/{token_id}
Deletes one of the authenticated user's Inbox tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteInboxToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List all Inbox tokens
/channels/in_app/inbox/tokens
Lists all Inbox tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListInboxTokensRequestParams{
}
response, err := client.Channels.ListInboxTokens(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a Slack token
/channels/slack/tokens
Saves the Slack token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel.
Request body
Show child attributesHide child attributes
Obtained directly from the incoming_webhook object in the installation response from the Slack API.
Show child attributesHide child attributes
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
slackTokenPayloadOauth := channels.SlackTokenPayloadOauth{
ChannelId: util.ToPointer("ChannelId"),
InstallationId: util.ToPointer("InstallationId"),
Scope: util.ToPointer("Scope"),
}
slackTokenPayloadWebhook := channels.SlackTokenPayloadWebhook{
Url: util.ToPointer("Url"),
}
request := channels.SlackTokenPayload{
Oauth: &slackTokenPayloadOauth,
Webhook: &slackTokenPayloadWebhook,
}
response, err := client.Channels.SaveSlackToken(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"webhook": {
"url": "https://example.com/webhook"
}
}
Fetch a Slack token
/channels/slack/tokens/{token_id}
Fetches details of a specific Slack token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchSlackToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z",
"webhook": {
"url": "https://example.com/webhook"
}
}
Delete a Slack token
/channels/slack/tokens/{token_id}
Deletes one of the authenticated user's Slack tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteSlackToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List all Slack tokens
/channels/slack/tokens
Lists all Slack tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListSlackTokensRequestParams{
}
response, err := client.Channels.ListSlackTokens(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z",
"webhook": {
"url": "https://example.com/webhook"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a Teams token
/channels/teams/tokens
Saves the Teams token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel.
Request body
Show child attributesHide child attributes
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
teamsTokenPayloadWebhook := channels.TeamsTokenPayloadWebhook{
Url: util.ToPointer("Url"),
}
request := channels.TeamsTokenPayload{
Webhook: &teamsTokenPayloadWebhook,
}
response, err := client.Channels.SaveTeamsToken(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
Fetch a Teams token
/channels/teams/tokens/{token_id}
Fetches details of a specific Teams token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchTeamsToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete a Teams token
/channels/teams/tokens/{token_id}
Deletes one of the authenticated user's Teams tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteTeamsToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List all Teams tokens
/channels/teams/tokens
Lists all Teams tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListTeamsTokensRequestParams{
}
response, err := client.Channels.ListTeamsTokens(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a Web Push token
/channels/web_push/tokens
Saves the Web Push token for the authenticated user. This token serves as a credential for accessing channel-specific functionality. Each token is unique to the user and channel combination, allowing for direct communication with the user via the channel.
Request body
The push subscription URL obtained from PushSubscription.endpoint after calling registration.pushManager.subscribe(). This is the unique URL for this device that push messages will be sent to.
The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription.
Show child attributesHide child attributes
The authentication secret obtained from PushSubscription.getKey('auth'). Used to encrypt push messages for this subscription.
The P-256 ECDH public key obtained from PushSubscription.getKey('p256dh'). Used to encrypt push messages for this subscription.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/shared"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
webPushTokenPayloadKeys := shared.WebPushTokenPayloadKeys{
Auth: util.ToPointer("Auth"),
P256dh: util.ToPointer("P256dh"),
}
request := shared.WebPushTokenPayload{
Endpoint: util.ToPointer("Endpoint"),
Keys: &webPushTokenPayloadKeys,
}
response, err := client.Channels.SaveWebPushToken(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"endpoint": "https://fcm.googleapis.com/fcm/send/fZhR0fsr0zw:APA91bE4pM-qo1KBJDU_Zp2N9nDP-Jdmwugm-v4KNL_NlJvYCrJeJUzPXmMyAXqAE0m6BFOrkSWT0ArGbUjEEpxQEYZLado8JeW1PZA5CHB8R6C7HT6-MD6Qs8ZaCn8_ffLGGU7WuvtN",
"keys": {
"p256dh": "BICAe4KtLhhPNFvynlqMRxjvpRnr94881QeuTCr8kCwJf-Fssj3FLIlnfFMjj7T1yNg5l6cn14350323_NSGZh0",
"auth": "GoIO2ulhtQuyBM64lZuFuw"
}
}
Fetch a Web Push token
/channels/web_push/tokens/{token_id}
Fetches details of a specific Web Push token belonging to the authenticated user. Returns information about the token's status, creation date, and any associated metadata. Users can only access their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchWebPushToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"endpoint": "https://fcm.googleapis.com/fcm/send/fZhR0fsr0zw:APA91bE4pM-qo1KBJDU_Zp2N9nDP-Jdmwugm-v4KNL_NlJvYCrJeJUzPXmMyAXqAE0m6BFOrkSWT0ArGbUjEEpxQEYZLado8JeW1PZA5CHB8R6C7HT6-MD6Qs8ZaCn8_ffLGGU7WuvtN",
"id": "123",
"keys": {
"auth": "GoIO2ulhtQuyBM64lZuFuw",
"p256dh": "BICAe4KtLhhPNFvynlqMRxjvpRnr94881QeuTCr8kCwJf-Fssj3FLIlnfFMjj7T1yNg5l6cn14350323_NSGZh0"
},
"updated_at": "2021-01-01T00:00:00Z"
}
Delete a Web Push token
/channels/web_push/tokens/{token_id}
Deletes one of the authenticated user's Web Push tokens. This permanently invalidates the specified token, preventing it from being used for future channel access. This action cannot be undone. Users can only revoke their own tokens.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteWebPushToken(context.Background(), "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List all Web Push tokens
/channels/web_push/tokens
Lists all Web Push tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListWebPushTokensRequestParams{
}
response, err := client.Channels.ListWebPushTokens(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"endpoint": "https://fcm.googleapis.com/fcm/send/fZhR0fsr0zw:APA91bE4pM-qo1KBJDU_Zp2N9nDP-Jdmwugm-v4KNL_NlJvYCrJeJUzPXmMyAXqAE0m6BFOrkSWT0ArGbUjEEpxQEYZLado8JeW1PZA5CHB8R6C7HT6-MD6Qs8ZaCn8_ffLGGU7WuvtN",
"id": "123",
"keys": {
"auth": "GoIO2ulhtQuyBM64lZuFuw",
"p256dh": "BICAe4KtLhhPNFvynlqMRxjvpRnr94881QeuTCr8kCwJf-Fssj3FLIlnfFMjj7T1yNg5l6cn14350323_NSGZh0"
},
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Fetch an event
/events/{event_id}
Fetches a project event by its ID.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Events.FetchEvent(context.Background(), "eventId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"type": "example_type",
"timestamp": "2021-01-01T00:00:00Z"
}
List all events
/events
Retrieves a paginated list of events for the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/events"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := events.ListEventsRequestParams{
}
response, err := client.Events.ListEvents(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"id": "123",
"type": "example_type",
"timestamp": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save an APNs integration
/integrations/apns
Updates or creates the APNs integration for the project.
Request body
The default bundle identifier of the application that is configured with this project. It can be overriden on a per token basis, when registering device tokens.
The APNs certificate in P8 format. Generate it at developer.apple.com with the 'Apple Push Notification service (APNs)' option selected.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
badge := integrations.BADGE_UNREAD
payloadVersion := integrations.PAYLOAD_VERSION_1
request := integrations.ApnsConfigPayload{
AppId: util.ToPointer("AppId"),
Badge: &badge,
Certificate: util.ToPointer("Certificate"),
KeyId: util.ToPointer("KeyId"),
PayloadVersion: &payloadVersion,
TeamId: util.ToPointer("TeamId"),
}
response, err := client.Integrations.SaveApnsIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"app_id": "com.example.myapp",
"certificate": "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgHnr4B2P+by++FGu/th0a44E8chJl5v5Vo4gq0YHw6e6gCgYIKoZIzj0DAQehRANCAARCg1MRibnfyeX5mx6+Rtfzzn7UhJP/oaqL4RzSmDuTsd3BTX33cuQ0gWHe20R2m1bLAkI1wrp+zbWOlAOAD7KX\n-----END PRIVATE KEY-----",
"key_id": "ABCD1234EF",
"team_id": "ABCD1234EF",
"badge": "unread"
}
Delete an APNs integration
/integrations/apns
Deletes the APNs integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteApnsIntegrationRequestParams{
}
response, err := client.Integrations.DeleteApnsIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all APNs integrations
/integrations/apns
Retrieves the current APNs integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListApnsIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"app_id": "com.example.myapp",
"certificate": "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgHnr4B2P+by++FGu/th0a44E8chJl5v5Vo4gq0YHw6e6gCgYIKoZIzj0DAQehRANCAARCg1MRibnfyeX5mx6+Rtfzzn7UhJP/oaqL4RzSmDuTsd3BTX33cuQ0gWHe20R2m1bLAkI1wrp+zbWOlAOAD7KX\n-----END PRIVATE KEY-----",
"key_id": "ABCD1234EF",
"team_id": "ABCD1234EF",
"badge": "unread"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save an Expo integration
/integrations/expo
Updates or creates the Expo integration for the project.
Request body
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := integrations.ExpoConfigPayload{
AccessToken: util.ToPointer("AccessToken"),
}
response, err := client.Integrations.SaveExpoIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"access_token": "expo_access_token"
}
Delete an Expo integration
/integrations/expo
Deletes the Expo integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteExpoIntegrationRequestParams{
}
response, err := client.Integrations.DeleteExpoIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all Expo integrations
/integrations/expo
Retrieves the current Expo integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListExpoIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"access_token": "expo_access_token"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a FCM integration
/integrations/fcm
Updates or creates the FCM integration for the project.
Request body
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
type_ := integrations.TYPE_SERVICE_ACCOUNT
request := integrations.FcmConfigPayload{
AuthProviderX509CertUrl: util.ToPointer("AuthProviderX509CertUrl"),
AuthUri: util.ToPointer("AuthUri"),
ClientEmail: util.ToPointer("ClientEmail"),
ClientId: util.ToPointer("ClientId"),
ClientX509CertUrl: util.ToPointer("ClientX509CertUrl"),
PrivateKey: util.ToPointer("PrivateKey"),
PrivateKeyId: util.ToPointer("PrivateKeyId"),
ProjectId: util.ToPointer("ProjectId"),
TokenUri: util.ToPointer("TokenUri"),
Type_: &type_,
UniverseDomain: util.ToPointer("UniverseDomain"),
}
response, err := client.Integrations.SaveFcmIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"type": "service_account",
"project_id": "platform-development",
"private_key_id": "1935e74178f6ef0bbc23fb3538255f8281093bf2",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC7/GBHM4AK4/8c\nZyvJfdzjBzfA48tV9T3N4hBCb4E66jIz+oztH9oSngEfIVO/L1dWjK1OlN0cqJ0f\nQaKq1eycSjmwfTR3HGNjQQyoGQ4BFBdyqT5rRDDZLPI2LoR0dtQXcBtiFpJF2t8e\niDmpl3d/ipuKMtBRzjYPqzP0qv3YkPmw2v5FqKK9EIaHRtOhd2R28F5FE+kF1dvB\nt7fEeVtKcQJcSwDUQ8HEshlWSx6azGd4jxf9jHRXWumXYfTA6NMA7EUTDJVus3vU\ny9MCv2KwZO/dzlQygY0BM9FHPSzZRIiHUx+DH6gYl2uWJatluHz58lj3r5mo/Ssc\nyP3TrqOnAgMBAAECggEAWAnDe0UCt9b8QGyPBK/V1VspgMQOE+UlOzkenUaEUreg\nqFg0TM8ofaSS6OXeR0DgGdALUCyGeyf6YcuG55QFWlKmvuF8QzY/05mA2G7XcKjc\nrF3Xtju61tLmYnqZnMOT46AkquTgPyfYa3+n5aVimRAsdOYESvOUvPTUgcbc2GGK\nC2h2MUCoRKuhzbGx847XJmINRE+xaht4hDMhzhMBVrgGGyQ3sIdbCxpbiQR6QH2H\npITrSnd4hlKRPREWS/D4FUKP/ucXdORP9SUi0R64NRZ3GvT1HvpVZ9fOXwIACdAG\n9fpIQbsmIgxhgZ5ZjuGz/nFi2KQ2Y8rEycQmnHd4QQKBgQD4LVFL93E4qwr7Eruj\nFjyxGYYi2PhVxvrpiSD6ziK3HUjAxat6OcoElJx7WEFWHmi7KRgehqcl40A8Coav\n9DGBwnSM2AYKgzOqMqzjK71TFOQsJdGEYThnhiL2FoQeptgskVS7J9MMBPTnyl7D\nYObINwGbg9auVp66rj5W+dymZwKBgQDB6VdpxJpU9hXBW+8nJESduhzpYiHoe1kN\nyka90dQDOe2b/R7bnF1Ggte6Ll1dMs3xLhN1Mm2XTcX2zmzM15C0E4+1t1LXXzAo\nO2P+riEmCIUc1i0yNMVgEKXiOBBYgKauE3fT88c4dw2JAT0QlifJ0h8kRPNhUaq9\nespjleNQwQKBgHUzwZ7knn2qmSb1M9PTHppseWJfoPexXrGHZyHK064ykDcpos+4\nFuWO4U+G4GQxPDiXMaLI6IsGBUHVnsHdyruC/9O7+S5hw7Zu9CLcdy6TQSZwPcAM\nwbxyJnSdMYvgM1roz2ELb6nPdXE5qwMN8i8/euzcmDgBBDkZLKuamE+lAoGBAKb7\nvd7DAvPvBkUAWi2mub/pqUQA0ZpVvhZ1/f0wWBZ/J/KQQqZzPI+f1Q3rJ1M+kMIE\nH5Vo257TxooGsQKlD2NDBRpCx//XZK0Al9eVM86Av8BZX4pAj0dujqsEBG9yOhbl\nhObsor4pJ2q3ulIyPAk7/L1K8xr3LMUGnIqtZJcBAoGAEQffqGbnaOG8Ue3++bLP\nN6XlAyt5UajAd1CycIHgDvbW0CkWoI70Bg7QNqMYJe6DareH4vRpdB3tw6zNP7qN\n0Bd04L8+zUYN+VqNJ70d7Xn+k2rY7STlgU3vwOzHFwu4wK2A7e+aAZ8AjC+Sr0ZM\nps+wuWO8MN5yQTBZvAEIfQs=\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-qwhtp@platform-development.iam.gserviceaccount.com",
"client_id": "117893100789081023083",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-qwhtp%40magicbell-development.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
Delete a FCM integration
/integrations/fcm
Deletes the FCM integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteFcmIntegrationRequestParams{
}
response, err := client.Integrations.DeleteFcmIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all FCM integrations
/integrations/fcm
Retrieves the current FCM integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListFcmIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"type": "service_account",
"project_id": "platform-development",
"private_key_id": "1935e74178f6ef0bbc23fb3538255f8281093bf2",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC7/GBHM4AK4/8c\nZyvJfdzjBzfA48tV9T3N4hBCb4E66jIz+oztH9oSngEfIVO/L1dWjK1OlN0cqJ0f\nQaKq1eycSjmwfTR3HGNjQQyoGQ4BFBdyqT5rRDDZLPI2LoR0dtQXcBtiFpJF2t8e\niDmpl3d/ipuKMtBRzjYPqzP0qv3YkPmw2v5FqKK9EIaHRtOhd2R28F5FE+kF1dvB\nt7fEeVtKcQJcSwDUQ8HEshlWSx6azGd4jxf9jHRXWumXYfTA6NMA7EUTDJVus3vU\ny9MCv2KwZO/dzlQygY0BM9FHPSzZRIiHUx+DH6gYl2uWJatluHz58lj3r5mo/Ssc\nyP3TrqOnAgMBAAECggEAWAnDe0UCt9b8QGyPBK/V1VspgMQOE+UlOzkenUaEUreg\nqFg0TM8ofaSS6OXeR0DgGdALUCyGeyf6YcuG55QFWlKmvuF8QzY/05mA2G7XcKjc\nrF3Xtju61tLmYnqZnMOT46AkquTgPyfYa3+n5aVimRAsdOYESvOUvPTUgcbc2GGK\nC2h2MUCoRKuhzbGx847XJmINRE+xaht4hDMhzhMBVrgGGyQ3sIdbCxpbiQR6QH2H\npITrSnd4hlKRPREWS/D4FUKP/ucXdORP9SUi0R64NRZ3GvT1HvpVZ9fOXwIACdAG\n9fpIQbsmIgxhgZ5ZjuGz/nFi2KQ2Y8rEycQmnHd4QQKBgQD4LVFL93E4qwr7Eruj\nFjyxGYYi2PhVxvrpiSD6ziK3HUjAxat6OcoElJx7WEFWHmi7KRgehqcl40A8Coav\n9DGBwnSM2AYKgzOqMqzjK71TFOQsJdGEYThnhiL2FoQeptgskVS7J9MMBPTnyl7D\nYObINwGbg9auVp66rj5W+dymZwKBgQDB6VdpxJpU9hXBW+8nJESduhzpYiHoe1kN\nyka90dQDOe2b/R7bnF1Ggte6Ll1dMs3xLhN1Mm2XTcX2zmzM15C0E4+1t1LXXzAo\nO2P+riEmCIUc1i0yNMVgEKXiOBBYgKauE3fT88c4dw2JAT0QlifJ0h8kRPNhUaq9\nespjleNQwQKBgHUzwZ7knn2qmSb1M9PTHppseWJfoPexXrGHZyHK064ykDcpos+4\nFuWO4U+G4GQxPDiXMaLI6IsGBUHVnsHdyruC/9O7+S5hw7Zu9CLcdy6TQSZwPcAM\nwbxyJnSdMYvgM1roz2ELb6nPdXE5qwMN8i8/euzcmDgBBDkZLKuamE+lAoGBAKb7\nvd7DAvPvBkUAWi2mub/pqUQA0ZpVvhZ1/f0wWBZ/J/KQQqZzPI+f1Q3rJ1M+kMIE\nH5Vo257TxooGsQKlD2NDBRpCx//XZK0Al9eVM86Av8BZX4pAj0dujqsEBG9yOhbl\nhObsor4pJ2q3ulIyPAk7/L1K8xr3LMUGnIqtZJcBAoGAEQffqGbnaOG8Ue3++bLP\nN6XlAyt5UajAd1CycIHgDvbW0CkWoI70Bg7QNqMYJe6DareH4vRpdB3tw6zNP7qN\n0Bd04L8+zUYN+VqNJ70d7Xn+k2rY7STlgU3vwOzHFwu4wK2A7e+aAZ8AjC+Sr0ZM\nps+wuWO8MN5yQTBZvAEIfQs=\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-qwhtp@platform-development.iam.gserviceaccount.com",
"client_id": "117893100789081023083",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-qwhtp%40magicbell-development.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save an Inbox installation
/integrations/inbox/installations
Creates a new installation of a Inbox integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration.
Request body
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
images := integrations.Images{
EmptyInboxUrl: util.ToPointer("EmptyInboxUrl"),
}
banner := integrations.Banner{
BackgroundColor: util.ToPointer("BackgroundColor"),
BackgroundOpacity: util.ToPointer(float64(123)),
FontSize: util.ToPointer("FontSize"),
TextColor: util.ToPointer("TextColor"),
}
dialog := integrations.Dialog{
AccentColor: util.ToPointer("AccentColor"),
BackgroundColor: util.ToPointer("BackgroundColor"),
TextColor: util.ToPointer("TextColor"),
}
footer := integrations.Footer{
BackgroundColor: util.ToPointer("BackgroundColor"),
BorderRadius: util.ToPointer("BorderRadius"),
FontSize: util.ToPointer("FontSize"),
TextColor: util.ToPointer("TextColor"),
}
header := integrations.Header{
BackgroundColor: util.ToPointer("BackgroundColor"),
BorderRadius: util.ToPointer("BorderRadius"),
FontFamily: util.ToPointer("FontFamily"),
FontSize: util.ToPointer("FontSize"),
TextColor: util.ToPointer("TextColor"),
}
icon := integrations.Icon{
BorderColor: util.ToPointer("BorderColor"),
Width: util.ToPointer("Width"),
}
defaultHover := integrations.DefaultHover{
BackgroundColor: util.ToPointer("BackgroundColor"),
}
defaultState := integrations.DefaultState{
Color: util.ToPointer("Color"),
}
default_ := integrations.Default_{
BackgroundColor: util.ToPointer("BackgroundColor"),
BorderRadius: util.ToPointer("BorderRadius"),
FontFamily: util.ToPointer("FontFamily"),
FontSize: util.ToPointer("FontSize"),
Hover: &defaultHover,
Margin: util.ToPointer("Margin"),
State: &defaultState,
TextColor: util.ToPointer("TextColor"),
}
unreadHover := integrations.UnreadHover{
BackgroundColor: util.ToPointer("BackgroundColor"),
}
unreadState := integrations.UnreadState{
Color: util.ToPointer("Color"),
}
unread := integrations.Unread{
BackgroundColor: util.ToPointer("BackgroundColor"),
Hover: &unreadHover,
State: &unreadState,
TextColor: util.ToPointer("TextColor"),
}
unseenHover := integrations.UnseenHover{
BackgroundColor: util.ToPointer("BackgroundColor"),
}
unseenState := integrations.UnseenState{
Color: util.ToPointer("Color"),
}
unseen := integrations.Unseen{
BackgroundColor: util.ToPointer("BackgroundColor"),
Hover: &unseenHover,
State: &unseenState,
TextColor: util.ToPointer("TextColor"),
}
themeNotification := integrations.ThemeNotification{
Default_: &default_,
Unread: &unread,
Unseen: &unseen,
}
unseenBadge := integrations.UnseenBadge{
BackgroundColor: util.ToPointer("BackgroundColor"),
}
theme := integrations.Theme{
Banner: &banner,
Dialog: &dialog,
Footer: &footer,
Header: &header,
Icon: &icon,
Notification: &themeNotification,
UnseenBadge: &unseenBadge,
}
request := integrations.InboxConfigPayload{
Images: &images,
Locale: util.ToPointer(util.Nullable[string]{ Value: "Locale" }),
Theme: &theme,
}
response, err := client.Integrations.SaveInboxInstallation(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"images": { "emptyInboxUrl": "" },
"locale": "de",
"theme": {
"banner": {
"backgroundColor": "#F8F5FF",
"fontSize": "14px",
"textColor": "#3A424D"
},
"dialog": {
"accentColor": "#5225C1",
"backgroundColor": "#F5F5F5",
"textColor": "#313131"
},
"footer": {
"backgroundColor": "#FFFFFF",
"borderRadius": "16px",
"fontFamily": "inherit",
"fontSize": "15px",
"textColor": "#5225C1"
},
"header": {
"backgroundColor": "#FFFFFF",
"borderRadius": "16px",
"fontFamily": "inherit",
"fontSize": "15px",
"textColor": "#5225C1"
},
"icon": { "borderColor": "#EDEDEF", "width": "24px" },
"unseenBadge": { "backgroundColor": "#F80808" }
}
}
Start an Inbox installation
/integrations/inbox/installations/start
Initiates the installation flow for an Inbox integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.StartInboxInstallation(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"images": { "emptyInboxUrl": "" },
"locale": "de",
"theme": {
"banner": {
"backgroundColor": "#F8F5FF",
"fontSize": "14px",
"textColor": "#3A424D"
},
"dialog": {
"accentColor": "#5225C1",
"backgroundColor": "#F5F5F5",
"textColor": "#313131"
},
"footer": {
"backgroundColor": "#FFFFFF",
"borderRadius": "16px",
"fontFamily": "inherit",
"fontSize": "15px",
"textColor": "#5225C1"
},
"header": {
"backgroundColor": "#FFFFFF",
"borderRadius": "16px",
"fontFamily": "inherit",
"fontSize": "15px",
"textColor": "#5225C1"
},
"icon": { "borderColor": "#EDEDEF", "width": "24px" },
"unseenBadge": { "backgroundColor": "#F80808" }
}
}
Save an Inbox integration
/integrations/inbox
Updates or creates the Inbox integration for the project.
Request body
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
images := integrations.Images{
EmptyInboxUrl: util.ToPointer("EmptyInboxUrl"),
}
banner := integrations.Banner{
BackgroundColor: util.ToPointer("BackgroundColor"),
BackgroundOpacity: util.ToPointer(float64(123)),
FontSize: util.ToPointer("FontSize"),
TextColor: util.ToPointer("TextColor"),
}
dialog := integrations.Dialog{
AccentColor: util.ToPointer("AccentColor"),
BackgroundColor: util.ToPointer("BackgroundColor"),
TextColor: util.ToPointer("TextColor"),
}
footer := integrations.Footer{
BackgroundColor: util.ToPointer("BackgroundColor"),
BorderRadius: util.ToPointer("BorderRadius"),
FontSize: util.ToPointer("FontSize"),
TextColor: util.ToPointer("TextColor"),
}
header := integrations.Header{
BackgroundColor: util.ToPointer("BackgroundColor"),
BorderRadius: util.ToPointer("BorderRadius"),
FontFamily: util.ToPointer("FontFamily"),
FontSize: util.ToPointer("FontSize"),
TextColor: util.ToPointer("TextColor"),
}
icon := integrations.Icon{
BorderColor: util.ToPointer("BorderColor"),
Width: util.ToPointer("Width"),
}
defaultHover := integrations.DefaultHover{
BackgroundColor: util.ToPointer("BackgroundColor"),
}
defaultState := integrations.DefaultState{
Color: util.ToPointer("Color"),
}
default_ := integrations.Default_{
BackgroundColor: util.ToPointer("BackgroundColor"),
BorderRadius: util.ToPointer("BorderRadius"),
FontFamily: util.ToPointer("FontFamily"),
FontSize: util.ToPointer("FontSize"),
Hover: &defaultHover,
Margin: util.ToPointer("Margin"),
State: &defaultState,
TextColor: util.ToPointer("TextColor"),
}
unreadHover := integrations.UnreadHover{
BackgroundColor: util.ToPointer("BackgroundColor"),
}
unreadState := integrations.UnreadState{
Color: util.ToPointer("Color"),
}
unread := integrations.Unread{
BackgroundColor: util.ToPointer("BackgroundColor"),
Hover: &unreadHover,
State: &unreadState,
TextColor: util.ToPointer("TextColor"),
}
unseenHover := integrations.UnseenHover{
BackgroundColor: util.ToPointer("BackgroundColor"),
}
unseenState := integrations.UnseenState{
Color: util.ToPointer("Color"),
}
unseen := integrations.Unseen{
BackgroundColor: util.ToPointer("BackgroundColor"),
Hover: &unseenHover,
State: &unseenState,
TextColor: util.ToPointer("TextColor"),
}
notification := integrations.Notification{
Default_: &default_,
Unread: &unread,
Unseen: &unseen,
}
unseenBadge := integrations.UnseenBadge{
BackgroundColor: util.ToPointer("BackgroundColor"),
}
theme := integrations.Theme{
Banner: &banner,
Dialog: &dialog,
Footer: &footer,
Header: &header,
Icon: &icon,
Notification: ¬ification,
UnseenBadge: &unseenBadge,
}
request := integrations.InboxConfigPayload{
Images: &images,
Locale: util.ToPointer(util.Nullable[string]{ Value: "Locale" }),
Theme: &theme,
}
response, err := client.Integrations.SaveInboxIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"images": { "emptyInboxUrl": "" },
"locale": "de",
"theme": {
"banner": {
"backgroundColor": "#F8F5FF",
"fontSize": "14px",
"textColor": "#3A424D"
},
"dialog": {
"accentColor": "#5225C1",
"backgroundColor": "#F5F5F5",
"textColor": "#313131"
},
"footer": {
"backgroundColor": "#FFFFFF",
"borderRadius": "16px",
"fontFamily": "inherit",
"fontSize": "15px",
"textColor": "#5225C1"
},
"header": {
"backgroundColor": "#FFFFFF",
"borderRadius": "16px",
"fontFamily": "inherit",
"fontSize": "15px",
"textColor": "#5225C1"
},
"icon": { "borderColor": "#EDEDEF", "width": "24px" },
"unseenBadge": { "backgroundColor": "#F80808" }
}
}
Delete an Inbox integration
/integrations/inbox
Deletes the Inbox integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteInboxIntegrationRequestParams{
}
response, err := client.Integrations.DeleteInboxIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all Inbox integrations
/integrations/inbox
Retrieves the current Inbox integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListInboxIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"images": { "emptyInboxUrl": "" },
"locale": "de",
"theme": {
"banner": {
"backgroundColor": "#F8F5FF",
"fontSize": "14px",
"textColor": "#3A424D"
},
"dialog": {
"accentColor": "#5225C1",
"backgroundColor": "#F5F5F5",
"textColor": "#313131"
},
"footer": {
"backgroundColor": "#FFFFFF",
"borderRadius": "16px",
"fontFamily": "inherit",
"fontSize": "15px",
"textColor": "#5225C1"
},
"header": {
"backgroundColor": "#FFFFFF",
"borderRadius": "16px",
"fontFamily": "inherit",
"fontSize": "15px",
"textColor": "#5225C1"
},
"icon": { "borderColor": "#EDEDEF", "width": "24px" },
"unseenBadge": { "backgroundColor": "#F80808" }
}
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a Mailgun integration
/integrations/mailgun
Updates or creates the Mailgun integration for the project.
Request body
Show child attributesHide child attributes
The email address to send from
The name to send from
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
mailgunConfigPayloadFrom := integrations.MailgunConfigPayloadFrom{
Email: util.ToPointer("Email"),
Name: util.ToPointer(util.Nullable[string]{ Value: "Name" }),
}
region := integrations.REGION_US
request := integrations.MailgunConfigPayload{
ApiKey: util.ToPointer("ApiKey"),
Domain: util.ToPointer("Domain"),
From: &mailgunConfigPayloadFrom,
Region: ®ion,
}
response, err := client.Integrations.SaveMailgunIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"from": {
"name": "Example",
"email": "hello@example.com"
},
"api_key": "key-3ax6xnjp29jd6fds4gc373sgvjxteol0",
"region": "us",
"domain": "example.com"
}
Delete a Mailgun integration
/integrations/mailgun
Deletes the Mailgun integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteMailgunIntegrationRequestParams{
}
response, err := client.Integrations.DeleteMailgunIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all Mailgun integrations
/integrations/mailgun
Retrieves the current Mailgun integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListMailgunIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"from": {
"name": "Example",
"email": "hello@example.com"
},
"api_key": "key-3ax6xnjp29jd6fds4gc373sgvjxteol0",
"region": "us",
"domain": "example.com"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a Ping Email integration
/integrations/ping_email
Updates or creates the Ping Email integration for the project.
Request body
URL to ping
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := integrations.PingConfigPayload{
Url: util.ToPointer("Url"),
}
response, err := client.Integrations.SavePingEmailIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"url": "https://example.com/webhook"
}
Delete a Ping Email integration
/integrations/ping_email
Deletes the Ping Email integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeletePingEmailIntegrationRequestParams{
}
response, err := client.Integrations.DeletePingEmailIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all Ping Email integrations
/integrations/ping_email
Retrieves the current Ping Email integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListPingEmailIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"url": "https://example.com/webhook"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a SendGrid integration
/integrations/sendgrid
Updates or creates the SendGrid integration for the project.
Request body
The API key for Sendgrid
Show child attributesHide child attributes
The email address to send from
The name to send from
Show child attributesHide child attributes
The email address to reply to
The name to reply to
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
sendgridConfigPayloadFrom := integrations.SendgridConfigPayloadFrom{
Email: util.ToPointer("Email"),
Name: util.ToPointer(util.Nullable[string]{ Value: "Name" }),
}
replyTo := integrations.ReplyTo{
Email: util.ToPointer("Email"),
Name: util.ToPointer(util.Nullable[string]{ Value: "Name" }),
}
request := integrations.SendgridConfigPayload{
ApiKey: util.ToPointer("ApiKey"),
From: &sendgridConfigPayloadFrom,
ReplyTo: &replyTo,
}
response, err := client.Integrations.SaveSendgridIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"api_key": "SG.1234567890",
"from": {
"email": "company@example.com",
"name": "Company Name"
},
"reply_to": {
"email": "reply-to@example.com",
"name": "Reply to Company"
}
}
Delete a SendGrid integration
/integrations/sendgrid
Deletes the SendGrid integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteSendgridIntegrationRequestParams{
}
response, err := client.Integrations.DeleteSendgridIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all SendGrid integrations
/integrations/sendgrid
Retrieves the current SendGrid integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListSendgridIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"api_key": "SG.1234567890",
"from": {
"email": "company@example.com",
"name": "Company Name"
},
"reply_to": {
"email": "reply-to@example.com",
"name": "Reply to Company"
}
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save an Amazon SES integration
/integrations/ses
Updates or creates the Amazon SES integration for the project.
Request body
Show child attributesHide child attributes
The email address to send from
The name to send from
AWS Access Key ID
AWS Region
AWS Secret Key
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
sesConfigPayloadFrom := integrations.SesConfigPayloadFrom{
Email: util.ToPointer("Email"),
Name: util.ToPointer(util.Nullable[string]{ Value: "Name" }),
}
request := integrations.SesConfigPayload{
From: &sesConfigPayloadFrom,
KeyId: util.ToPointer("KeyId"),
Region: util.ToPointer("Region"),
SecretKey: util.ToPointer("SecretKey"),
}
response, err := client.Integrations.SaveSesIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"key_id": "MY_FAKE_AWS_ACCESS_KEY_ID",
"secret_key": "MY_FAKE_AWS_SECRET_KEY",
"region": "eu-west-1",
"from": {
"name": "Person Name",
"email": "person@example.com"
}
}
Delete an Amazon SES integration
/integrations/ses
Deletes the Amazon SES integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteSesIntegrationRequestParams{
}
response, err := client.Integrations.DeleteSesIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all Amazon SES integrations
/integrations/ses
Retrieves the current Amazon SES integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListSesIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"key_id": "MY_FAKE_AWS_ACCESS_KEY_ID",
"secret_key": "MY_FAKE_AWS_SECRET_KEY",
"region": "eu-west-1",
"from": {
"name": "Person Name",
"email": "person@example.com"
}
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a Slack installation
/integrations/slack/installations
Creates a new installation of a Slack integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration.
Request body
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
Show child attributesHide child attributes
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
authedUser := integrations.AuthedUser{
AccessToken: util.ToPointer("AccessToken"),
ExpiresIn: util.ToPointer(int64(123)),
Id: util.ToPointer("Id"),
RefreshToken: util.ToPointer("RefreshToken"),
Scope: util.ToPointer("Scope"),
TokenType: util.ToPointer("TokenType"),
}
enterprise := integrations.Enterprise{
Id: util.ToPointer("Id"),
Name: util.ToPointer("Name"),
}
incomingWebhook := integrations.IncomingWebhook{
Channel: util.ToPointer("Channel"),
ConfigurationUrl: util.ToPointer("ConfigurationUrl"),
Url: util.ToPointer("Url"),
}
team := integrations.Team{
Id: util.ToPointer("Id"),
Name: util.ToPointer("Name"),
}
request := integrations.SlackInstallation{
AccessToken: util.ToPointer("AccessToken"),
AppId: util.ToPointer("AppId"),
AuthedUser: &authedUser,
BotUserId: util.ToPointer("BotUserId"),
Enterprise: &enterprise,
ExpiresIn: util.ToPointer(int64(123)),
Id: util.ToPointer("Id"),
IncomingWebhook: &incomingWebhook,
IsEnterpriseInstall: util.ToPointer(true),
RefreshToken: util.ToPointer("RefreshToken"),
Scope: util.ToPointer("Scope"),
Team: &team,
TokenType: util.ToPointer("TokenType"),
}
response, err := client.Integrations.SaveSlackInstallation(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "A12345678-T123",
"access_token": "xoxb-123456789012-1234567890123-12345678901234567890abcdef123456",
"scope": "identify,commands,bot",
"team_name": "Team Installing Your App",
"team_id": "T12345678",
"enterprise_id": "E12345678",
"enterprise_name": "Enterprise Grid, Inc.",
"bot_user_id": "U12345678",
"app_id": "A12345678",
"authed_user": {
"id": "U12345678",
"scope": "identify,commands"
},
"incoming_webhook": {
"channel": "C12345678",
"channel_id": "C12345678",
"configuration_url": "https://teamname.slack.com/services/B12345678",
"url": "https://hooks.slack.com/services/T12345678/B12345678/123456789012345678901234"
},
"team": {
"name": "Team Installing Your App",
"id": "T123"
}
}
Start a Slack installation
/integrations/slack/installations/start
Initiates the installation flow for a Slack integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required.
Request body
Show child attributesHide child attributes
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := integrations.SlackStartInstall{
AppId: util.ToPointer("AppId"),
AuthUrl: util.ToPointer("AuthUrl"),
ExtraScopes: []string{},
RedirectUrl: util.ToPointer("RedirectUrl"),
}
response, err := client.Integrations.StartSlackInstallation(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"app_id": "app-id",
"auth_url": "https://slack.com/oauth/v2/authorize?client_id=app-id&scope=channels:read,chat:write",
"scopes": [
"channels:read",
"chat:write"
]
}
Finish a Slack installation
/integrations/slack/installations/finish
Completes the installation flow for the Slack integration. This endpoint is typically called after the user has completed any required authorization steps with Slack.
Request body
The app ID of the Slack app that was originally configured at the project-level.
The code that was returned from the OAuth flow, and found in the query string of the redirect URL.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := integrations.SlackFinishInstallResponse{
AppId: util.ToPointer("AppId"),
Code: util.ToPointer("Code"),
RedirectUrl: util.ToPointer("RedirectUrl"),
}
response, err := client.Integrations.FinishSlackInstallation(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "A12345678-T123",
"access_token": "xoxb-123456789012-1234567890123-12345678901234567890abcdef123456",
"scope": "identify,commands,bot",
"team_name": "Team Installing Your App",
"team_id": "T12345678",
"enterprise_id": "E12345678",
"enterprise_name": "Enterprise Grid, Inc.",
"bot_user_id": "U12345678",
"app_id": "A12345678",
"authed_user": {
"id": "U12345678",
"scope": "identify,commands"
},
"incoming_webhook": {
"channel": "C12345678",
"channel_id": "C12345678",
"configuration_url": "https://teamname.slack.com/services/B12345678",
"url": "https://hooks.slack.com/services/T12345678/B12345678/123456789012345678901234"
},
"team": {
"name": "Team Installing Your App",
"id": "T123"
}
}
Save a Slack integration
/integrations/slack
Updates or creates the Slack integration for the project.
Request body
The Slack app ID that can be found in the app's settings page of the Slack API dashboard.
The Slack client ID that can be found in the app's settings page of the Slack API dashboard.
The Slack client secret that can be found in the app's settings page of the Slack API dashboard.
The Slack signing secret that can be found in the app's settings page of the Slack API dashboard.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := integrations.SlackConfigPayload{
AppId: util.ToPointer("AppId"),
ClientId: util.ToPointer("ClientId"),
ClientSecret: util.ToPointer("ClientSecret"),
SigningSecret: util.ToPointer("SigningSecret"),
}
response, err := client.Integrations.SaveSlackIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"app_id": "12345678901",
"client_id": "1.0",
"client_secret": "12345678901234567890123456789012",
"signing_secret": "12345678901234567890123456789012"
}
Delete a Slack integration
/integrations/slack
Deletes the Slack integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteSlackIntegrationRequestParams{
}
response, err := client.Integrations.DeleteSlackIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all Slack integrations
/integrations/slack
Retrieves the current Slack integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListSlackIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"app_id": "12345678901",
"client_id": "1.0",
"client_secret": "12345678901234567890123456789012",
"signing_secret": "12345678901234567890123456789012"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a Twilio integration
/integrations/twilio
Updates or creates the Twilio integration for the project.
Request body
The SID for your Twilio account
A US1 API key for Twilio- - https://www.twilio.com/docs/iam/api-keys
The API Secret for Twilio
The phone number to send from, in E.164 format
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := integrations.TwilioConfigPayload{
AccountSid: util.ToPointer("AccountSid"),
ApiKey: util.ToPointer("ApiKey"),
ApiSecret: util.ToPointer("ApiSecret"),
From: util.ToPointer("From"),
}
response, err := client.Integrations.SaveTwilioIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"account_sid": "ACXXXXXXXX",
"api_key": "SKXXXXXXXX",
"api_secret": "your_api_secret",
"from": "+15017122661"
}
Delete a Twilio integration
/integrations/twilio
Deletes the Twilio integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteTwilioIntegrationRequestParams{
}
response, err := client.Integrations.DeleteTwilioIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all Twilio integrations
/integrations/twilio
Retrieves the current Twilio integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListTwilioIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"account_sid": "ACXXXXXXXX",
"api_key": "SKXXXXXXXX",
"api_secret": "your_api_secret",
"from": "+15017122661"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a Web Push installation
/integrations/web_push/installations
Creates a new installation of a Web Push integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration.
Request body
The push subscription URL obtained from PushSubscription.endpoint after calling registration.pushManager.subscribe(). This is the unique URL for this device that push messages will be sent to.
The encryption keys from the PushSubscription.getKey() method, needed to encrypt push messages for this subscription.
Show child attributesHide child attributes
The P-256 ECDH public key obtained from PushSubscription.getKey('p256dh'). Used to encrypt push messages for this subscription.
The authentication secret obtained from PushSubscription.getKey('auth'). Used to encrypt push messages for this subscription.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/util"
"github.com/magicbell/magicbell-go/pkg/user-client/shared"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
webPushTokenPayloadKeys := shared.WebPushTokenPayloadKeys{
Auth: util.ToPointer("Auth"),
P256dh: util.ToPointer("P256dh"),
}
request := shared.WebPushTokenPayload{
Endpoint: util.ToPointer("Endpoint"),
Keys: &webPushTokenPayloadKeys,
}
response, err := client.Integrations.SaveWebPushInstallation(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"endpoint": "https://fcm.googleapis.com/fcm/send/fZhR0fsr0zw:APA91bE4pM-qo1KBJDU_Zp2N9nDP-Jdmwugm-v4KNL_NlJvYCrJeJUzPXmMyAXqAE0m6BFOrkSWT0ArGbUjEEpxQEYZLado8JeW1PZA5CHB8R6C7HT6-MD6Qs8ZaCn8_ffLGGU7WuvtN",
"keys": {
"p256dh": "BICAe4KtLhhPNFvynlqMRxjvpRnr94881QeuTCr8kCwJf-Fssj3FLIlnfFMjj7T1yNg5l6cn14350323_NSGZh0",
"auth": "GoIO2ulhtQuyBM64lZuFuw"
}
}
Start a Web Push installation
/integrations/web_push/installations/start
Initiates the installation flow for a Web Push integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.StartWebPushInstallation(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"public_key": "BHaJd...gRHDk",
"auth_token": "eyGhb...GA2Bw"
}
Save a Web Push integration
/integrations/web_push
Updates or creates the Web Push integration for the project.
Request body
VAPID private key - from the pair you generated.
VAPID public key - generate one at https://tools.reactpwa.com/vapid.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := integrations.WebpushConfigPayload{
PrivateKey: util.ToPointer("PrivateKey"),
PublicKey: util.ToPointer("PublicKey"),
}
response, err := client.Integrations.SaveWebPushIntegration(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"public_key": "BNKZeSrRX_c3QfqzOvv1oshpj1qPbDcUJHKET6Ahs2u9-F4HgllPYxtgaGvGSqfytuALumX5NYZPLD8YmCwBxcw",
"private_key": "y56TIPdEzrQ0Ku_uQbGGkB84mYdF9pJl5IHvmAZ_fVs"
}
Delete a Web Push integration
/integrations/web_push
Deletes the Web Push integration configuration from the project. This will disable the integration's functionality within the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/integrations"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := integrations.DeleteWebPushIntegrationRequestParams{
}
response, err := client.Integrations.DeleteWebPushIntegration(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all Web Push integrations
/integrations/web_push
Retrieves the current Web Push integration configurations for a specific integration type in the project. Returns configuration details and status information.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Integrations.ListWebPushIntegrations(context.Background())
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"name": "<provider-name>",
"id": "123",
"config": {
"public_key": "BNKZeSrRX_c3QfqzOvv1oshpj1qPbDcUJHKET6Ahs2u9-F4HgllPYxtgaGvGSqfytuALumX5NYZPLD8YmCwBxcw",
"private_key": "y56TIPdEzrQ0Ku_uQbGGkB84mYdF9pJl5IHvmAZ_fVs"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Archive all notifications
/notifications/archive
Archive all notifications.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/notifications"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := notifications.ArchiveAllNotificationsRequestParams{
}
response, err := client.Notifications.ArchiveAllNotifications(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
Mark all notifications read
/notifications/read
Marks all notifications as read.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/notifications"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := notifications.MarkAllNotificationsReadRequestParams{
}
response, err := client.Notifications.MarkAllNotificationsRead(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{}
Fetch a notification
/notifications/{notification_id}
Gets a notification by ID.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Notifications.FetchNotification(context.Background(), "notificationId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "4b6efd21-f0f6-4051-8922-cc8c90a3dc5d",
"title": "Example Notification",
"action_url": null,
"seen_at": null,
"read_at": null,
"project_id": 7,
"user_id": "d4121424-097e-40b0-9cc8-357060d004b2",
"created_at": "2024-09-11T11:14:42.165Z",
"updated_at": "2024-09-11T11:14:42.165Z",
"custom_attributes": { "key": "value", "obj_key": { "one": "two" } },
"metadata": {},
"category_id": null,
"notification_broadcast_id": "6a8b1e23-f54b-4c65-95b2-78f288d7f247",
"in_app": true,
"discarded_at": null,
"overrides": {},
"aasm_state": "unseen",
"archived_at": null,
"topic_id": null
}
Unarchive a notification
/notifications/{notification_id}/unarchive
Unarchives a notification.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Notifications.UnarchiveNotification(context.Background(), "notificationId")
if err != nil {
panic(err)
}
fmt.Println(response)
{}
Archive a notification
/notifications/{notification_id}/archive
Archive a notification.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Notifications.ArchiveNotification(context.Background(), "notificationId")
if err != nil {
panic(err)
}
fmt.Println(response)
{}
Mark a notification read
/notifications/{notification_id}/read
Marks a notification as read.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Notifications.MarkNotificationRead(context.Background(), "notificationId")
if err != nil {
panic(err)
}
fmt.Println(response)
{}
Mark a notification unread
/notifications/{notification_id}/unread
Marks a notification as unread.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Notifications.MarkNotificationUnread(context.Background(), "notificationId")
if err != nil {
panic(err)
}
fmt.Println(response)
{}
List all notifications
/notifications
Lists all notifications for a user.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/user-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/user-client/client"
"github.com/magicbell/magicbell-go/pkg/user-client/notifications"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := notifications.ListNotificationsRequestParams{
}
response, err := client.Notifications.ListNotifications(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"id": "4b6efd21-f0f6-4051-8922-cc8c90a3dc5d",
"title": "Example Notification",
"action_url": null,
"seen_at": null,
"read_at": null,
"project_id": 7,
"user_id": "d4121424-097e-40b0-9cc8-357060d004b2",
"created_at": "2024-09-11T11:14:42.165Z",
"updated_at": "2024-09-11T11:14:42.165Z",
"custom_attributes": { "key": "value", "obj_key": { "one": "two" } },
"metadata": {},
"category_id": null,
"notification_broadcast_id": "6a8b1e23-f54b-4c65-95b2-78f288d7f247",
"in_app": true,
"discarded_at": null,
"overrides": {},
"aasm_state": "unseen",
"archived_at": null,
"topic_id": null
}
],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Save a user
/users
Creates or updates a user with the provided details. The user will be associated with the project specified in the request context.
Request body
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/util"
"github.com/magicbell/magicbell-go/pkg/project-client/shared"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
request := shared.User{
CreatedAt: util.ToPointer(util.Nullable[string]{ Value: "CreatedAt" }),
CustomAttributes: []byte{},
Email: util.ToPointer(util.Nullable[string]{ Value: "Email" }),
ExternalId: util.ToPointer(util.Nullable[string]{ Value: "ExternalId" }),
FirstName: util.ToPointer(util.Nullable[string]{ Value: "FirstName" }),
Id: util.ToPointer("Id"),
LastName: util.ToPointer(util.Nullable[string]{ Value: "LastName" }),
LastNotifiedAt: util.ToPointer(util.Nullable[string]{ Value: "LastNotifiedAt" }),
LastSeenAt: util.ToPointer(util.Nullable[string]{ Value: "LastSeenAt" }),
UpdatedAt: util.ToPointer(util.Nullable[string]{ Value: "UpdatedAt" }),
}
response, err := client.Users.SaveUser(context.Background(), request)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "8a038704-acc1-47f9-81b0-7523886cbeae",
"external_id": "external-id",
"email": "dan@example.com",
"first_name": "Dan",
"last_name": "Example",
"custom_attributes": {
"key": "value"
}
}
Delete a user
/users/{user_id}
Removes a user and all associated data from the project.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Users.DeleteUser(context.Background(), "userId")
if err != nil {
panic(err)
}
fmt.Println(response)
{}
Fetch an user's APNs token
/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}
Fetches a specific APNs token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchUserApnsToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"installation_id": "development",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an user's APNs token
/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}
Deletes a specific user's APNs token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteUserApnsToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List an user's APNs tokens
/users/{user_id}/channels/mobile_push/apns/tokens
Lists all APNs tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListUserApnsTokensRequestParams{
}
response, err := client.Channels.ListUserApnsTokens(context.Background(), "userId", params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"installation_id": "development",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Fetch an user's Expo token
/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}
Fetches a specific Expo token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchUserExpoToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an user's Expo token
/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}
Deletes a specific user's Expo token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteUserExpoToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List an user's Expo tokens
/users/{user_id}/channels/mobile_push/expo/tokens
Lists all Expo tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListUserExpoTokensRequestParams{
}
response, err := client.Channels.ListUserExpoTokens(context.Background(), "userId", params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "ExponentPushToken[xxxxxxxxxxxxxxxxxxxxxx]",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Fetch an user's FCM token
/users/{user_id}/channels/mobile_push/fcm/tokens/{token_id}
Fetches a specific FCM token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchUserFcmToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"installation_id": "development",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an user's FCM token
/users/{user_id}/channels/mobile_push/fcm/tokens/{token_id}
Deletes a specific user's FCM token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteUserFcmToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List an user's FCM tokens
/users/{user_id}/channels/mobile_push/fcm/tokens
Lists all FCM tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListUserFcmTokensRequestParams{
}
response, err := client.Channels.ListUserFcmTokens(context.Background(), "userId", params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"device_token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"installation_id": "development",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Fetch an user's Inbox token
/users/{user_id}/channels/in_app/inbox/tokens/{token_id}
Fetches a specific Inbox token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchUserInboxToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an user's Inbox token
/users/{user_id}/channels/in_app/inbox/tokens/{token_id}
Deletes a specific user's Inbox token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteUserInboxToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List an user's Inbox tokens
/users/{user_id}/channels/in_app/inbox/tokens
Lists all Inbox tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListUserInboxTokensRequestParams{
}
response, err := client.Channels.ListUserInboxTokens(context.Background(), "userId", params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"token": "eH0fLhuiRj2Np7UQ-opXAm:APA91bGtC-wH4sgW1jWkMKIZf7FYkm_RTQb7Jid7DfSJnCgivGYoRzhLrGxpcIF6yPjmbzAr6CKF-6phZkBasFUUfZmfdgcqfA_ZlZdVk6pSnon3LGzMumCzEJE0zgWoo_RUmVUVJUAt",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Fetch an user's Slack token
/users/{user_id}/channels/slack/tokens/{token_id}
Fetches a specific Slack token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchUserSlackToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z",
"webhook": {
"url": "https://example.com/webhook"
}
}
Delete an user's Slack token
/users/{user_id}/channels/slack/tokens/{token_id}
Deletes a specific user's Slack token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteUserSlackToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List an user's Slack tokens
/users/{user_id}/channels/slack/tokens
Lists all Slack tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListUserSlackTokensRequestParams{
}
response, err := client.Channels.ListUserSlackTokens(context.Background(), "userId", params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z",
"webhook": {
"url": "https://example.com/webhook"
}
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Fetch an user's Teams token
/users/{user_id}/channels/teams/tokens/{token_id}
Fetches a specific Teams token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchUserTeamsToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an user's Teams token
/users/{user_id}/channels/teams/tokens/{token_id}
Deletes a specific user's Teams token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteUserTeamsToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List an user's Teams tokens
/users/{user_id}/channels/teams/tokens
Lists all Teams tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListUserTeamsTokensRequestParams{
}
response, err := client.Channels.ListUserTeamsTokens(context.Background(), "userId", params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"id": "123",
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
Fetch an user's Web Push token
/users/{user_id}/channels/web_push/tokens/{token_id}
Fetches a specific Web Push token by its ID for a given user. This endpoint is available to project administrators and requires project-level authentication. Use this to inspect token details including its status, creation date, and associated metadata.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.FetchUserWebPushToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"endpoint": "https://fcm.googleapis.com/fcm/send/fZhR0fsr0zw:APA91bE4pM-qo1KBJDU_Zp2N9nDP-Jdmwugm-v4KNL_NlJvYCrJeJUzPXmMyAXqAE0m6BFOrkSWT0ArGbUjEEpxQEYZLado8JeW1PZA5CHB8R6C7HT6-MD6Qs8ZaCn8_ffLGGU7WuvtN",
"id": "123",
"keys": {
"auth": "GoIO2ulhtQuyBM64lZuFuw",
"p256dh": "BICAe4KtLhhPNFvynlqMRxjvpRnr94881QeuTCr8kCwJf-Fssj3FLIlnfFMjj7T1yNg5l6cn14350323_NSGZh0"
},
"updated_at": "2021-01-01T00:00:00Z"
}
Delete an user's Web Push token
/users/{user_id}/channels/web_push/tokens/{token_id}
Deletes a specific user's Web Push token. This endpoint is available to project administrators and permanently invalidates the specified token. Once revoked, the token can no longer be used to access channel features. This action cannot be undone.
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
response, err := client.Channels.DeleteUserWebPushToken(context.Background(), "userId", "tokenId")
if err != nil {
panic(err)
}
fmt.Println(response)
{
"id": "123",
"discarded_at": "2021-01-01T00:00:00Z"
}
List an user's Web Push tokens
/users/{user_id}/channels/web_push/tokens
Lists all Web Push tokens associated with a specific user. This endpoint is available to project administrators and returns a paginated list of tokens, including both active and revoked tokens.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/channels"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := channels.ListUserWebPushTokensRequestParams{
}
response, err := client.Channels.ListUserWebPushTokens(context.Background(), "userId", params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"created_at": "2021-01-01T00:00:00Z",
"discarded_at": "2021-01-01T00:00:00Z",
"endpoint": "https://fcm.googleapis.com/fcm/send/fZhR0fsr0zw:APA91bE4pM-qo1KBJDU_Zp2N9nDP-Jdmwugm-v4KNL_NlJvYCrJeJUzPXmMyAXqAE0m6BFOrkSWT0ArGbUjEEpxQEYZLado8JeW1PZA5CHB8R6C7HT6-MD6Qs8ZaCn8_ffLGGU7WuvtN",
"id": "123",
"keys": {
"auth": "GoIO2ulhtQuyBM64lZuFuw",
"p256dh": "BICAe4KtLhhPNFvynlqMRxjvpRnr94881QeuTCr8kCwJf-Fssj3FLIlnfFMjj7T1yNg5l6cn14350323_NSGZh0"
},
"updated_at": "2021-01-01T00:00:00Z"
}],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}
List all users
/users
Lists all users in the project.
Query parameters
import (
"fmt"
"encoding/json"
"github.com/magicbell/magicbell-go/pkg/project-client/clientconfig"
"github.com/magicbell/magicbell-go/pkg/project-client/client"
"github.com/magicbell/magicbell-go/pkg/project-client/users"
)
config := clientconfig.NewConfig()
client := client.NewClient(config)
params := users.ListUsersRequestParams{
}
response, err := client.Users.ListUsers(context.Background(), params)
if err != nil {
panic(err)
}
fmt.Println(response)
{
"data":[{
"id": "8a038704-acc1-47f9-81b0-7523886cbeae",
"external_id": "external-id",
"email": "dan@example.com",
"first_name": "Dan",
"last_name": "Example",
"custom_attributes": {
"key": "value"
}
}
],
"links": {
"first":"https://api.magicbell.com/v1/example",
"next":"https://api.magicbell.com/v1/example?page_next=abc",
"prev":null
}
}