Skip to content

📋 Lists module Inbound API

Manage account-level lists.

Add List Entry method

Add an entry to an account-level blocklist or safelist.

Usage

ts
import { MailChannelsClient, Lists } from 'mailchannels-sdk'

const mailchannels = new MailChannelsClient('your-api-key')
const lists = new Lists(mailchannels)

const { data, error } = await lists.addListEntry({
  listName: 'safelist',
  item: 'name@domain.com'
})
ts
import { MailChannels } from 'mailchannels-sdk'

const mailchannels = new MailChannels('your-api-key')

const { data, error } = await mailchannels.lists.addListEntry({
  listName: 'safelist',
  item: 'name@domain.com'
})

Params

  • options ListEntryOptions required: Add list entry options.
    • listName "blocklist" | "safelist" | "blacklist" | "whitelist" required: The list to add the item to.
    • item string required: The item to add to the list. This can be a domain, email address, or IP address.

Response

  • data ListEntry | null nullable
    • action "blocklist" | "safelist" guaranteed
    • item string guaranteed
    • type "domain" | "email_address" | "ip_address" guaranteed
  • error string | null nullable

List Entries method

Get account-level list entries.

Usage

ts
import { MailChannelsClient, Lists } from 'mailchannels-sdk'

const mailchannels = new MailChannelsClient('your-api-key')
const lists = new Lists(mailchannels)

const { data, error } = await lists.listEntries('safelist')
ts
import { MailChannels } from 'mailchannels-sdk'

const mailchannels = new MailChannels('your-api-key')

const { data, error } = await mailchannels.lists.listEntries('safelist')

Params

  • listName "blocklist" | "safelist" | "blacklist" | "whitelist" required: The name of the list to fetch.

Response

  • data ListEntry[] | null nullable
    • action "blocklist" | "safelist" guaranteed
    • item string guaranteed
    • type "domain" | "email_address" | "ip_address" guaranteed
  • error string | null nullable

Delete List Entry method

Delete item from account-level list.

Usage

ts
import { MailChannelsClient, Lists } from 'mailchannels-sdk'

const mailchannels = new MailChannelsClient('your-api-key')
const lists = new Lists(mailchannels)

const { success, error } = await lists.deleteListEntry({
  listName: 'safelist',
  item: 'name@domain.com'
})
ts
import { MailChannels } from 'mailchannels-sdk'

const mailchannels = new MailChannels('your-api-key')

const { success, error } = await mailchannels.lists.deleteListEntry({
  listName: 'safelist',
  item: 'name@domain.com'
})

Params

  • options ListEntryOptions required: Add list entry options.
    • listName "blocklist" | "safelist" | "blacklist" | "whitelist" required: The name of the list to remove an entry from.
    • item string required: The list entry which should be removed. This can be a domain, email address, or IP address.

Response

  • success boolean guaranteed: Whether the operation was successful.
  • error string | null nullable

Type declarations

ts
class Lists {
  constructor (protected mailchannels: MailChannelsClient);
  async addListEntry (options: ListEntryOptions): Promise<ListEntryResponse>;
  async listEntries (listName: ListNames): Promise<ListEntriesResponse>;
  async deleteListEntry (options: ListEntryOptions): Promise<SuccessResponse>;
}
All type declarations

Responses

ts
interface DataResponse<T> {
  data: T | null;
  error: string | null;
}

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

SourcePlaygroundDocs

Released under the MIT License.