Setu Recipes: reusable digital workers across every app.Browse templates

Integrations / SendGrid

SendGrid

Email delivery and marketing: send mail, manage contacts and lists, read sending statistics.

6 actions API key 3 read3 write Calls api.sendgrid.com

Connect

TypeScript
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "sendgrid" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();

Permissions requested

This toolkit uses a single credential and requests no scopes.

Actions

Create contact listwritesendgrid.create_listCreate an empty marketing contact list with the given name.
InputTypeDescription
namestringRequiredList name
TypeScript
await setu.execute({
  userId: "user_1",
  action: "sendgrid.create_list",
  input: {
    "name": "<name>"
  },
});
Get email statisticsreadsendgrid.get_statsGet global email statistics (requests, delivered, opens, clicks, bounces, spam reports) per day, week or month for a date range.
InputTypeDescription
start_datestringRequiredStart date, YYYY-MM-DD
end_datestringOptionalEnd date, YYYY-MM-DD (defaults to today)
aggregated_bystringOptionalGrouping
TypeScript
await setu.execute({
  userId: "user_1",
  action: "sendgrid.get_stats",
  input: {
    "start_date": "<start_date>"
  },
});
List contact listsreadsendgrid.list_listsList the marketing contact lists with their ids, names and contact counts.
InputTypeDescription
page_sizeintegerOptionalLists per page (1 to 1000, default 100)
TypeScript
await setu.execute({
  userId: "user_1",
  action: "sendgrid.list_lists",
  input: {},
});
Search contactsreadsendgrid.search_contactsSearch marketing contacts with a SendGrid Query Language string, for example email LIKE 'jane%'. Emails are stored lowercase. Returns the first 50 matches.
InputTypeDescription
querystringRequiredSGQL query, e.g. email LIKE '[email protected]%' AND CONTAINS(list_ids, 'LIST_ID')
TypeScript
await setu.execute({
  userId: "user_1",
  action: "sendgrid.search_contacts",
  input: {
    "query": "<query>"
  },
});
Send emailwritesendgrid.send_emailSend one email through SendGrid to a single recipient. The sender address must be a verified sender in the SendGrid account.
InputTypeDescription
tostringRequiredRecipient email address
to_namestringOptionalRecipient name
from_emailstringRequiredVerified sender email address
from_namestringOptionalSender display name
subjectstringRequiredSubject line
content_typestringRequiredBody format
contentstringRequiredEmail body in the chosen format
TypeScript
await setu.execute({
  userId: "user_1",
  action: "sendgrid.send_email",
  input: {
    "to": "<to>",
    "from_email": "<from_email>",
    "subject": "<subject>",
    "content_type": "<content_type>",
    "content": "<content>"
  },
});
Add or update contactwritesendgrid.upsert_contactAdd a marketing contact, or update the one with the same email, optionally adding it to lists. SendGrid processes this asynchronously and returns a job id.
InputTypeDescription
emailstringRequiredContact email
first_namestringOptionalFirst name
last_namestringOptionalLast name
list_idsarray of stringOptionalList ids (UUIDs) to add the contact to
custom_fieldsobjectOptionalCustom field id to string value
TypeScript
await setu.execute({
  userId: "user_1",
  action: "sendgrid.upsert_contact",
  input: {
    "email": "<email>"
  },
});