Netzo Logo


Mailgun is an email automation service.


import { mailgun } from 'netzo/apis/mailgun.ts'

const api = mailgun({
  apiKey: Deno.env.get('MAILGUN_API_KEY')


The mailgun factory function expects an object with the following, and returns an object with an API client api.

apiKeystringDeno.env.get('MAILGUN_API_KEY')the api key to use for authentication
Refer to the API documentation to get the required information.


The following examples assume you have created an api client instance.

Find mailing lists

Find all mailing lists.

const query: QueryMailingLists = {}
const result = await api.v3.lists.pages.get<MailingLists>(query)
const resultData = result.items

Add mailing list

Add a new mailing list.

const data: DataAddMailingList = {
  address: '[email protected]',
  name: 'Newsletter'
const result = await<AddOrUpdateListResult>(data)
const resultData = result.list

Update mailing list

Update a mailing list by its email address.

const data: DataUpdateMailingList = {
  name: 'Updated name'
const result = await api.v3.lists[LIST_ADDRESS].put<AddOrUpdateListResult>(data)
const resultData = result.list

Add member to mailing list

Add a new email address to a mailing list.

const data: DataAddMember = {
  address: '[email protected]'
const result = await api.v3.lists[LIST_ADDRESS]<AddMemberResult>(data)
const resultData = result.member

Delete mailing list member

Remove an email from a mailing list.

const resultData = await api.v3.lists[LIST_ADDRESS].members[MEMBER_ADDRESS].delete<DeleteMemberResult>()