Browser/Node Client
Setup & Configuration
Installation
To get started with the SDK, we recommend installing using npm:
npm install magicbell-js
Authentication
Both the ProjectClient and the UserClient require authentication. Please read more about authentication and generation of tokens in our Authentication docs.
ProjectClient
Authentication
Access Token Authentication
The Client API uses an Access Token for authentication.
This token must be provided to authenticate your requests to the API.
Setting the Access Token
When you initialize the SDK, you can set the access token as follows:
const sdk = new Client({ token: 'YOUR_TOKEN' });
If you need to set or update the access token after initializing the SDK, you can use:
const sdk = new Client();
sdk.token = 'YOUR_TOKEN';
Setting a Custom Timeout
You can set a custom timeout for the SDK's HTTP requests as follows:
const client = new Client({ timeout: 10000 });
Sample Usage
Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.broadcasts.listBroadcasts({
limit: 1,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
Services
The SDK provides various services to interact with the API.
BroadcastsService
A list of all methods in the BroadcastsService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| listBroadcasts | Retrieves a paginated list of broadcasts for the project. Returns basic information about each broadcast including its creation time and status. |
| createBroadcast | Creates a new broadcast. When a broadcast is created, it generates individual notifications for relevant users within the project. |
| fetchBroadcast | Retrieves detailed information about a specific broadcast by its ID. Includes the broadcast's configuration and current status. |
listBroadcasts
Retrieves a paginated list of broadcasts for the project. Returns basic information about each broadcast including its creation time and status.
- HTTP Method:
GET - Endpoint:
/broadcasts
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
BroadcastCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.broadcasts.listBroadcasts({
limit: 1,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
createBroadcast
Creates a new broadcast. When a broadcast is created, it generates individual notifications for relevant users within the project.
- HTTP Method:
POST - Endpoint:
/broadcasts
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | Broadcast | ❌ | The request body. |
Return Type
Broadcast
Example Usage Code Snippet
import {
Broadcast,
BroadcastStatus,
Client,
Email,
Errors,
InApp,
MobilePush,
Overrides,
OverridesChannels,
Providers,
Sms,
StatusStatus,
Summary,
User,
} from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const email: Email = {
actionUrl: 'action_url',
content: 'content',
title: 'title',
};
const inApp: InApp = {
actionUrl: 'action_url',
content: 'content',
title: 'title',
};
const mobilePush: MobilePush = {
actionUrl: 'action_url',
content: 'content',
title: 'title',
};
const sms: Sms = {
actionUrl: 'action_url',
content: 'content',
title: 'title',
};
const overridesChannels: OverridesChannels = {
email: email,
inApp: inApp,
mobilePush: mobilePush,
sms: sms,
};
const providers: Providers = {
apns: {},
expo: {},
fcm: {},
mailgun: {},
sendgrid: {},
ses: {},
slack: {},
teams: {},
twilio: {},
webPush: {},
};
const overrides: Overrides = {
channels: overridesChannels,
providers: providers,
};
const user: User = {
createdAt: 'created_at',
customAttributes: {},
email: 'email',
externalId: 'external_id',
firstName: 'first_name',
id: 'id',
lastName: 'last_name',
lastNotifiedAt: 'last_notified_at',
lastSeenAt: 'last_seen_at',
updatedAt: 'updated_at',
};
const errors: Errors = {
message: 'message',
};
const statusStatus = StatusStatus.ENQUEUED;
const summary: Summary = {
failures: 4,
total: 5,
};
const broadcastStatus: BroadcastStatus = {
errors: [errors],
status: statusStatus,
summary: summary,
};
const broadcast: Broadcast = {
actionUrl: 'action_url',
category: 'category',
content: 'content',
createdAt: 'created_at',
customAttributes: {},
id: 'id',
overrides: overrides,
recipients: [user],
status: broadcastStatus,
title: 'title',
topic: 'topic',
};
const { data } = await client.broadcasts.createBroadcast(broadcast);
console.log(data);
})();
fetchBroadcast
Retrieves detailed information about a specific broadcast by its ID. Includes the broadcast's configuration and current status.
- HTTP Method:
GET - Endpoint:
/broadcasts/{broadcast_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| broadcastId | string | ✅ |
Return Type
Broadcast
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.broadcasts.fetchBroadcast('broadcast_id');
console.log(data);
})();
ChannelsService
A list of all methods in the ChannelsService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| saveChannelsConfig | Save the channels configuration for a given key. |
| fetchChannelsConfig | Fetches the channels config for a given key. |
| listUserInboxTokens | 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. |
| fetchUserInboxToken | 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. |
| deleteUserInboxToken | 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. |
| listUserApnsTokens | 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. |
| fetchUserApnsToken | 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. |
| deleteUserApnsToken | 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. |
| listUserExpoTokens | 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. |
| fetchUserExpoToken | 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. |
| deleteUserExpoToken | 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. |
| listUserFcmTokens | 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. |
| fetchUserFcmToken | 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. |
| deleteUserFcmToken | 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. |
| listUserMagicbellSlackbotTokens | Lists all MagicBell SlackBot 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. |
| fetchUserMagicbellSlackbotToken | Fetches a specific MagicBell SlackBot 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. |
| deleteUserMagicbellSlackbotToken | Deletes a specific user's MagicBell SlackBot 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. |
| listUserSlackTokens | 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. |
| fetchUserSlackToken | 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. |
| deleteUserSlackToken | 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. |
| listUserTeamsTokens | 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. |
| fetchUserTeamsToken | 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. |
| deleteUserTeamsToken | 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. |
| listUserWebPushTokens | 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. |
| fetchUserWebPushToken | 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. |
| deleteUserWebPushToken | 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. |
saveChannelsConfig
Save the channels configuration for a given key.
- HTTP Method:
PUT - Endpoint:
/channels
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | CategoryDeliveryConfig | ❌ | The request body. |
Return Type
CategoryDeliveryConfig
Example Usage Code Snippet
import { CategoryDeliveryConfig, CategoryDeliveryConfigChannels, Channel, Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const channel = Channel.IN_APP;
const categoryDeliveryConfigChannels: CategoryDeliveryConfigChannels = {
channel: channel,
delay: 1,
if: 'if',
};
const categoryDeliveryConfig: CategoryDeliveryConfig = {
channels: [categoryDeliveryConfigChannels],
disabled: true,
key: 'key',
};
const { data } = await client.channels.saveChannelsConfig(categoryDeliveryConfig);
console.log(data);
})();
fetchChannelsConfig
Fetches the channels config for a given key.
- HTTP Method:
GET - Endpoint:
/channels/{key}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| key | string | ✅ |
Return Type
CategoryDeliveryConfig
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchChannelsConfig('key');
console.log(data);
})();
listUserInboxTokens
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/in_app/inbox/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
InboxTokenResponseCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listUserInboxTokens('user_id', {
limit: 3,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchUserInboxToken
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/in_app/inbox/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
InboxTokenResponse
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserInboxToken('user_id', 'token_id');
console.log(data);
})();
deleteUserInboxToken
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.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}/channels/in_app/inbox/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteUserInboxToken('user_id', 'token_id');
console.log(data);
})();
listUserApnsTokens
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/mobile_push/apns/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
ApnsTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listUserApnsTokens('user_id', {
limit: 3,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchUserApnsToken
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
ApnsToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserApnsToken('user_id', 'token_id');
console.log(data);
})();
deleteUserApnsToken
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.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteUserApnsToken('user_id', 'token_id');
console.log(data);
})();
listUserExpoTokens
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/mobile_push/expo/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
ExpoTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listUserExpoTokens('user_id', {
limit: 123,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchUserExpoToken
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
ExpoToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserExpoToken('user_id', 'token_id');
console.log(data);
})();
deleteUserExpoToken
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.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteUserExpoToken('user_id', 'token_id');
console.log(data);
})();
listUserFcmTokens
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/mobile_push/fcm/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
FcmTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listUserFcmTokens('user_id', {
limit: 2,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchUserFcmToken
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/mobile_push/fcm/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
FcmToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserFcmToken('user_id', 'token_id');
console.log(data);
})();
deleteUserFcmToken
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.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}/channels/mobile_push/fcm/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteUserFcmToken('user_id', 'token_id');
console.log(data);
})();
listUserMagicbellSlackbotTokens
Lists all MagicBell SlackBot 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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/slack/magicbell_slackbot/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
SlackTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listUserMagicbellSlackbotTokens('user_id', {
limit: 8,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchUserMagicbellSlackbotToken
Fetches a specific MagicBell SlackBot 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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/slack/magicbell_slackbot/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
SlackToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserMagicbellSlackbotToken('user_id', 'token_id');
console.log(data);
})();
deleteUserMagicbellSlackbotToken
Deletes a specific user's MagicBell SlackBot 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.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}/channels/slack/magicbell_slackbot/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteUserMagicbellSlackbotToken('user_id', 'token_id');
console.log(data);
})();
listUserSlackTokens
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/slack/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
SlackTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listUserSlackTokens('user_id', {
limit: 8,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchUserSlackToken
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/slack/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
SlackToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserSlackToken('user_id', 'token_id');
console.log(data);
})();
deleteUserSlackToken
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.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}/channels/slack/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteUserSlackToken('user_id', 'token_id');
console.log(data);
})();
listUserTeamsTokens
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/teams/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
TeamsTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listUserTeamsTokens('user_id', {
limit: 1,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchUserTeamsToken
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/teams/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
TeamsToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserTeamsToken('user_id', 'token_id');
console.log(data);
})();
deleteUserTeamsToken
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.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}/channels/teams/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteUserTeamsToken('user_id', 'token_id');
console.log(data);
})();
listUserWebPushTokens
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/web_push/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
WebPushTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listUserWebPushTokens('user_id', {
limit: 123,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchUserWebPushToken
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.
- HTTP Method:
GET - Endpoint:
/users/{user_id}/channels/web_push/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
WebPushToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserWebPushToken('user_id', 'token_id');
console.log(data);
})();
deleteUserWebPushToken
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.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}/channels/web_push/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ | |
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteUserWebPushToken('user_id', 'token_id');
console.log(data);
})();
EventsService
A list of all methods in the EventsService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| listEvents | Retrieves a paginated list of events for the project. |
| fetchEvent | Fetches a project event by its ID. |
listEvents
Retrieves a paginated list of events for the project.
- HTTP Method:
GET - Endpoint:
/events
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
EventCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.events.listEvents({
limit: 1,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
fetchEvent
Fetches a project event by its ID.
- HTTP Method:
GET - Endpoint:
/events/{event_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| eventId | string | ✅ |
Return Type
Event
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.events.fetchEvent('event_id');
console.log(data);
})();
IntegrationsService
A list of all methods in the IntegrationsService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| listIntegrations | Lists all available and configured integrations for the project. Returns a summary of each integration including its type, status, and basic configuration information. |
| listApnsIntegrations | Retrieves the current APNs integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveApnsIntegration | Updates or creates the APNs integration for the project. |
| deleteApnsIntegration | Deletes the APNs integration configuration from the project. This will disable the integration's functionality within the project. |
| listEventsourceIntegrations | Retrieves the current EventSource integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveEventsourceIntegration | Updates or creates the EventSource integration for the project. |
| deleteEventsourceIntegration | Deletes the EventSource integration configuration from the project. This will disable the integration's functionality within the project. |
| listExpoIntegrations | Retrieves the current Expo integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveExpoIntegration | Updates or creates the Expo integration for the project. |
| deleteExpoIntegration | Deletes the Expo integration configuration from the project. This will disable the integration's functionality within the project. |
| listFcmIntegrations | Retrieves the current FCM integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveFcmIntegration | Updates or creates the FCM integration for the project. |
| deleteFcmIntegration | Deletes the FCM integration configuration from the project. This will disable the integration's functionality within the project. |
| listGithubIntegrations | Retrieves the current GitHub integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveGithubIntegration | Updates or creates the GitHub integration for the project. |
| deleteGithubIntegration | Deletes the GitHub integration configuration from the project. This will disable the integration's functionality within the project. |
| listInboxIntegrations | Retrieves the current Inbox integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveInboxIntegration | Updates or creates the Inbox integration for the project. |
| deleteInboxIntegration | Deletes the Inbox integration configuration from the project. This will disable the integration's functionality within the project. |
| listMagicbellSlackbotIntegrations | Retrieves the current MagicBell SlackBot integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveMagicbellSlackbotIntegration | Updates or creates the MagicBell SlackBot integration for the project. |
| deleteMagicbellSlackbotIntegration | Deletes the MagicBell SlackBot integration configuration from the project. This will disable the integration's functionality within the project. |
| listMailgunIntegrations | Retrieves the current Mailgun integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveMailgunIntegration | Updates or creates the Mailgun integration for the project. |
| deleteMailgunIntegration | Deletes the Mailgun integration configuration from the project. This will disable the integration's functionality within the project. |
| listPingEmailIntegrations | Retrieves the current Ping Email integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| savePingEmailIntegration | Updates or creates the Ping Email integration for the project. |
| deletePingEmailIntegration | Deletes the Ping Email integration configuration from the project. This will disable the integration's functionality within the project. |
| listSendgridIntegrations | Retrieves the current SendGrid integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveSendgridIntegration | Updates or creates the SendGrid integration for the project. |
| deleteSendgridIntegration | Deletes the SendGrid integration configuration from the project. This will disable the integration's functionality within the project. |
| listSesIntegrations | Retrieves the current Amazon SES integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveSesIntegration | Updates or creates the Amazon SES integration for the project. |
| deleteSesIntegration | Deletes the Amazon SES integration configuration from the project. This will disable the integration's functionality within the project. |
| listSlackIntegrations | Retrieves the current Slack integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveSlackIntegration | Updates or creates the Slack integration for the project. |
| deleteSlackIntegration | Deletes the Slack integration configuration from the project. This will disable the integration's functionality within the project. |
| listSmtpIntegrations | Retrieves the current SMTP integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveSmtpIntegration | Updates or creates the SMTP integration for the project. |
| deleteSmtpIntegration | Deletes the SMTP integration configuration from the project. This will disable the integration's functionality within the project. |
| listStripeIntegrations | Retrieves the current Stripe integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveStripeIntegration | Updates or creates the Stripe integration for the project. |
| deleteStripeIntegration | Deletes the Stripe integration configuration from the project. This will disable the integration's functionality within the project. |
| listTwilioIntegrations | Retrieves the current Twilio integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveTwilioIntegration | Updates or creates the Twilio integration for the project. |
| deleteTwilioIntegration | Deletes the Twilio integration configuration from the project. This will disable the integration's functionality within the project. |
| listWebPushIntegrations | Retrieves the current Web Push integration configurations for a specific integration type in the project. Returns configuration details and status information. |
| saveWebPushIntegration | Updates or creates the Web Push integration for the project. |
| deleteWebPushIntegration | Deletes the Web Push integration configuration from the project. This will disable the integration's functionality within the project. |
listIntegrations
Lists all available and configured integrations for the project. Returns a summary of each integration including its type, status, and basic configuration information.
- HTTP Method:
GET - Endpoint:
/integrations
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
IntegrationConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listIntegrations({
limit: 2,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
listApnsIntegrations
Retrieves the current APNs integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/apns
Return Type
ApnsConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listApnsIntegrations();
console.log(data);
})();
saveApnsIntegration
Updates or creates the APNs integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/apns
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | ApnsConfigPayload | ❌ | The request body. |
Return Type
ApnsConfigPayload
Example Usage Code Snippet
import { ApnsConfigPayload, Badge, Client, PayloadVersion } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const badge = Badge.UNREAD
const payloadVersion = PayloadVersion._1
const apnsConfigPayload: ApnsConfigPayload = {
appId: "app_id",
badge: badge,
certificate: " BEGIN PRIVATE KEY--
2tSdsGz=
--------- END PRIVATE KEYYYYYYYYYYY--------
",
keyId: "proident s",
payloadVersion: payloadVersion,
teamId: "laborum ut"
};
const { data } = await client.integrations.saveApnsIntegration(apnsConfigPayload);
console.log(data);
})();
deleteApnsIntegration
Deletes the APNs integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/apns
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteApnsIntegration({
id: 'id',
});
console.log(data);
})();
listEventsourceIntegrations
Retrieves the current EventSource integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/eventsource
Return Type
EventSourceConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listEventsourceIntegrations();
console.log(data);
})();
saveEventsourceIntegration
Updates or creates the EventSource integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/eventsource
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | EventSourceConfigPayload | ❌ | The request body. |
Return Type
EventSourceConfigPayload
Example Usage Code Snippet
import { Client, EventSourceConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const eventSourceConfigPayload: EventSourceConfigPayload = {
source: 'source',
};
const { data } = await client.integrations.saveEventsourceIntegration(eventSourceConfigPayload);
console.log(data);
})();
deleteEventsourceIntegration
Deletes the EventSource integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/eventsource
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteEventsourceIntegration({
id: 'id',
});
console.log(data);
})();
listExpoIntegrations
Retrieves the current Expo integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/expo
Return Type
ExpoConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listExpoIntegrations();
console.log(data);
})();
saveExpoIntegration
Updates or creates the Expo integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/expo
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | ExpoConfigPayload | ❌ | The request body. |
Return Type
ExpoConfigPayload
Example Usage Code Snippet
import { Client, ExpoConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const expoConfigPayload: ExpoConfigPayload = {
accessToken: 'access_token',
};
const { data } = await client.integrations.saveExpoIntegration(expoConfigPayload);
console.log(data);
})();
deleteExpoIntegration
Deletes the Expo integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/expo
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteExpoIntegration({
id: 'id',
});
console.log(data);
})();
listFcmIntegrations
Retrieves the current FCM integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/fcm
Return Type
FcmConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listFcmIntegrations();
console.log(data);
})();
saveFcmIntegration
Updates or creates the FCM integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/fcm
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | FcmConfigPayload | ❌ | The request body. |
Return Type
FcmConfigPayload
Example Usage Code Snippet
import { Client, FcmConfigPayload, Type_ } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const type_ = Type_.SERVICE_ACCOUNT
const fcmConfigPayload: FcmConfigPayload = {
authProviderX509CertUrl: "auth_provider_x509_cert_url",
authUri: "auth_uri",
clientEmail: "client_email",
clientId: "client_id",
clientX509CertUrl: "client_x509_cert_url",
privateKey: "----BEGINZZASTRAXC-
NBdNmSp
------- ENDTLCHMVK----------",
privateKeyId: "private_key_id",
projectId: "project_id",
tokenUri: "token_uri",
type: type_,
universeDomain: "universe_domain"
};
const { data } = await client.integrations.saveFcmIntegration(fcmConfigPayload);
console.log(data);
})();
deleteFcmIntegration
Deletes the FCM integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/fcm
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteFcmIntegration({
id: 'id',
});
console.log(data);
})();
listGithubIntegrations
Retrieves the current GitHub integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/github
Return Type
GithubConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listGithubIntegrations();
console.log(data);
})();
saveGithubIntegration
Updates or creates the GitHub integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/github
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | GithubConfigPayload | ❌ | The request body. |
Return Type
GithubConfigPayload
Example Usage Code Snippet
import { Client, GithubConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const githubConfigPayload: GithubConfigPayload = {
webhookSigningSecret: 'webhook_signing_secret',
};
const { data } = await client.integrations.saveGithubIntegration(githubConfigPayload);
console.log(data);
})();
deleteGithubIntegration
Deletes the GitHub integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/github
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteGithubIntegration({
id: 'id',
});
console.log(data);
})();
listInboxIntegrations
Retrieves the current Inbox integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/inbox
Return Type
InboxConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listInboxIntegrations();
console.log(data);
})();
saveInboxIntegration
Updates or creates the Inbox integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/inbox
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | InboxConfigPayload | ❌ | The request body. |
Return Type
InboxConfigPayload
Example Usage Code Snippet
import {
Banner,
Client,
DefaultHover,
DefaultState,
Default_,
Dialog,
Footer,
Header,
Icon,
Images,
InboxConfigPayload,
Notification,
Theme,
Unread,
UnreadHover,
UnreadState,
Unseen,
UnseenBadge,
UnseenHover,
UnseenState,
} from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const images: Images = {
emptyInboxUrl: 'emptyInboxUrl',
};
const banner: Banner = {
backgroundColor: 'backgroundColor',
backgroundOpacity: 4.93,
fontSize: 'fontSize',
textColor: 'textColor',
};
const dialog: Dialog = {
accentColor: 'accentColor',
backgroundColor: 'backgroundColor',
textColor: 'textColor',
};
const footer: Footer = {
backgroundColor: 'backgroundColor',
borderRadius: 'borderRadius',
fontSize: 'fontSize',
textColor: 'textColor',
};
const header: Header = {
backgroundColor: 'backgroundColor',
borderRadius: 'borderRadius',
fontFamily: 'fontFamily',
fontSize: 'fontSize',
textColor: 'textColor',
};
const icon: Icon = {
borderColor: 'borderColor',
width: 'width',
};
const defaultHover: DefaultHover = {
backgroundColor: 'backgroundColor',
};
const defaultState: DefaultState = {
color: 'color',
};
const default_: Default_ = {
backgroundColor: 'backgroundColor',
borderRadius: 'borderRadius',
fontFamily: 'fontFamily',
fontSize: 'fontSize',
hover: defaultHover,
margin: 'margin',
state: defaultState,
textColor: 'textColor',
};
const unreadHover: UnreadHover = {
backgroundColor: 'backgroundColor',
};
const unreadState: UnreadState = {
color: 'color',
};
const unread: Unread = {
backgroundColor: 'backgroundColor',
hover: unreadHover,
state: unreadState,
textColor: 'textColor',
};
const unseenHover: UnseenHover = {
backgroundColor: 'backgroundColor',
};
const unseenState: UnseenState = {
color: 'color',
};
const unseen: Unseen = {
backgroundColor: 'backgroundColor',
hover: unseenHover,
state: unseenState,
textColor: 'textColor',
};
const notification: Notification = {
default: default_,
unread: unread,
unseen: unseen,
};
const unseenBadge: UnseenBadge = {
backgroundColor: 'backgroundColor',
};
const theme: Theme = {
banner: banner,
dialog: dialog,
footer: footer,
header: header,
icon: icon,
notification: notification,
unseenBadge: unseenBadge,
};
const inboxConfigPayload: InboxConfigPayload = {
images: images,
locale: 'locale',
theme: theme,
};
const { data } = await client.integrations.saveInboxIntegration(inboxConfigPayload);
console.log(data);
})();
deleteInboxIntegration
Deletes the Inbox integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/inbox
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteInboxIntegration({
id: 'id',
});
console.log(data);
})();
listMagicbellSlackbotIntegrations
Retrieves the current MagicBell SlackBot integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/magicbell_slackbot
Return Type
SlackBotConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listMagicbellSlackbotIntegrations();
console.log(data);
})();
saveMagicbellSlackbotIntegration
Updates or creates the MagicBell SlackBot integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/magicbell_slackbot
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackBotConfigPayload | ❌ | The request body. |
Return Type
SlackBotConfigPayload
Example Usage Code Snippet
import { Client, SlackBotConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const slackBotConfigPayload: SlackBotConfigPayload = {
enabled: true,
};
const { data } = await client.integrations.saveMagicbellSlackbotIntegration(slackBotConfigPayload);
console.log(data);
})();
deleteMagicbellSlackbotIntegration
Deletes the MagicBell SlackBot integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/magicbell_slackbot
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteMagicbellSlackbotIntegration({
id: 'id',
});
console.log(data);
})();
listMailgunIntegrations
Retrieves the current Mailgun integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/mailgun
Return Type
MailgunConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listMailgunIntegrations();
console.log(data);
})();
saveMailgunIntegration
Updates or creates the Mailgun integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/mailgun
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | MailgunConfigPayload | ❌ | The request body. |
Return Type
MailgunConfigPayload
Example Usage Code Snippet
import { Client, MailgunConfigPayload, MailgunConfigPayloadFrom, Region } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const mailgunConfigPayloadFrom: MailgunConfigPayloadFrom = {
email: 'email',
name: 'name',
};
const region = Region.US;
const mailgunConfigPayload: MailgunConfigPayload = {
apiKey: 'api_key',
domain: 'domain',
from: mailgunConfigPayloadFrom,
region: region,
};
const { data } = await client.integrations.saveMailgunIntegration(mailgunConfigPayload);
console.log(data);
})();
deleteMailgunIntegration
Deletes the Mailgun integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/mailgun
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteMailgunIntegration({
id: 'id',
});
console.log(data);
})();
listPingEmailIntegrations
Retrieves the current Ping Email integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/ping_email
Return Type
PingConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listPingEmailIntegrations();
console.log(data);
})();
savePingEmailIntegration
Updates or creates the Ping Email integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/ping_email
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | PingConfigPayload | ❌ | The request body. |
Return Type
PingConfigPayload
Example Usage Code Snippet
import { Client, PingConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const pingConfigPayload: PingConfigPayload = {
url: 'url',
};
const { data } = await client.integrations.savePingEmailIntegration(pingConfigPayload);
console.log(data);
})();
deletePingEmailIntegration
Deletes the Ping Email integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/ping_email
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deletePingEmailIntegration({
id: 'id',
});
console.log(data);
})();
listSendgridIntegrations
Retrieves the current SendGrid integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/sendgrid
Return Type
SendgridConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listSendgridIntegrations();
console.log(data);
})();
saveSendgridIntegration
Updates or creates the SendGrid integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/sendgrid
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SendgridConfigPayload | ❌ | The request body. |
Return Type
SendgridConfigPayload
Example Usage Code Snippet
import {
Client,
SendgridConfigPayload,
SendgridConfigPayloadFrom,
SendgridConfigPayloadReplyTo,
} from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const sendgridConfigPayloadFrom: SendgridConfigPayloadFrom = {
email: 'email',
name: 'name',
};
const sendgridConfigPayloadReplyTo: SendgridConfigPayloadReplyTo = {
email: 'email',
name: 'name',
};
const sendgridConfigPayload: SendgridConfigPayload = {
apiKey: 'api_key',
from: sendgridConfigPayloadFrom,
replyTo: sendgridConfigPayloadReplyTo,
};
const { data } = await client.integrations.saveSendgridIntegration(sendgridConfigPayload);
console.log(data);
})();
deleteSendgridIntegration
Deletes the SendGrid integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/sendgrid
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteSendgridIntegration({
id: 'id',
});
console.log(data);
})();
listSesIntegrations
Retrieves the current Amazon SES integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/ses
Return Type
SesConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listSesIntegrations();
console.log(data);
})();
saveSesIntegration
Updates or creates the Amazon SES integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/ses
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SesConfigPayload | ❌ | The request body. |
Return Type
SesConfigPayload
Example Usage Code Snippet
import { Client, SesConfigPayload, SesConfigPayloadFrom } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const sesConfigPayloadFrom: SesConfigPayloadFrom = {
email: 'email',
name: 'name',
};
const sesConfigPayload: SesConfigPayload = {
from: sesConfigPayloadFrom,
keyId: 'key_id',
region: 'region',
secretKey: 'secret_key',
};
const { data } = await client.integrations.saveSesIntegration(sesConfigPayload);
console.log(data);
})();
deleteSesIntegration
Deletes the Amazon SES integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/ses
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteSesIntegration({
id: 'id',
});
console.log(data);
})();
listSlackIntegrations
Retrieves the current Slack integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/slack
Return Type
SlackConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listSlackIntegrations();
console.log(data);
})();
saveSlackIntegration
Updates or creates the Slack integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/slack
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackConfigPayload | ❌ | The request body. |
Return Type
SlackConfigPayload
Example Usage Code Snippet
import { Client, SlackConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const slackConfigPayload: SlackConfigPayload = {
appId: 'O7RI',
clientId: '104.7350704',
clientSecret: 'officia fugiat nostrud Excepteur',
signingSecret: 'non sit exanim ad enim eaexlabor',
};
const { data } = await client.integrations.saveSlackIntegration(slackConfigPayload);
console.log(data);
})();
deleteSlackIntegration
Deletes the Slack integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/slack
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteSlackIntegration({
id: 'id',
});
console.log(data);
})();
listSmtpIntegrations
Retrieves the current SMTP integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/smtp
Return Type
SmtpConfigObjectCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listSmtpIntegrations();
console.log(data);
})();
saveSmtpIntegration
Updates or creates the SMTP integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/smtp
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SmtpConfig | ❌ | The request body. |
Return Type
SmtpConfig
Example Usage Code Snippet
import { Client, Security, SmtpConfig, SmtpConfigFrom, SmtpConfigReplyTo } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const smtpConfigFrom: SmtpConfigFrom = {
email: 'email',
name: 'name',
};
const smtpConfigReplyTo: SmtpConfigReplyTo = {
email: 'email',
name: 'name',
};
const security = Security.NONE;
const smtpConfig: SmtpConfig = {
from: smtpConfigFrom,
host: 'smtp.gmail.com',
password: 'password',
port: 25,
replyTo: smtpConfigReplyTo,
security: security,
username: 'username',
};
const { data } = await client.integrations.saveSmtpIntegration(smtpConfig);
console.log(data);
})();
deleteSmtpIntegration
Deletes the SMTP integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/smtp
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteSmtpIntegration({
id: 'id',
});
console.log(data);
})();
listStripeIntegrations
Retrieves the current Stripe integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/stripe
Return Type
StripeConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listStripeIntegrations();
console.log(data);
})();
saveStripeIntegration
Updates or creates the Stripe integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/stripe
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | StripeConfigPayload | ❌ | The request body. |
Return Type
StripeConfigPayload
Example Usage Code Snippet
import { Client, StripeConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const stripeConfigPayload: StripeConfigPayload = {
id: 'id',
webhookSigningSecret: 'webhook_signing_secret',
};
const { data } = await client.integrations.saveStripeIntegration(stripeConfigPayload);
console.log(data);
})();
deleteStripeIntegration
Deletes the Stripe integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/stripe
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteStripeIntegration({
id: 'id',
});
console.log(data);
})();
listTwilioIntegrations
Retrieves the current Twilio integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/twilio
Return Type
TwilioConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listTwilioIntegrations();
console.log(data);
})();
saveTwilioIntegration
Updates or creates the Twilio integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/twilio
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | TwilioConfigPayload | ❌ | The request body. |
Return Type
TwilioConfigPayload
Example Usage Code Snippet
import { Client, TwilioConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const twilioConfigPayload: TwilioConfigPayload = {
accountSid: 'account_sid',
apiKey: 'api_key',
apiSecret: 'api_secret',
from: '+28378825295343',
};
const { data } = await client.integrations.saveTwilioIntegration(twilioConfigPayload);
console.log(data);
})();
deleteTwilioIntegration
Deletes the Twilio integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/twilio
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteTwilioIntegration({
id: 'id',
});
console.log(data);
})();
listWebPushIntegrations
Retrieves the current Web Push integration configurations for a specific integration type in the project. Returns configuration details and status information.
- HTTP Method:
GET - Endpoint:
/integrations/web_push
Return Type
WebpushConfigCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.listWebPushIntegrations();
console.log(data);
})();
saveWebPushIntegration
Updates or creates the Web Push integration for the project.
- HTTP Method:
PUT - Endpoint:
/integrations/web_push
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | WebpushConfigPayload | ❌ | The request body. |
Return Type
WebpushConfigPayload
Example Usage Code Snippet
import { Client, WebpushConfigPayload } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const webpushConfigPayload: WebpushConfigPayload = {
privateKey: 'private_key',
publicKey: 'public_key',
};
const { data } = await client.integrations.saveWebPushIntegration(webpushConfigPayload);
console.log(data);
})();
deleteWebPushIntegration
Deletes the Web Push integration configuration from the project. This will disable the integration's functionality within the project.
- HTTP Method:
DELETE - Endpoint:
/integrations/web_push
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| id | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.deleteWebPushIntegration({
id: 'id',
});
console.log(data);
})();
UsersService
A list of all methods in the UsersService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| listUsers | Lists all users in the project. |
| saveUser | Creates or updates a user with the provided details. The user will be associated with the project specified in the request context. |
| deleteUser | Removes a user and all associated data from the project. |
listUsers
Lists all users in the project.
- HTTP Method:
GET - Endpoint:
/users
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ | |
| query | string | ❌ |
Return Type
UserCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.users.listUsers({
limit: 1,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
query: 'query',
});
console.log(data);
})();
saveUser
Creates or updates a user with the provided details. The user will be associated with the project specified in the request context.
- HTTP Method:
PUT - Endpoint:
/users
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | User | ❌ | The request body. |
Return Type
User
Example Usage Code Snippet
import { Client, User } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const user: User = {
createdAt: 'created_at',
customAttributes: {},
email: 'email',
externalId: 'external_id',
firstName: 'first_name',
id: 'id',
lastName: 'last_name',
lastNotifiedAt: 'last_notified_at',
lastSeenAt: 'last_seen_at',
updatedAt: 'updated_at',
};
const { data } = await client.users.saveUser(user);
console.log(data);
})();
deleteUser
Removes a user and all associated data from the project.
- HTTP Method:
DELETE - Endpoint:
/users/{user_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| userId | string | ✅ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.users.deleteUser('user_id');
console.log(data);
})();
WorkflowsService
A list of all methods in the WorkflowsService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| saveWorkflow | Creates or updates a workflow definition for the project |
| fetchWorkflow | Retrieves a workflow definition by key |
| createWorkflowRun | Executes a workflow with the provided input parameters |
| fetchWorkflowRun | Retrieves the status and details of a workflow run |
| listWorkflowRuns | Retrieves all runs for a specific workflow |
saveWorkflow
Creates or updates a workflow definition for the project
- HTTP Method:
PUT - Endpoint:
/workflows
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | WorkflowDefinition | ❌ | The request body. |
Return Type
WorkflowDefinition
Example Usage Code Snippet
import { Client, Steps, WorkflowDefinition } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const steps: Steps = {
command: 'command',
if: 'if',
input: {},
};
const workflowDefinition: WorkflowDefinition = {
disabled: true,
key: 'key',
steps: [steps],
};
const { data } = await client.workflows.saveWorkflow(workflowDefinition);
console.log(data);
})();
fetchWorkflow
Retrieves a workflow definition by key
- HTTP Method:
GET - Endpoint:
/workflows/*
Return Type
WorkflowDefinition
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.workflows.fetchWorkflow();
console.log(data);
})();
createWorkflowRun
Executes a workflow with the provided input parameters
- HTTP Method:
POST - Endpoint:
/workflows/runs
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | ExecuteWorkflowRequest | ❌ | The request body. |
Return Type
CreateRunResponse
Example Usage Code Snippet
import { Client, ExecuteWorkflowRequest } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const executeWorkflowRequest: ExecuteWorkflowRequest = {
input: {},
key: 'key',
};
const { data } = await client.workflows.createWorkflowRun(executeWorkflowRequest);
console.log(data);
})();
fetchWorkflowRun
Retrieves the status and details of a workflow run
- HTTP Method:
GET - Endpoint:
/workflows/runs/{run_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| runId | string | ✅ |
Return Type
GetRunResponse
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.workflows.fetchWorkflowRun('run_id');
console.log(data);
})();
listWorkflowRuns
Retrieves all runs for a specific workflow
- HTTP Method:
GET - Endpoint:
/workflows/{workflow_key}/runs
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| workflowKey | string | ✅ |
Return Type
WorkflowRunCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/project-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.workflows.listWorkflowRuns('workflow_key');
console.log(data);
})();
Models
The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.
Below is a list of all available models with links to their detailed documentation:
UserClient
Authentication
Access Token Authentication
The Client API uses an Access Token for authentication.
This token must be provided to authenticate your requests to the API.
Setting the Access Token
When you initialize the SDK, you can set the access token as follows:
const sdk = new Client({ token: 'YOUR_TOKEN' });
If you need to set or update the access token after initializing the SDK, you can use:
const sdk = new Client();
sdk.token = 'YOUR_TOKEN';
Setting a Custom Timeout
You can set a custom timeout for the SDK's HTTP requests as follows:
const client = new Client({ timeout: 10000 });
Sample Usage
Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listInboxTokens({
limit: 123,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
Services
The SDK provides various services to interact with the API.
ChannelsService
A list of all methods in the ChannelsService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| listInboxTokens | Lists all Inbox tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. |
| saveInboxToken | 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. |
| fetchInboxToken | 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. |
| deleteInboxToken | 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. |
| listApnsTokens | Lists all APNs tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. |
| saveApnsToken | 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. |
| fetchApnsToken | 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. |
| deleteApnsToken | 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. |
| listExpoTokens | Lists all Expo tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. |
| saveExpoToken | 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. |
| fetchExpoToken | 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. |
| deleteExpoToken | 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. |
| listFcmTokens | Lists all FCM tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. |
| saveFcmToken | 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. |
| fetchFcmToken | 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. |
| deleteFcmToken | 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. |
| listMagicbellSlackbotTokens | Lists all MagicBell SlackBot tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. |
| saveMagicbellSlackbotToken | Saves the MagicBell SlackBot 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. |
| fetchMagicbellSlackbotToken | Fetches details of a specific MagicBell SlackBot 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. |
| deleteMagicbellSlackbotToken | Deletes one of the authenticated user's MagicBell SlackBot 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. |
| listSlackTokens | Lists all Slack tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. |
| saveSlackToken | 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. |
| fetchSlackToken | 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. |
| deleteSlackToken | 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. |
| listTeamsTokens | Lists all Teams tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. |
| saveTeamsToken | 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. |
| fetchTeamsToken | 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. |
| deleteTeamsToken | 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. |
| fetchUserPreferences | Fetch a user's channel delivery preferences. |
| saveUserPreferences | Save a user's channel preferences. |
| listWebPushTokens | Lists all Web Push tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata. |
| saveWebPushToken | 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. |
| fetchWebPushToken | 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. |
| deleteWebPushToken | 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. |
listInboxTokens
Lists all Inbox tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
- HTTP Method:
GET - Endpoint:
/channels/in_app/inbox/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
InboxTokenResponseCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listInboxTokens({
limit: 123,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
saveInboxToken
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.
- HTTP Method:
PUT - Endpoint:
/channels/in_app/inbox/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | InboxToken | ❌ | The request body. |
Return Type
InboxToken
Example Usage Code Snippet
import { Client, InboxToken } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const inboxToken: InboxToken = {
connectionId: 'connection_id',
token: 'insint adipisic',
};
const { data } = await client.channels.saveInboxToken(inboxToken);
console.log(data);
})();
fetchInboxToken
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.
- HTTP Method:
GET - Endpoint:
/channels/in_app/inbox/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
InboxTokenResponse
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchInboxToken('token_id');
console.log(data);
})();
deleteInboxToken
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.
- HTTP Method:
DELETE - Endpoint:
/channels/in_app/inbox/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteInboxToken('token_id');
console.log(data);
})();
listApnsTokens
Lists all APNs tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
- HTTP Method:
GET - Endpoint:
/channels/mobile_push/apns/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
ApnsTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listApnsTokens({
limit: 10,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
saveApnsToken
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.
- HTTP Method:
PUT - Endpoint:
/channels/mobile_push/apns/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | ApnsTokenPayload | ❌ | The request body. |
Return Type
ApnsTokenPayload
Example Usage Code Snippet
import { ApnsTokenPayload, ApnsTokenPayloadInstallationId, Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const apnsTokenPayloadInstallationId = ApnsTokenPayloadInstallationId.DEVELOPMENT;
const apnsTokenPayload: ApnsTokenPayload = {
appId: 'app_id',
deviceToken: 'doea occaecat q',
installationId: apnsTokenPayloadInstallationId,
};
const { data } = await client.channels.saveApnsToken(apnsTokenPayload);
console.log(data);
})();
fetchApnsToken
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.
- HTTP Method:
GET - Endpoint:
/channels/mobile_push/apns/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
ApnsToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchApnsToken('token_id');
console.log(data);
})();
deleteApnsToken
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.
- HTTP Method:
DELETE - Endpoint:
/channels/mobile_push/apns/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteApnsToken('token_id');
console.log(data);
})();
listExpoTokens
Lists all Expo tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
- HTTP Method:
GET - Endpoint:
/channels/mobile_push/expo/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
ExpoTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listExpoTokens({
limit: 8,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
saveExpoToken
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.
- HTTP Method:
PUT - Endpoint:
/channels/mobile_push/expo/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | ExpoTokenPayload | ❌ | The request body. |
Return Type
ExpoTokenPayload
Example Usage Code Snippet
import { Client, ExpoTokenPayload } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const expoTokenPayload: ExpoTokenPayload = {
deviceToken: 'device_token',
};
const { data } = await client.channels.saveExpoToken(expoTokenPayload);
console.log(data);
})();
fetchExpoToken
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.
- HTTP Method:
GET - Endpoint:
/channels/mobile_push/expo/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
ExpoToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchExpoToken('token_id');
console.log(data);
})();
deleteExpoToken
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.
- HTTP Method:
DELETE - Endpoint:
/channels/mobile_push/expo/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteExpoToken('token_id');
console.log(data);
})();
listFcmTokens
Lists all FCM tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
- HTTP Method:
GET - Endpoint:
/channels/mobile_push/fcm/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
FcmTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listFcmTokens({
limit: 3,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
saveFcmToken
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.
- HTTP Method:
PUT - Endpoint:
/channels/mobile_push/fcm/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | FcmTokenPayload | ❌ | The request body. |
Return Type
FcmTokenPayload
Example Usage Code Snippet
import { Client, FcmTokenPayload } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const fcmTokenPayload: FcmTokenPayload = {
deviceToken: 'voluptate incid',
};
const { data } = await client.channels.saveFcmToken(fcmTokenPayload);
console.log(data);
})();
fetchFcmToken
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.
- HTTP Method:
GET - Endpoint:
/channels/mobile_push/fcm/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
FcmToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchFcmToken('token_id');
console.log(data);
})();
deleteFcmToken
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.
- HTTP Method:
DELETE - Endpoint:
/channels/mobile_push/fcm/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteFcmToken('token_id');
console.log(data);
})();
listMagicbellSlackbotTokens
Lists all MagicBell SlackBot tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
- HTTP Method:
GET - Endpoint:
/channels/slack/magicbell_slackbot/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
SlackTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listMagicbellSlackbotTokens({
limit: 2,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
saveMagicbellSlackbotToken
Saves the MagicBell SlackBot 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.
- HTTP Method:
PUT - Endpoint:
/channels/slack/magicbell_slackbot/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackTokenPayload | ❌ | The request body. |
Return Type
SlackTokenPayload
Example Usage Code Snippet
import { Client, SlackTokenPayload, SlackTokenPayloadOauth, SlackTokenPayloadWebhook } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const slackTokenPayloadOauth: SlackTokenPayloadOauth = {
channelId: 'channel_id',
installationId: 'installation_id',
scope: 'scope',
};
const slackTokenPayloadWebhook: SlackTokenPayloadWebhook = {
url: 'url',
};
const slackTokenPayload: SlackTokenPayload = {
oauth: slackTokenPayloadOauth,
webhook: slackTokenPayloadWebhook,
};
const { data } = await client.channels.saveMagicbellSlackbotToken(slackTokenPayload);
console.log(data);
})();
fetchMagicbellSlackbotToken
Fetches details of a specific MagicBell SlackBot 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.
- HTTP Method:
GET - Endpoint:
/channels/slack/magicbell_slackbot/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
SlackToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchMagicbellSlackbotToken('token_id');
console.log(data);
})();
deleteMagicbellSlackbotToken
Deletes one of the authenticated user's MagicBell SlackBot 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.
- HTTP Method:
DELETE - Endpoint:
/channels/slack/magicbell_slackbot/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteMagicbellSlackbotToken('token_id');
console.log(data);
})();
listSlackTokens
Lists all Slack tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
- HTTP Method:
GET - Endpoint:
/channels/slack/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
SlackTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listSlackTokens({
limit: 4,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
saveSlackToken
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.
- HTTP Method:
PUT - Endpoint:
/channels/slack/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackTokenPayload | ❌ | The request body. |
Return Type
SlackTokenPayload
Example Usage Code Snippet
import { Client, SlackTokenPayload, SlackTokenPayloadOauth, SlackTokenPayloadWebhook } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const slackTokenPayloadOauth: SlackTokenPayloadOauth = {
channelId: 'channel_id',
installationId: 'installation_id',
scope: 'scope',
};
const slackTokenPayloadWebhook: SlackTokenPayloadWebhook = {
url: 'url',
};
const slackTokenPayload: SlackTokenPayload = {
oauth: slackTokenPayloadOauth,
webhook: slackTokenPayloadWebhook,
};
const { data } = await client.channels.saveSlackToken(slackTokenPayload);
console.log(data);
})();
fetchSlackToken
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.
- HTTP Method:
GET - Endpoint:
/channels/slack/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
SlackToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchSlackToken('token_id');
console.log(data);
})();
deleteSlackToken
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.
- HTTP Method:
DELETE - Endpoint:
/channels/slack/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteSlackToken('token_id');
console.log(data);
})();
listTeamsTokens
Lists all Teams tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
- HTTP Method:
GET - Endpoint:
/channels/teams/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
TeamsTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listTeamsTokens({
limit: 123,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
saveTeamsToken
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.
- HTTP Method:
PUT - Endpoint:
/channels/teams/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | TeamsTokenPayload | ❌ | The request body. |
Return Type
TeamsTokenPayload
Example Usage Code Snippet
import { Client, TeamsTokenPayload, TeamsTokenPayloadWebhook } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const teamsTokenPayloadWebhook: TeamsTokenPayloadWebhook = {
url: 'url',
};
const teamsTokenPayload: TeamsTokenPayload = {
webhook: teamsTokenPayloadWebhook,
};
const { data } = await client.channels.saveTeamsToken(teamsTokenPayload);
console.log(data);
})();
fetchTeamsToken
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.
- HTTP Method:
GET - Endpoint:
/channels/teams/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
TeamsToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchTeamsToken('token_id');
console.log(data);
})();
deleteTeamsToken
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.
- HTTP Method:
DELETE - Endpoint:
/channels/teams/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteTeamsToken('token_id');
console.log(data);
})();
fetchUserPreferences
Fetch a user's channel delivery preferences.
- HTTP Method:
GET - Endpoint:
/channels/user_preferences
Return Type
UserPreferences
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchUserPreferences();
console.log(data);
})();
saveUserPreferences
Save a user's channel preferences.
- HTTP Method:
PUT - Endpoint:
/channels/user_preferences
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | UserPreferences | ❌ | The request body. |
Example Usage Code Snippet
import { Categories, Channels, Client, UserPreferences } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const channels: Channels = {
enabled: true,
name: 'name',
};
const categories: Categories = {
channels: [channels],
key: 'key',
label: 'label',
};
const userPreferences: UserPreferences = {
categories: [categories],
};
const { data } = await client.channels.saveUserPreferences(userPreferences);
console.log(data);
})();
listWebPushTokens
Lists all Web Push tokens belonging to the authenticated user. Returns a paginated list of tokens, including their status, creation dates, and associated metadata.
- HTTP Method:
GET - Endpoint:
/channels/web_push/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ |
Return Type
WebPushTokenCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.listWebPushTokens({
limit: 1,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
});
console.log(data);
})();
saveWebPushToken
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.
- HTTP Method:
PUT - Endpoint:
/channels/web_push/tokens
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | WebPushTokenPayload | ❌ | The request body. |
Return Type
WebPushTokenPayload
Example Usage Code Snippet
import { Client, WebPushTokenPayload, WebPushTokenPayloadKeys } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const webPushTokenPayloadKeys: WebPushTokenPayloadKeys = {
auth: 'auth',
p256dh: 'p256dh',
};
const webPushTokenPayload: WebPushTokenPayload = {
endpoint: 'endpoint',
keys: webPushTokenPayloadKeys,
};
const { data } = await client.channels.saveWebPushToken(webPushTokenPayload);
console.log(data);
})();
fetchWebPushToken
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.
- HTTP Method:
GET - Endpoint:
/channels/web_push/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
WebPushToken
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.fetchWebPushToken('token_id');
console.log(data);
})();
deleteWebPushToken
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.
- HTTP Method:
DELETE - Endpoint:
/channels/web_push/tokens/{token_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| tokenId | string | ✅ |
Return Type
DiscardResult
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.channels.deleteWebPushToken('token_id');
console.log(data);
})();
IntegrationsService
A list of all methods in the IntegrationsService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| saveInboxInstallation | 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. |
| startInboxInstallation | 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. |
| saveMagicbellSlackbotInstallation | Creates a new installation of a MagicBell SlackBot integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration. |
| finishMagicbellSlackbotInstallation | Completes the installation flow for the MagicBell SlackBot integration. This endpoint is typically called after the user has completed any required authorization steps with MagicBell SlackBot. |
| startMagicbellSlackbotInstallation | Initiates the installation flow for a MagicBell SlackBot integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required. |
| saveSlackInstallation | 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. |
| finishSlackInstallation | Completes the installation flow for the Slack integration. This endpoint is typically called after the user has completed any required authorization steps with Slack. |
| startSlackInstallation | 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. |
| saveWebPushInstallation | 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. |
| startWebPushInstallation | 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. |
saveInboxInstallation
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.
- HTTP Method:
PUT - Endpoint:
/integrations/inbox/installations
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | InboxConfigPayload | ❌ | The request body. |
Return Type
InboxConfigPayload
Example Usage Code Snippet
import {
Banner,
Client,
DefaultHover,
DefaultState,
Default_,
Dialog,
Footer,
Header,
Icon,
Images,
InboxConfigPayload,
Theme,
ThemeNotification,
Unread,
UnreadHover,
UnreadState,
Unseen,
UnseenBadge,
UnseenHover,
UnseenState,
} from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const images: Images = {
emptyInboxUrl: 'emptyInboxUrl',
};
const banner: Banner = {
backgroundColor: 'backgroundColor',
backgroundOpacity: 8.51,
fontSize: 'fontSize',
textColor: 'textColor',
};
const dialog: Dialog = {
accentColor: 'accentColor',
backgroundColor: 'backgroundColor',
textColor: 'textColor',
};
const footer: Footer = {
backgroundColor: 'backgroundColor',
borderRadius: 'borderRadius',
fontSize: 'fontSize',
textColor: 'textColor',
};
const header: Header = {
backgroundColor: 'backgroundColor',
borderRadius: 'borderRadius',
fontFamily: 'fontFamily',
fontSize: 'fontSize',
textColor: 'textColor',
};
const icon: Icon = {
borderColor: 'borderColor',
width: 'width',
};
const defaultHover: DefaultHover = {
backgroundColor: 'backgroundColor',
};
const defaultState: DefaultState = {
color: 'color',
};
const default_: Default_ = {
backgroundColor: 'backgroundColor',
borderRadius: 'borderRadius',
fontFamily: 'fontFamily',
fontSize: 'fontSize',
hover: defaultHover,
margin: 'margin',
state: defaultState,
textColor: 'textColor',
};
const unreadHover: UnreadHover = {
backgroundColor: 'backgroundColor',
};
const unreadState: UnreadState = {
color: 'color',
};
const unread: Unread = {
backgroundColor: 'backgroundColor',
hover: unreadHover,
state: unreadState,
textColor: 'textColor',
};
const unseenHover: UnseenHover = {
backgroundColor: 'backgroundColor',
};
const unseenState: UnseenState = {
color: 'color',
};
const unseen: Unseen = {
backgroundColor: 'backgroundColor',
hover: unseenHover,
state: unseenState,
textColor: 'textColor',
};
const themeNotification: ThemeNotification = {
default: default_,
unread: unread,
unseen: unseen,
};
const unseenBadge: UnseenBadge = {
backgroundColor: 'backgroundColor',
};
const theme: Theme = {
banner: banner,
dialog: dialog,
footer: footer,
header: header,
icon: icon,
notification: themeNotification,
unseenBadge: unseenBadge,
};
const inboxConfigPayload: InboxConfigPayload = {
images: images,
locale: 'locale',
theme: theme,
};
const { data } = await client.integrations.saveInboxInstallation(inboxConfigPayload);
console.log(data);
})();
startInboxInstallation
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.
- HTTP Method:
POST - Endpoint:
/integrations/inbox/installations/start
Return Type
InboxConfigPayload
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.startInboxInstallation();
console.log(data);
})();
saveMagicbellSlackbotInstallation
Creates a new installation of a MagicBell SlackBot integration for a user. This endpoint is used when an integration needs to be set up with user-specific credentials or configuration.
- HTTP Method:
PUT - Endpoint:
/integrations/magicbell_slackbot/installations
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackInstallation | ❌ | The request body. |
Return Type
SlackInstallation
Example Usage Code Snippet
import { AuthedUser, Client, Enterprise, IncomingWebhook, SlackInstallation, Team } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const authedUser: AuthedUser = {
accessToken: 'access_token',
expiresIn: 123,
id: 'id',
refreshToken: 'refresh_token',
scope: 'scope',
tokenType: 'token_type',
};
const enterprise: Enterprise = {
id: 'id',
name: 'name',
};
const incomingWebhook: IncomingWebhook = {
channel: 'channel',
configurationUrl: 'configuration_url',
url: 'url',
};
const team: Team = {
id: 'id',
name: 'name',
};
const slackInstallation: SlackInstallation = {
accessToken: 'access_token',
appId: 'app_id',
authedUser: authedUser,
botUserId: 'bot_user_id',
enterprise: enterprise,
expiresIn: 1,
id: '8-P^R',
incomingWebhook: incomingWebhook,
isEnterpriseInstall: true,
refreshToken: 'refresh_token',
scope: 'scope',
team: team,
tokenType: 'token_type',
};
const { data } = await client.integrations.saveMagicbellSlackbotInstallation(slackInstallation);
console.log(data);
})();
finishMagicbellSlackbotInstallation
Completes the installation flow for the MagicBell SlackBot integration. This endpoint is typically called after the user has completed any required authorization steps with MagicBell SlackBot.
- HTTP Method:
POST - Endpoint:
/integrations/magicbell_slackbot/installations/finish
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackFinishInstallResponse | ❌ | The request body. |
Return Type
SlackInstallation
Example Usage Code Snippet
import { Client, SlackFinishInstallResponse } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const slackFinishInstallResponse: SlackFinishInstallResponse = {
appId: 'app_id',
code: 'code',
redirectUrl: 'redirect_url',
};
const { data } = await client.integrations.finishMagicbellSlackbotInstallation(slackFinishInstallResponse);
console.log(data);
})();
startMagicbellSlackbotInstallation
Initiates the installation flow for a MagicBell SlackBot integration. This is the first step in a multi-step installation process where user authorization or external service configuration may be required.
- HTTP Method:
POST - Endpoint:
/integrations/magicbell_slackbot/installations/start
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackStartInstall | ❌ | The request body. |
Return Type
SlackStartInstallResponseContent
Example Usage Code Snippet
import { Client, SlackStartInstall } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const slackStartInstall: SlackStartInstall = {
appId: 'app_id',
authUrl: 'auth_url',
extraScopes: ['extra_scopes'],
redirectUrl: 'redirect_url',
};
const { data } = await client.integrations.startMagicbellSlackbotInstallation(slackStartInstall);
console.log(data);
})();
saveSlackInstallation
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.
- HTTP Method:
PUT - Endpoint:
/integrations/slack/installations
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackInstallation | ❌ | The request body. |
Return Type
SlackInstallation
Example Usage Code Snippet
import { AuthedUser, Client, Enterprise, IncomingWebhook, SlackInstallation, Team } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const authedUser: AuthedUser = {
accessToken: 'access_token',
expiresIn: 123,
id: 'id',
refreshToken: 'refresh_token',
scope: 'scope',
tokenType: 'token_type',
};
const enterprise: Enterprise = {
id: 'id',
name: 'name',
};
const incomingWebhook: IncomingWebhook = {
channel: 'channel',
configurationUrl: 'configuration_url',
url: 'url',
};
const team: Team = {
id: 'id',
name: 'name',
};
const slackInstallation: SlackInstallation = {
accessToken: 'access_token',
appId: 'app_id',
authedUser: authedUser,
botUserId: 'bot_user_id',
enterprise: enterprise,
expiresIn: 1,
id: '8-P^R',
incomingWebhook: incomingWebhook,
isEnterpriseInstall: true,
refreshToken: 'refresh_token',
scope: 'scope',
team: team,
tokenType: 'token_type',
};
const { data } = await client.integrations.saveSlackInstallation(slackInstallation);
console.log(data);
})();
finishSlackInstallation
Completes the installation flow for the Slack integration. This endpoint is typically called after the user has completed any required authorization steps with Slack.
- HTTP Method:
POST - Endpoint:
/integrations/slack/installations/finish
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackFinishInstallResponse | ❌ | The request body. |
Return Type
SlackInstallation
Example Usage Code Snippet
import { Client, SlackFinishInstallResponse } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const slackFinishInstallResponse: SlackFinishInstallResponse = {
appId: 'app_id',
code: 'code',
redirectUrl: 'redirect_url',
};
const { data } = await client.integrations.finishSlackInstallation(slackFinishInstallResponse);
console.log(data);
})();
startSlackInstallation
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.
- HTTP Method:
POST - Endpoint:
/integrations/slack/installations/start
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | SlackStartInstall | ❌ | The request body. |
Return Type
SlackStartInstallResponseContent
Example Usage Code Snippet
import { Client, SlackStartInstall } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const slackStartInstall: SlackStartInstall = {
appId: 'app_id',
authUrl: 'auth_url',
extraScopes: ['extra_scopes'],
redirectUrl: 'redirect_url',
};
const { data } = await client.integrations.startSlackInstallation(slackStartInstall);
console.log(data);
})();
saveWebPushInstallation
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.
- HTTP Method:
PUT - Endpoint:
/integrations/web_push/installations
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| body | WebPushTokenPayload | ❌ | The request body. |
Return Type
WebPushTokenPayload
Example Usage Code Snippet
import { Client, WebPushTokenPayload, WebPushTokenPayloadKeys } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const webPushTokenPayloadKeys: WebPushTokenPayloadKeys = {
auth: 'auth',
p256dh: 'p256dh',
};
const webPushTokenPayload: WebPushTokenPayload = {
endpoint: 'endpoint',
keys: webPushTokenPayloadKeys,
};
const { data } = await client.integrations.saveWebPushInstallation(webPushTokenPayload);
console.log(data);
})();
startWebPushInstallation
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.
- HTTP Method:
POST - Endpoint:
/integrations/web_push/installations/start
Return Type
WebPushStartInstallationResponse
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.integrations.startWebPushInstallation();
console.log(data);
})();
NotificationsService
A list of all methods in the NotificationsService service. Click on the method name to view detailed information about that method.
| Methods | Description |
|---|---|
| listNotifications | Lists all notifications for a user. |
| archiveAllNotifications | Archive all notifications. |
| markAllNotificationsRead | Marks all notifications as read. |
| fetchNotification | Gets a notification by ID. |
| archiveNotification | Archive a notification. |
| markNotificationRead | Marks a notification as read. |
| unarchiveNotification | Unarchives a notification. |
| markNotificationUnread | Marks a notification as unread. |
listNotifications
Lists all notifications for a user.
- HTTP Method:
GET - Endpoint:
/notifications
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | number | ❌ | |
| startingAfter | string | ❌ | |
| endingBefore | string | ❌ | |
| status | string | ❌ | |
| category | string | ❌ | |
| topic | string | ❌ |
Return Type
NotificationCollection
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.notifications.listNotifications({
limit: 5,
startingAfter: 'starting_after',
endingBefore: 'ending_before',
status: 'status',
category: 'category',
topic: 'topic',
});
console.log(data);
})();
archiveAllNotifications
Archive all notifications.
- HTTP Method:
POST - Endpoint:
/notifications/archive
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| category | string | ❌ | |
| topic | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.notifications.archiveAllNotifications({
category: 'category',
topic: 'topic',
});
console.log(data);
})();
markAllNotificationsRead
Marks all notifications as read.
- HTTP Method:
POST - Endpoint:
/notifications/read
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| category | string | ❌ | |
| topic | string | ❌ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.notifications.markAllNotificationsRead({
category: 'category',
topic: 'topic',
});
console.log(data);
})();
fetchNotification
Gets a notification by ID.
- HTTP Method:
GET - Endpoint:
/notifications/{notification_id}
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| notificationId | string | ✅ |
Return Type
Notification
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.notifications.fetchNotification('notification_id');
console.log(data);
})();
archiveNotification
Archive a notification.
- HTTP Method:
POST - Endpoint:
/notifications/{notification_id}/archive
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| notificationId | string | ✅ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.notifications.archiveNotification('notification_id');
console.log(data);
})();
markNotificationRead
Marks a notification as read.
- HTTP Method:
POST - Endpoint:
/notifications/{notification_id}/read
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| notificationId | string | ✅ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.notifications.markNotificationRead('notification_id');
console.log(data);
})();
unarchiveNotification
Unarchives a notification.
- HTTP Method:
POST - Endpoint:
/notifications/{notification_id}/unarchive
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| notificationId | string | ✅ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.notifications.unarchiveNotification('notification_id');
console.log(data);
})();
markNotificationUnread
Marks a notification as unread.
- HTTP Method:
POST - Endpoint:
/notifications/{notification_id}/unread
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| notificationId | string | ✅ |
Example Usage Code Snippet
import { Client } from 'magicbell-js/user-client';
(async () => {
const client = new Client({
token: 'YOUR_TOKEN',
});
const { data } = await client.notifications.markNotificationUnread('notification_id');
console.log(data);
})();
Models
The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.
Below is a list of all available models with links to their detailed documentation:
Realtime
The Realtime client enables real-time notification delivery through WebSocket connections. When new notifications are created for a user, they are instantly pushed to connected clients without requiring polling.
Authentication
The Realtime client requires a user access token for authentication. This can be provided either directly or through an existing UserClient instance.
Sample Usage
import { Realtime } from 'magicbell-js/realtime';
const realtime = new Realtime({ token: 'USER_ACCESS_TOKEN' });
realtime.listen((notification) => {
console.log('New notification received:', notification.title);
// Handle the notification (update UI, show toast, etc.)
});
// When done listening
realtime.disconnect();
Using with UserClient
You can also initialize the Realtime client with an existing UserClient:
import { Client } from 'magicbell-js/user-client';
import { Realtime } from 'magicbell-js/realtime';
const userClient = new Client({ token: 'USER_ACCESS_TOKEN' });
const realtime = new Realtime(userClient);
realtime.listen((notification) => {
console.log('New notification:', notification);
});
Connection Management
The Realtime client automatically handles connection management, including reconnection attempts when the connection is lost:
// Check if currently connected
if (realtime.isListening()) {
console.log('Connected to real-time notifications');
}
// Disconnect when no longer needed
realtime.disconnect();