← All integrations

SendGrid

Let an agent send email and keep your lists tidy with a ceiling on how much it can do. It sends emails and template emails, adds and updates contacts and lists, and honours unsubscribes, and an email to more than five recipients can wait for a person.

SendGridsecret · SENDGRID
host
api.sendgrid.com
connect
API key, per user
  • Send email

    sendgrid-send-email

  • Send template email

    sendgrid-send-template-email

  • Upsert contacts

    sendgrid-upsert-contacts

  • Delete contact

    sendgrid-delete-contact

writes are off until switched on

Reads and writes in SendGrid. Writes are off until you switch them on.

Each one is a named operation from the pack. Reads change nothing.

Writes

  • Send email

    acknowledged

    sendgrid-send-email

    Send one email to the addresses in to, from a sender verified in SendGrid, with a plain-text body and, if given, an HTML body. Every recipient is on the To line and sees the others; there is no cc or bcc. Counted in emails, one per recipient.

  • Send template email

    acknowledged

    sendgrid-send-template-email

    Send one email built from a SendGrid dynamic template (id starts with d-, from list-templates) to the addresses in to, filling the template with dynamic_template_data. The subject and body come from the template's active version. Every recipient is on the To line and sees the others. Counted in emails, one per recipient.

  • Upsert contacts

    read back

    sendgrid-upsert-contacts

    Add or update Marketing contacts by email, and add each to the lists in list_ids (list-lists); this is how a contact is put on a list. A field left out keeps its value. SendGrid queues the change as a background job and answers with job_id. Counted per contact.

  • Delete contact

    read back

    sendgrid-delete-contact

    Delete one Marketing contact by id. Deleting every contact is not offered. SendGrid deletes it in a background job and answers with job_id.

  • Create list

    read back

    sendgrid-create-list

    Create one Marketing contact list with a name.

  • Rename list

    read back

    sendgrid-rename-list

    Rename one Marketing contact list. Its contacts are unchanged.

  • Delete list

    read back

    sendgrid-delete-list

    Delete one Marketing contact list. The contacts on it are kept.

  • Remove contact from list

    acknowledged

    sendgrid-remove-contact-from-list

    Take one contact off one Marketing list. The contact itself is kept.

  • Add to unsubscribe group

    read back

    sendgrid-add-to-unsubscribe-group

    Unsubscribe one address from one unsubscribe group (list-unsubscribe-groups), so mail sent with that group no longer reaches it.

  • Remove from unsubscribe group

    read back

    sendgrid-remove-from-unsubscribe-group

    Subscribe one address to one unsubscribe group again, so mail sent with that group reaches it. Do this when the person asked for it, never on your own.

  • Add global unsubscribe

    read back

    sendgrid-add-global-unsubscribe

    Put one address on the global unsubscribe list, so SendGrid sends it no mail at all.

  • Remove global unsubscribe

    read back

    sendgrid-remove-global-unsubscribe

    Take one address off the global unsubscribe list, so SendGrid sends it mail again. Do this when the person asked for it, never on your own.

