Node.js SDK
Setup & Initialization
- Install using one of the following package managers:
npm install pingram
yarn add pingram
pnpm add pingram
- Import:
import { Pingram } from 'pingram';
- Initialize:
const pingram = new Pingram({
apiKey: 'pingram_sk_...' // Your API key from the dashboard
});
| Name | Type | Description |
|---|---|---|
apiKey* | string | Your Pingram API key. You can get it from your dashboard under Environments. |
accessToken | string | Optional JWT token for end-user authentication (for internal use) |
baseURL | string | Optional. To choose a different region other than default (US). Use https://api.ca.pingram.io for the Canada region, and https://api.eu.pingram.io for the EU region. |
- required
Region specific example:
import { Pingram } from 'pingram';
const pingram = new Pingram({
apiKey: 'pingram_sk_...',
baseURL: 'https://api.eu.pingram.io'
});
Send
send()
Send a notification
// Request body only
await pingram.send({
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| senderPostBody | SenderPostBody | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
notificationId | string | |
user | GetUsersResponseUsersInner | |
mergeTags | object | |
replace | { [key: string]: string; } | |
type | string | |
to | SenderPostBodyTo | |
forceChannels | Array<ChannelsEnum> | |
parameters | { [key: string]: any; } | |
secondaryId | string | |
templateId | string | |
subNotificationId | string | |
options | SenderPostBodyOptions | |
schedule | string | |
email | SenderPostBodyEmail | |
inapp | SenderPostBodyInapp | |
sms | SenderPostBodySms | |
call | SenderPostBodySmsAutoReply | |
webPush | SenderPostBodyWebPush | |
mobilePush | SenderPostBodyMobilePush | |
slack | SenderPostBodySlack |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
Domains
addDomain()
Request to verify a new sender domain or email address
// Request body only
await pingram.domains.addDomain({
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| postSendersRequestBody | PostSendersRequestBody | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
sender | string |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
deleteDomain()
Delete a sender domain or email address
// Path parameter only
await pingram.domains.deleteDomain('sender_example');
Parameters
| Name | Type | Description |
|---|---|---|
| sender | string | Sender domain or email address (URL encoded) |
listDomains()
Get all sender domains and email addresses configured for the account
// No parameters
await pingram.domains.listDomains();
Parameters
This endpoint does not need any parameter.
Environments
createEnvironment()
Create a new environment for the account
// Request body only
await pingram.environments.createEnvironment({
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| environmentCreateRequest | EnvironmentCreateRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
title | string |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
listEnvironments()
Get all environments for the authenticated account
// No parameters
await pingram.environments.listEnvironments();
Parameters
This endpoint does not need any parameter.
updateEnvironment()
Update environment settings (title, secret, disable sending, secure mode)
// Path parameter + request body
await pingram.environments.updateEnvironment('', {
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| clientId | string | Environment client ID |
| environmentPatchRequest | EnvironmentPatchRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
resetSecret | boolean | |
disableSending | Array<ChannelsEnum> | |
title | string | |
secureMode | boolean |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
Logs
getLogRetention()
Get log retention period in days for the account
// No parameters
await pingram.logs.getLogRetention();
Parameters
This endpoint does not need any parameter.
getLogsByTrackingIds()
Get logs by tracking IDs (comma-separated, max 25 IDs)
// Path parameter only
await pingram.logs.getLogsByTrackingIds('trackingIds_example');
Parameters
| Name | Type | Description |
|---|---|---|
| trackingIds | string | Comma-separated tracking IDs (URL encoded) |
getLogsQueryResult()
Get results from a query ID
// Path parameter only
await pingram.logs.getLogsQueryResult('queryId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| queryId | string | Query ID |
startLogsQuery()
Start a log query and return query ID for asynchronous log searching
// Request body only
await pingram.logs.startLogsQuery({
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| logQueryPostBody | LogQueryPostBody | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
dateRangeFilter | Array<number> | A tuple of [startTime, endTime] for the date range filter, each representing a unix timestamp. |
userFilter | string | |
envIdFilter | Array<string> | |
statusFilter | string | |
channelFilter | Array<string> | |
notificationFilter | Array<string> |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
tailLogs()
Get last 100 logs from the stream
// No parameters
await pingram.logs.tailLogs();
Parameters
This endpoint does not need any parameter.
Sender
deleteSchedule()
Delete (unschedule) an already scheduled notification
// Path parameter only
await pingram.sender.deleteSchedule('trackingId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| trackingId | string | The tracking ID of the scheduled notification |
updateSchedule()
Update the body or schedule of an already scheduled notification.
// Path parameter + request body
await pingram.sender.updateSchedule('', {
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| trackingId | string | The tracking ID of the scheduled notification |
| senderPostBody | SenderPostBody | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
notificationId | string | |
user | GetUsersResponseUsersInner | |
mergeTags | object | |
replace | { [key: string]: string; } | |
type | string | |
to | SenderPostBodyTo | |
forceChannels | Array<ChannelsEnum> | |
parameters | { [key: string]: any; } | |
secondaryId | string | |
templateId | string | |
subNotificationId | string | |
options | SenderPostBodyOptions | |
schedule | string | |
email | SenderPostBodyEmail | |
inapp | SenderPostBodyInapp | |
sms | SenderPostBodySms | |
call | SenderPostBodySmsAutoReply | |
webPush | SenderPostBodyWebPush | |
mobilePush | SenderPostBodyMobilePush | |
slack | SenderPostBodySlack |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
Templates
createTemplate()
Create a new template for a notification
// Path parameter + request body
await pingram.templates.createTemplate('', {
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| notificationId | string | Notification ID |
| channel | string | Channel type |
| templatePostRequest | TemplatePostRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
templateId | string |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
deleteTemplate()
Delete a template
// Path parameter only
await pingram.templates.deleteTemplate('notificationId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| notificationId | string | Notification ID |
| channel | string | Channel type |
| templateId | string | Template ID |
listTemplates()
Get template(s) for a notification
// Path parameter only
await pingram.templates.listTemplates('notificationId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| notificationId | string | Notification ID |
| channel | string | Channel type |
| templateId | string | Template ID (optional for listing all) |
setDefaultTemplate()
Set a template as default for specific delivery modes
// Path parameter + request body
await pingram.templates.setDefaultTemplate('', {
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| notificationId | string | Notification ID |
| channel | string | Channel type |
| setDefaultTemplateRequest | SetDefaultTemplateRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
templateId | string | |
modes | Array<string> |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
updateTemplate()
Update a template's properties
// Path parameter + request body
await pingram.templates.updateTemplate('', {
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| notificationId | string | Notification ID |
| channel | string | Channel type |
| templateId | string | Template ID |
| templatePatchRequest | TemplatePatchRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
html | string | |
internal | string | |
subject | string | |
senderName | string | |
senderEmail | string | |
migration | string | |
title | string | |
redirectURL | string | |
imageURL | string | |
instant | TemplatePatchRequestAnyOf1Instant | |
batch | TemplatePatchRequestAnyOf1Batch |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
Types
createNotificationType()
Create a new notification
// Request body only
await pingram.types.createNotificationType({
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| notificationCreateRequest | NotificationCreateRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
notificationId | string | |
title | string | |
channels | Array<string> | |
options | GetNotificationsResponseInnerOptions |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
deleteNotificationType()
Delete a notification
// Path parameter only
await pingram.types.deleteNotificationType('notificationId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| notificationId | string | The notification ID |
getNotificationType()
Get a specific notification by ID
// Path parameter only
await pingram.types.getNotificationType('notificationId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| notificationId | string | The notification ID |
listNotificationTypes()
Get all notifications for an account with their templates
// No parameters
await pingram.types.listNotificationTypes();
Parameters
This endpoint does not need any parameter.
updateNotificationType()
Update a notification's settings
// Path parameter + request body
await pingram.types.updateNotificationType('', {
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| notificationId | string | The notification ID |
| notificationPatchRequest | NotificationPatchRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
title | string | |
channels | Array<ChannelsEnum> | |
enabled | boolean | |
deduplication | GetNotificationsResponseInnerDeduplication | |
throttling | GetNotificationsResponseInnerThrottling | |
retention | number | |
options | GetNotificationsResponseInnerOptions |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
User
getAccountMetadata()
Get account-level metadata including logo, VAPID key, and web push status
// No parameters
await pingram.user.getAccountMetadata();
Parameters
This endpoint does not need any parameter.
getAvailableSlackChannels()
Get list of Slack channels and users for the authenticated user
// Path parameter only
await pingram.user.getAvailableSlackChannels('userId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| userId | string | User ID |
getInAppNotifications()
Get in-app notifications for a user
// No parameters
await pingram.user.getInAppNotifications();
Parameters
| Name | Type | Description |
|---|---|---|
| before | string | Timestamp or ISO date to fetch notifications before |
| count | number | Number of notifications to return (default 10) |
getInAppUnreadCount()
Get the count of unread in-app notifications for a user
// No parameters
await pingram.user.getInAppUnreadCount();
Parameters
This endpoint does not need any parameter.
getUser()
Get a user by ID. All users exist implicitly, returns basic user object if not found in DB.
// Path parameter only
await pingram.user.getUser('userId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| userId | string | User ID |
identify()
Create or update a user with the given ID. Updates lastSeenTime automatically.
// Path parameter + request body
await pingram.user.identify('', {
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| userId | string | User ID |
| postUserRequest | PostUserRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
id | string | |
email | string | |
number | string | |
pushTokens | Array<GetUsersResponseUsersInnerPushTokensInner> | |
webPushTokens | Array<GetUsersResponseUsersInnerWebPushTokensInner> | |
timezone | string | |
slackChannel | string | The destination channel of slack notifications sent to this user. Can be either of the following: - Channel name, e.g. “test” - Channel name with # prefix, e.g. “#test” - Channel ID, e.g. “C1234567890” - User ID for DM, e.g. “U1234567890” - Username with @ prefix, e.g. “@test” |
slackToken | GetUsersResponseUsersInnerSlackToken |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
markInAppNotificationsAsSeen()
Mark in-app web notifications as seen/read for a user
// Request body only
await pingram.user.markInAppNotificationsAsSeen({
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| inAppNotificationUnreadClearRequest | InAppNotificationUnreadClearRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
notificationId | string | |
trackingId | string |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
updateInAppNotificationStatus()
Update in-app web notification status (opened, archived, clicked, etc.)
// Request body only
await pingram.user.updateInAppNotificationStatus({
// See Request Body Properties table below for all available fields
// Example structure (adjust based on your needs):
// fieldName: 'value'
});
Parameters
| Name | Type | Description |
|---|---|---|
| inAppNotificationPatchRequest | InAppNotificationPatchRequest | See Request Body Properties below |
Request Body Properties
| Name | Type | Description |
|---|---|---|
trackingIds | Array<string> | |
opened | string | |
clicked | string | |
archived | string | |
actioned1 | string | |
actioned2 | string | |
reply | GetInappNotificationsResponseNotificationsInnerRepliesInner | |
replies | Array<GetInappNotificationsResponseNotificationsInnerRepliesInner> |
For detailed property descriptions and TypeScript type definitions, refer to the generated TypeScript types in the
pingrampackage.
Users
deleteUser()
Delete a user and all associated data (in-app notifications, preferences, and user record)
// Path parameter only
await pingram.users.deleteUser('userId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| userId | string | User ID |
| envId | string | Environment ID (required when using JWT auth) |
listUsers()
Get all users for an environment with pagination support
// No parameters
await pingram.users.listUsers();
Parameters
| Name | Type | Description |
|---|---|---|
| limit | number | Maximum number of users to return (default |
| nextToken | string | Pagination token for next page |
| envId | string | Environment ID (required when using JWT auth) |
removeUserFromSuppression()
Remove user suppression status for a specific channel
// Path parameter only
await pingram.users.removeUserFromSuppression('userId_example');
Parameters
| Name | Type | Description |
|---|---|---|
| userId | string | User ID |
| channel | string | Channel type (EMAIL) |
| envId | string | Environment ID (required when using JWT auth) |