Netzo Logo


SendGrid is a cloud-based email service.


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

const api = sendgrid({
  apiKey: Deno.env.get('SENDGRID_API_KEY')


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

apiKeystringDeno.env.get('SENDGRID_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 lists

Find all your contact lists.

const query: QueryLists = {}
const result = await<Lists>(query)
const resultData = result.result

Get list

Get a list by id.

const query: QueryList = {}
const resultData = await[LIST_ID].get<List>(query)

Update list name

Update the name of a list.

const data: DataUpdateList = { name: 'Updated list name' }
const resultData = await[LIST_ID].patch<UpdateListResult>(data)

Add contacts to list

Add contacts to one or multiple lists.

const data: DataAddContacts = {
  list_ids: [LIST_ID1, LIST_ID2],
  contacts: [{ email: '[email protected]' }]
const resultData = await<AddContactsResult>(data)

Send email

Send an email over the API.

const data: DataSendEmail = {
  personalizations: [
      to: [
          email: '[email protected]',
          name: 'Contact name'
  from: {
    email: '[email protected]',
    name: 'Sender name'
  subject: 'New Subject',
  content: [
      type: 'text/html',
      value: '<p>Content of my email</p>'