Developers · Integrations
SendGrid via API Call Notifications
Last updated 11 November 2026
This document demonstrates creating a SendGrid integration for Insites using API call notifications.
When a user fills out a form on your Insites application, you need to have that user added to the correct SendGrid Segment so you can provide them with the correct marketing campaign. This guide explains how to create an API Call Notification for each form on your site that sends the user’s info to SendGrid and creates a custom (field) attribute in SendGrid to allow the user to be added to the correct segment.
Prerequisites
To understand this tutorial, you must be familiar with creating API call notifications, have access to SendGrid, and understand the SendGrid API. In addition, you must know how to create segments in SendGrid.
- Creating an API Call Notification
- SendGrid API Reference, Contacts API - Recipients: POST. This endpoint belongs to SendGrid Legacy Marketing Campaigns. For the current API, see Add or update a contact.
- Segments in SendGrid
Steps
Integrating SendGrid using API Call Notifications is a three-step process:
- Step 1: Create an API call notification
- Step 2: Add API call notifications to forms
- Step 3: Create segments in SendGrid
Step 1: Create an API call notification
Create an API Call Notification:
- Store your SendGrid API key as a constant, for example
. You can set it with . The API call reads it as . Never put the key itself in the file. - Add the payload based on the attributes in your form.
- Create a custom (field) attribute in SendGrid called
. Each form on your site provides a unique response that is recorded here.
---
name: sendgrid_new_user_homepage
delay: '0'
format: http
request_headers: >
{
"Content-Type": "application/json",
"Authorization": "Bearer {{ context.constants.SENDGRID_API_KEY }}"
}
request_type: POST
to: https://api.sendgrid.com/v3/contactdb/recipients
---
[
{
"email": "",
"first_name": "",
"last_name": "",
"contact_via": "Home Page Contact Form"
}
]Note
The documentation concerning Response Headers could be a valuable resource for you.
Step 2: Add API call notifications to forms
Add the following to the front matter on your form:
api_call_notifications:
- sendgrid_new_user_homepageStep 3: Create segments in SendGrid
Create segments in SendGrid and filter using the
Troubleshooting
Use this section to troubleshoot common issues encountered when integrating SendGrid using API call notifications.
Emails getting stuck in spam folders/filters
You can make some tweaks to your DNS records to help ensure that your emails are getting to your users' inboxes and not getting caught up in their spam folders/filters.
Solution 1
Add the sendgrid.net lookup to your current SPF record for your domain.
Example
If your current record (TXT or SPF) is:
You can add:
before the
This action will result in:
Note
You can learn more about this method by visiting the following documentation: SPF Records Explained.
Solution 2
Add DKIM records to your DNS records as described here: DKIM Records Explained.