📥 Users module Inbound API
Manage your MailChannels Inbound recipient users.
Create method
Create a recipient user.
Usage
ts
import { MailChannelsClient, Users } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const users = new Users(mailchannels)
const { data, error } = await users.create('name@example.com', {
admin: true
})ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.users.create('name@example.com', {
admin: true
})Params
emailstringrequired: The email address of the user to create.optionsUsersCreateOptionsoptional: Options for creating the user.adminbooleanoptional: Flag to indicate if the user is a domain admin or a regular user.NOTE
If
adminis not set, defaults tofalse.filterboolean | "compute"optional: Whether or not to filter mail for this recipient. There are three valid values. Defaults tocompute.TIP
Possible values are
false,true, andcompute.false: Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, return an error.true: Filtering policy will not be applied to messages intended for this recipient.compute: Filtering policy will be applied to messages intended for this recipient. If this would exceed the protected-addresses limit, filtering policy will not be applied, and no error will be returned.
listEntriesobjectoptional: Safelist and blocklist entries to be added.blockliststring[]optional: A list of items to add to the blocklist.safeliststring[]optional: A list of items to add to the safelist.
Response
dataobject | nullnullableemailstringguaranteedrolesstring[]guaranteedfilterbooleanoptionallistEntriesobject[]guaranteeditemstringguaranteedtype"domain" | "email_address" | "ip_address"guaranteedaction"safelist" | "blocklist"guaranteed
errorstring | nullnullable
Add List Entry method
Add an entry to a recipient user blocklist or safelist.
Usage
ts
import { MailChannelsClient, Users } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const users = new Users(mailchannels)
const { data, error } = await users.addListEntry('name@example.com', {
listName: 'safelist',
item: 'name@domain.com'
})ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.users.addListEntry('name@example.com', {
listName: 'safelist',
item: 'name@domain.com'
})Params
emailstringrequired: The email address of the recipient whose list will be modified.optionsListEntryOptionsrequired: Add list entry options.listName"blocklist" | "safelist" | "blacklist" | "whitelist"required: The list to add the item to.itemstringrequired: The item to add to the list. This can be a domain, email address, or IP address.
Response
dataListEntry | nullnullableaction"blocklist" | "safelist"guaranteeditemstringguaranteedtype"domain" | "email_address" | "ip_address"guaranteed
errorstring | nullnullable
List Entries method
Get recipient list entries.
Usage
ts
import { MailChannelsClient, Users } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const users = new Users(mailchannels)
const { data, error } = await users.listEntries('name@example.com', 'safelist')ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { data, error } = await mailchannels.users.listEntries('name@example.com', 'safelist')Params
emailstringrequired: The email address of the recipient whose list will be fetched.listName"blocklist" | "safelist" | "blacklist" | "whitelist"required: The name of the list to fetch.
Response
dataListEntry[] | nullnullableaction"blocklist" | "safelist"guaranteeditemstringguaranteedtype"domain" | "email_address" | "ip_address"guaranteed
errorstring | nullnullable
Delete List Entry method
Delete item from recipient list.
Usage
ts
import { MailChannelsClient, Users } from 'mailchannels-sdk'
const mailchannels = new MailChannelsClient('your-api-key')
const users = new Users(mailchannels)
const { success, error } = await users.deleteListEntry('name@example.com', {
listName: 'safelist',
item: 'name@domain.com'
})ts
import { MailChannels } from 'mailchannels-sdk'
const mailchannels = new MailChannels('your-api-key')
const { success, error } = await mailchannels.users.deleteListEntry('name@example.com', {
listName: 'safelist',
item: 'name@domain.com'
})Params
emailstringrequired: The email address of the recipient whose list will be modified.optionsListEntryOptionsrequired: Add list entry options.listName"blocklist" | "safelist" | "blacklist" | "whitelist"required: The name of the list to remove an entry from.itemstringrequired: The list entry which should be removed. This can be a domain, email address, or IP address.
Response
successbooleanguaranteed: Whether the operation was successful.errorstring | nullnullable
Type declarations
ts
class Users {
constructor (protected mailchannels: MailChannelsClient);
async create (email: string, options?: UsersCreateOptions): Promise<UsersCreateResponse>;
async addListEntry (email: string, options: ListEntryOptions): Promise<ListEntryResponse>;
async listEntries (email: string, listName: ListNames): Promise<ListEntriesResponse>;
async deleteListEntry (email: string, options: ListEntryOptions): Promise<SuccessResponse>;
}All type declarations
Responses
ts
interface DataResponse<T> {
data: T | null;
error: string | null;
}ts
interface SuccessResponse {
success: boolean;
error: string | null;
}Create type declarations
ts
interface UsersCreateOptions {
admin?: boolean;
filter?: boolean | "compute";
listEntries?: {
blocklist?: string[];
safelist?: string[];
};
}ts
type UsersCreateResponse = DataResponse<{
email: string;
roles: string[];
filter?: boolean;
listEntries: {
item: string;
type: "domain" | "email_address" | "ip_address";
action: "safelist" | "blocklist";
}[];
}>;List Entry type declarations
ts
type ListNames = "blocklist" | "safelist" | "blacklist" | "whitelist";ts
interface ListEntryOptions {
listName: ListNames;
item: string;
}ts
interface ListEntry {
action: Extract<ListNames, "blocklist" | "safelist">;
item: string;
type: "domain" | "email_address" | "ip_address";
}ts
type ListEntryResponse = DataResponse<ListEntry>;ts
type ListEntriesResponse = DataResponse<ListEntry[]>;Source
Source • Playground • Docs