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

# Integrate with Sendgrid

> If you want to automatically send an email from Next Matter, you can tap into Next Matter's built-in integration to reach out to external partners by email.

If you have your own email provider, you can also send emails using your email provider details with Next Matter custom integration step.

<Tip>
  Check out our ready-made templates available when you add a step and select **Templates > 3rd party templates**. You can use the templates to create a set of pre-configured steps. Need a specific template? Click the **Contact us** button in the top right of the page and let us know.
</Tip>

## Before you begin

* Check the [required scopes](/docs/security-matrix) to learn more about which data is shared between the apps.

## Use Next Matter's built-in integration

1. In the workflow in which you want to send an email, click **+ Add step**.

2. Select **Step templates > Integrations > SendGrid - Send an email**.

3. Customize the **Body**. You'll be using Next Matter's built-in integration, so all other details have been populated for you. Note that your emails will be sent from the Next Matter email address.

   <Tip>
     You can use data references to populate the recipient's name or content.
   </Tip>

   <CodeGroup>
     ```json JSON theme={null}
     {
     	"from": {
     		"email": "[email protected]",
     "name": "SENDER_NAME"//enter a name
     	},
     	"personalizations": [{
     		"to": [{
     			"email": "RECIPIENT_EMAIL_EDDRESS"}],//enter the address
     		"dynamic_template_data": {
     			"email-subject": "SUBJECT",//enter the subject
     			"email-content": "EMAIL_TEXT"}//enter the contents of the email
     	}],
     	"template_id": "d-1aa0b4cd59214c18924a28c96ed78f7f",  
       "attachments": [//you can delete this part if you don't send an attachment
         {
           "content": "REFERENCE_TO_ATTACHMENT_FILE",//use the data reference to find the attachment if it was added to the process
           "filename": "Attachments.zip"//enter the file name
         }
       ]
     }
     ```
   </CodeGroup>

If you want to send an email with an attachment, use the **SendGrid - Send an email with attachment template**.

## Integrate with Sengrid with your own account

1. In Sendgrid, go to **Settings > API keys**.

2. Click **Create API-Key** and define the scopes for the integration. You can only generate the key if you're an admin.

3. In Next Matter, open the process in which an email should be sent out and click **+ Add step**.

4. Select **Integrations > Custom integration**.

5. Click **Settings**.

6. Enter the following details:

   <CodeGroup>
     ```json JSON theme={null}
     {
     	"from": {
     		"email": "[email protected]",//change this for your company
     		"name": "EMAIL_SUBJECT"
     	},
     	"personalizations": [{
     		"to": [{
     			"email": "[email protected]"//this can be a Next Matter data reference
     		}],//copy and paste the enitire "to:"section for every user that should also receive this email
     		"cc": [{
             "email": "[email protected]"
         }],
         "dynamic_template_data": {
     			"email-subject": "NEW_SUBJECT",
     			"email-content": "EMAIL_TEXT"
     		}
     	}],
     	"template_id": "d-1ab0b3cd57213c18225a28c96ed78f7f" //you can find the template in Sendgrid >  Email Api>  Dynamic Templates
     }
     ```
   </CodeGroup>

   * **Method**: POST

   * **URL**: [https://api.sendgrid.com/v3/mail/send](https://api.sendgrid.com/v3/mail/send)

   * **Headers**: Content-Type: application/json

   * **Headers**: Authorization: Bearer SENDGRID\_API\_KEY

   * **Body**: The body might look like the following:

7. Save your changes. The step in which the email is sent out is now called **Email automation**.

For details on SendGrid email configuration, see the following [Sengrid API documentation](https://docs.sendgrid.com/api-reference/how-to-use-the-sendgrid-v3-api/authentication).
