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
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.
| Input | Type | Description | |
|---|---|---|---|
name | string | Required | List name |
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.
| Input | Type | Description | |
|---|---|---|---|
start_date | string | Required | Start date, YYYY-MM-DD |
end_date | string | Optional | End date, YYYY-MM-DD (defaults to today) |
aggregated_by | string | Optional | Grouping |
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.
| Input | Type | Description | |
|---|---|---|---|
page_size | integer | Optional | Lists per page (1 to 1000, default 100) |
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.
| Input | Type | Description | |
|---|---|---|---|
query | string | Required | SGQL query, e.g. email LIKE '[email protected]%' AND CONTAINS(list_ids, 'LIST_ID') |
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.
| Input | Type | Description | |
|---|---|---|---|
to | string | Required | Recipient email address |
to_name | string | Optional | Recipient name |
from_email | string | Required | Verified sender email address |
from_name | string | Optional | Sender display name |
subject | string | Required | Subject line |
content_type | string | Required | Body format |
content | string | Required | Email body in the chosen format |
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.
| Input | Type | Description | |
|---|---|---|---|
email | string | Required | Contact email |
first_name | string | Optional | First name |
last_name | string | Optional | Last name |
list_ids | array of string | Optional | List ids (UUIDs) to add the contact to |
custom_fields | object | Optional | Custom field id to string value |
await setu.execute({
userId: "user_1",
action: "sendgrid.upsert_contact",
input: {
"email": "<email>"
},
});