Reads

  • Search contacts

    sendgrid-search-contacts

    Find Marketing contacts with a SendGrid SGQL query, for example email LIKE 'ada%' or CONTAINS(list_ids, '<list id>'). Changes nothing (POST search). Returns at most 50 contacts and contact_count, the number that matched. There is no next page: narrow the query instead. Emails are stored in lower case, so write them in lower case. A query that runs over 20 seconds answers 408. A long result can be cut at the response limit.

  • Get contacts by email

    sendgrid-get-contacts-by-email

    Get Marketing contacts by exact email address, primary or alternate. Changes nothing (POST search). Takes up to 100 addresses. Returns result, keyed by each address: the contact, or an error for an address with no contact. Answers 404 when no address matches.

  • Get contact

    sendgrid-get-contact

    Get one Marketing contact by id: name, email, alternate emails, address fields, list_ids, segment_ids, custom_fields and timestamps. Answers 404 for a contact that does not exist or was deleted.

  • Get contact job

    sendgrid-get-contact-job

    Get the status of a contacts job from upsert-contacts or delete-contact, by its job_id: status (pending, completed, errored or failed), job_type (upsert or delete) and counts of contacts requested, created, updated, deleted and errored.

  • List lists

    sendgrid-list-lists

    List Marketing contact lists: id, name and contact_count, 50 a page. For the next page, pass the page_token from the _metadata.next URL; with no next, it was the last page.

  • Get list

    sendgrid-get-list

    Get one Marketing contact list by id: its name and contact_count.

  • List templates

    sendgrid-list-templates

    List dynamic transactional templates (ids start with d-), 20 a page: id, name, updated_at and each version's id, name, subject and whether it is active. For the next page, pass the page_token from _metadata.next. Legacy templates are not listed.

  • Get template

    sendgrid-get-template

    Get one transactional template by id, with every version: subject, HTML and plain content, and which version is active. A template with large or many versions can be cut at the response limit.

  • List unsubscribe groups

    sendgrid-list-unsubscribe-groups

    List the account's unsubscribe groups (suppression groups): id, name, description, whether it is the default and how many addresses left it. SendGrid returns every group in one response.

  • Get email unsubscribe groups

    sendgrid-get-email-unsubscribe-groups

    Get every unsubscribe group for one address, each with suppressed true when the address has left that group.

  • Get global unsubscribe

    sendgrid-get-global-unsubscribe

    Check whether one address is on the global unsubscribe list, which stops all mail to it. Returns recipient_email when it is, and an empty object when it is not.

  • Get bounce

    sendgrid-get-bounce

    Get the bounce records for one address: when it bounced, the reason and the SMTP status. An empty list means SendGrid has no bounce for it. A bounced address gets no further mail until the bounce is removed in SendGrid.

How do users connect? Each one brings their own SendGrid.

  1. 1.Call for the userYour server invokes the action for the signed-in user. Without a SendGrid connection, the SDK throws EndUserNotConnectedError with a connect link.
  2. 2.The user pastes a keyThe link opens a form that shows where in SendGrid's settings to create the key. The link lasts 10 minutes and works once.
  3. 3.Anlyon checks itThe key is checked with SendGrid before it is kept, and bound to api.sendgrid.com. It is never shown back.
  4. 4.Your server confirmsYour server confirms the connection for the user who is signed in, and the call goes through.

Guardrails. Suggested limits and approvals, for you to review.

Suggested limits

  • 100 emails sent a day
  • 100 template emails sent a day
  • 500 contacts added or updated a day
  • 20 contacts deleted a day
  • 10 lists created a day
  • 20 lists renamed a day
  • 5 lists deleted a day
  • 100 contacts taken off lists a day
  • 100 group unsubscribes a day
  • 10 group resubscribes a day
  • 100 global unsubscribes a day
  • 10 global resubscribes a day

Suggested approvals

  • A person approves an email to more than 5 recipients
  • A person approves a template email to more than 5 recipients
  • A person approves deleting a contact
  • A person approves deleting a list
  • A person approves subscribing an address to a group again
  • A person approves taking an address off the global unsubscribe list

What the key must allow

  • An API key with Custom Access
  • Mail Send, Marketing and Suppressions: Full Access
  • Template Engine: Read Access

Good to know

  • SendGrid returns no message id for a send, so a send is acknowledged rather than read back.
  • Accounts in SendGrid's EU region use another host and cannot be connected yet.

For your own account

  1. 1.In SendGrid, open Settings, API Keys, and create a key with Custom Access and those permissions.
  2. 2.In Anlyon, open Actions, then Integrations, choose SendGrid and paste the key.
  3. 3.Anlyon checks the key with SendGrid before storing it. It becomes a secret named SENDGRID, bound to api.sendgrid.com.

SendGrid in your code. For one of your users, or for your own account.

Act for one of your users from your server, or connect your company's own SendGrid with the CLI.

sendgrid.ts
import { Client, EndUserNotConnectedError } from "@anlyonhq/sdk";const anlyon = new Client({ apiKey: process.env.ANLYON_API_KEY! });try {  const { data } = await anlyon    .forUser(session.userId)    .actions.invoke("sendgrid-add-global-unsubscribe", {      email: "sam@example.com"    });  return { status: "done", grade: data.grade };} catch (error) {  if (error instanceof EndUserNotConnectedError) {    // The user connects their own SendGrid, then you call again.    return { status: "connect_required", url: error.connectUrl };  }  throw error;}

Let your agent act for your users, safely.

A few lines of server code, then send a user a connect link. Nothing to host.

$ claude mcp add --transport http anlyon https://api.anlyon.com/mcp