Skip to main content

SendGrid

Give agents tools to send email, and manage marketing contacts, lists, segments, custom fields, dynamic templates, sender identities, and suppressions in SendGrid through Mastra Connect. Each tool call goes through the Mastra platform, which adds the connection's credential. Your application never stores SendGrid credentials.

Connect
Direct link to Connect

Before you start, complete the Connect setup to install @mastra/connect and configure your platform project.

Connect an account
Direct link to Connect an account

Run this command from the directory that contains your .env file:

mastra connect add sendgrid

The CLI guides you through SendGrid's authorization and waits until the connection is active.

Add tools to an agent
Direct link to Add tools to an agent

Pass tools() to the agent and select the sendgrid provider:

src/mastra/agents/sendgrid-agent.ts
import { Agent } from '@mastra/core/agent'
import { tools } from '@mastra/connect'

export const sendgridAgent = new Agent({
id: 'sendgrid-agent',
name: 'SendGrid agent',
instructions:
'You help people send email, and manage marketing contacts, lists, segments, custom fields, dynamic templates, sender identities, and suppressions in SendGrid.',
model: 'openai/gpt-6-luna',
tools: tools({ providers: ['sendgrid'] }),
})

The agent gets 53 SendGrid tools, with keys such as sendgrid_activate_template_version. See SendGrid tools for the full list, and the tools() parameters to restrict tools or require approval before a call runs.

On this page