> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SendGrid Actions integration

[Back to list of integrations](https://koreai.mintlify.site/agent-platform/integrations/enterprise-systems.md)

Use the SendGrid integration to let agents send transactional email, as text, HTML, or a dynamic template, through Action Tools.

| Authentication | Actions | Workflow triggers |
| - | - | - |
| API Key | [3](#supported-actions) | None |

## Supported actions

Actions are SendGrid operations that an agent runs as Action Tools during a conversation. You can also run them from an [Integration node](https://koreai.mintlify.site/agent-platform/workflows.md#integration-node) in a workflow.

| Action | Use it to |
| - | - |
| [Send Email](#send-email) | Send a plain text or HTML email. |
| [Send Dynamic Template](#send-dynamic-template) | Send an email from a SendGrid dynamic template with personalized data. |
| [Custom API Call](#custom-api-call) | Call any SendGrid API endpoint the other actions don't cover. |

## Prerequisites

* A [verified sender identity](https://www.twilio.com/docs/sendgrid/for-developers/sending-email/sender-identity) and, for templates, a [dynamic template](https://www.twilio.com/docs/sendgrid/ui/sending-email/how-to-send-an-email-with-dynamic-templates) ID.

## Set up the integration

**1. Create a SendGrid API key**

In **Settings** > **API Keys**, create a **Restricted Access** key with **Mail Send** > **Full Access**, and copy it. SendGrid shows it only once.

**2. Create the auth profile**

In **Integrations**, select **SendGrid** > **Connect**. On **Project Auth Profiles**, select **New Profile** > **Integration Profile** > **SendGrid** > **Continue**. Paste the key into **API Key**, keep **Header Name** (`authorization`) and **Prefix** (`Bearer `), and select **Create Profile**.

**3. Create the action tool**

In **Tools**, select **New Tool** > **Action** > **SendGrid** > **Continue**. Select the **Action** and **Auth Profile**, set parameter defaults (leave a value empty for the agent to supply at runtime), and select **Create Tool**. Set `from` and `from_name` as defaults. Then [assign the tool to an agent](https://koreai.mintlify.site/agent-platform/tools/actions.md#assign-an-action-to-an-agent).

## Action reference

> [accordion] Send Email
>
> | Parameter | Type | Description |
> | - | - | - |
> | `to` | array | Recipient addresses. |
> | `from` | string | Sender address. Must be a verified sender in SendGrid. |
> | `from_name` | string | Sender display name. |
> | `reply_to` | string | Address that receives replies. Defaults to the sender. |
> | `subject` | string | Subject line. |
> | `content_type` | enum | Content type: text or HTML. |
> | `content` | string | Message body. HTML is allowed only when `content_type` is HTML. |

> [accordion] Send Dynamic Template
>
> | Parameter | Type | Description |
> | - | - | - |
> | `to` | array | Recipient addresses. |
> | `from_name` | string | Sender display name. |
> | `from` | string | Sender address. Must be a verified sender in SendGrid. |
> | `template_id` | string | Dynamic template ID, which starts with `d-`. |
> | `template_data` | object | Values for the template's Handlebars variables. |
> | `reply_to` | string | Address that receives replies. Defaults to the sender. |

> [accordion] Custom API Call
>
> Sends a request to any SendGrid v3 API endpoint. Artemis injects the authorization header from the auth profile.
>
> | Parameter | Type | Description |
> | - | - | - |
> | `url` | object | Endpoint URL. |
> | `method` | enum | HTTP method. |
> | `headers` | object | Additional request headers. |
> | `queryParams` | object | Query parameters. |
> | `body_type` | enum | Body type. Default: `None`. |
> | `body` | object | Request body. |
> | `response_is_binary` | boolean | Turn on for binary responses, such as PDFs or images. Default: `False`. |
> | `failsafe` | boolean | Returns no error when the call fails. |
> | `timeout` | number | Timeout, in seconds. |
> | `followRedirects` | boolean | Follows HTTP redirects. Default: `False`. |

## Troubleshoot common issues

| Issue | Resolution |
| - | - |
| `401 Unauthorized` | Confirm the API key is current and **Prefix** is `Bearer ` with a trailing space. |
| `403 Forbidden` | Grant the API key **Mail Send** access, or the access that the **Custom API Call** endpoint needs. |
| `The from address does not match a verified Sender Identity` | Verify the sender address or authenticate its domain in SendGrid. |
| Template variables are blank | Match the keys in `template_data` to the variable names in the template. Names are case sensitive. |
| Email sends but doesn't arrive | Check **Activity Feed** in SendGrid for bounces, blocks, or spam reports. |

**Related articles:**

* [Enterprise systems integrations](https://koreai.mintlify.site/agent-platform/integrations/enterprise-systems.md)
* [Auth profiles](https://koreai.mintlify.site/agent-platform/administration/integrations-settings.md#auth-profiles)
* [Action Tools](https://koreai.mintlify.site/agent-platform/tools/actions.md)
* [Amazon SES Actions integration](https://koreai.mintlify.site/agent-platform/integrations/enterprise-systems/amazon-ses)
* [SendGrid Mail Send API](https://www.twilio.com/docs/sendgrid/api-reference/mail-send/mail-send)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.