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

# SendGrid

> Send transactional email and manage contacts in SendGrid from inside an agent workflow.

SendGrid actions let an agent handle email directly in a flow. An agent can send transactional email, add contacts, and list existing contacts, then pass the results to later steps.

## Supported actions

| Group        | Actions                    |
| ------------ | -------------------------- |
| **Email**    | Send Email                 |
| **Contacts** | Add Contact, List Contacts |

## Prerequisites

<AccordionGroup>
  <Accordion title="Create a SendGrid credential" icon="key">
    Store a SendGrid API key as a **SendGrid** credential in [Credential Management](/admin-hub/account_settings/credential-management), then select it on every SendGrid action.
  </Accordion>
</AccordionGroup>

## How to use these actions

* **Map text inputs from earlier steps.** Inputs such as **To Email**, **Subject**, and **Plain Text Content** accept a value mapped from a previous step.
* **Fixed value inputs.** The **Page Size** count and the **List IDs** set are entered as fixed values.
* **Provide a body when sending.** When sending an email you must provide a **Plain Text Content** body, an **HTML Content** body, or both. At least one is required.
* **List results page with a token.** To page through more contacts, pass the **Page Token** from the previous response into the next call.

## Actions

### Email

#### SendGrid Send Email

Sends a transactional email.

| Input                  | Required    | Description                                        |
| ---------------------- | ----------- | -------------------------------------------------- |
| **From Email**         | Yes         | The sender address.                                |
| **From Name**          | No          | The sender display name.                           |
| **To Email**           | Yes         | The recipient address.                             |
| **To Name**            | No          | The recipient display name.                        |
| **Subject**            | Yes         | The email subject line.                            |
| **Plain Text Content** | Conditional | The plain text body. Provide this or HTML Content. |
| **HTML Content**       | Conditional | The HTML body. Provide this or Plain Text Content. |
| **Reply To Email**     | No          | The reply to address.                              |

<Note>At least one of **Plain Text Content** or **HTML Content** is required.</Note>

### Contacts

#### SendGrid Add Contact

Adds a contact to your SendGrid contacts.

| Input                     | Required | Description                               |
| ------------------------- | -------- | ----------------------------------------- |
| **Email**                 | Yes      | The contact's email address.              |
| **First Name**            | No       | The contact's first name.                 |
| **Last Name**             | No       | The contact's last name.                  |
| **City**                  | No       | The contact's city.                       |
| **State Province Region** | No       | The contact's state, province, or region. |
| **Country**               | No       | The contact's country.                    |
| **Postal Code**           | No       | The contact's postal code.                |
| **List IDs**              | No       | The list IDs to add the contact to.       |

#### SendGrid List Contacts

Lists contacts.

| Input          | Required | Description                                                  |
| -------------- | -------- | ------------------------------------------------------------ |
| **Page Token** | No       | Pagination token from a previous request.                    |
| **Page Size**  | No       | Number of contacts per page, from 1 to 1000. Defaults to 50. |

## Example

An agent that emails a customer and records them as a contact:

<Steps>
  <Step title="Send the email">
    A **SendGrid Send Email** action sets **From Email** to your sender address, maps **To Email** and **Subject** from earlier steps, and provides a **Plain Text Content** body composed by a model step.
  </Step>

  <Step title="Add the contact">
    A **SendGrid Add Contact** action maps **Email** to the recipient and sets **First Name**, **Last Name**, and **List IDs** so the contact is added to the right list.
  </Step>
</Steps>

## Troubleshooting

<AccordionGroup>
  <Accordion title="At least one body is required" icon="triangle-exclamation">
    Send Email needs a **Plain Text Content** body, an **HTML Content** body, or both. Provide at least one.
  </Accordion>

  <Accordion title="Authentication failed" icon="lock">
    The API key is missing, expired, or revoked. Confirm the credential holds a valid SendGrid API key with permission for the action you are calling.
  </Accordion>

  <Accordion title="From address not verified" icon="circle-exclamation">
    SendGrid only sends from verified senders. Confirm the **From Email** is a verified single sender or belongs to an authenticated domain in your SendGrid account.
  </Accordion>

  <Accordion title="Contact not added to a list" icon="circle-question">
    The **List IDs** must reference existing lists in your account. Confirm the IDs and that the API key has Marketing permissions.
  </Accordion>
</AccordionGroup>

For issues common to every vendor, see the [Actions overview](/building-and-deploying-agents/agent-basics/actions/overview#troubleshooting).
