This tutorial walks you through a Gravity Forms Salesforce integration that auto-fills entries by email securely, on submit, and without custom code. You’ll use GravityWP API Connector, OAuth 2.0 (Client Credentials), and a SOQL query to fetch First Name, Last Name, and Company from Salesforce.
What does Gravity Forms Salesforce integration tutorial delivers
Each submission checks Salesforce for a matching Lead by the submitted Email. If a record exists, the entry is enriched with First Name, Last Name, and Company from Salesforce. The lookup in this example runs on form submission. But with our API Connector for Gravity Forms it is also possible to prefill form fields with Salesforce data in real-time.
Gravity Forms Salesforce integration Requirements
- WordPress with Gravity Forms
- GravityWP – API Connector add-on
- Salesforce admin access to create an External Client App
- At least one Lead in Salesforce with a unique Email
- The Salesforce instance domain visible in the browser when logged in (example used here): https://orgfarm-7be0a7e638-dev-ed.develop.my.salesforce.com
Part 1 – Salesforce: External Client App
In Setup → External Client App Manager, create (or open) an app for this integration (e.g., Gravity Forms Integration) and ensure it is Enabled. In OAuth settings, enable Client Credentials Flow and include the api scope so a server can request an access token without a user login.
Open Consumer Key and Secret. Salesforce labels them “Consumer,” but the connector uses these as Client ID and Client Secret.



Part 2 – WordPress: create the API Connection
Go to Forms → Settings → API Connector → Add New API Connection and enter:
- Base URL: https://orgfarm-7be0a7e638-dev-ed.develop.my.salesforce.com
(Just the instance domain; the connector appends endpoints to this base.) - Authentication method: OAuth 2.0 (Client Credentials)
- Client ID / Client Secret: paste the Salesforce Consumer Key/Secret
- Token URL: https://orgfarm-7be0a7e638-dev-ed.develop.my.salesforce.com/services/oauth2/token
Save the connection.

Part 3 – Build the Gravity Form
Create fields for First Name, Last Name, Company, and Email; mark Email as Required. Note the Email field’s ID (in this example, 5), which appears in merge tags like {Email:5}.

Part 4 – Create the API Connector feed (Salesforce lookup)
Open the form → Settings → API Connector → Add New Feed. Give it a clear name.
Request
Set Request Method to GET and set the Endpoint (relative to the Base URL) to:
/services/data/v61.0/query
This is Salesforce’s REST Query resource: services/data is the REST base path; v61.0 is the API version; query accepts SOQL and returns JSON.
See the Salesforce REST API docs
SOQL via q parameter
Add a Query String parameter with Key = q and paste:
SELECT+Id,FirstName,LastName,Company,Email,Status+FROM+Lead+WHERE+Email='{Email:5}'+ORDER+BY+CreatedDate+DESC+LIMIT+1
- SELECT lists the exact fields required.
- FROM Lead targets the Lead object.
- WHERE Email = ‘{Email:5}’ inserts the submitted Email value from the form.
- ORDER BY … LIMIT 1 ensures a single deterministic record if duplicates ever appear.
The connector URL-encodes the query automatically; no manual encoding is needed.
Map JSON → fields
Map the response paths to Gravity Forms fields:
- First Name ←
records/0/FirstName - Last Name ←
records/0/LastName - Company ←
records/0/Company
Only mapped fields are written to the entry; unmapped fields will not auto-fill.
Trigger & debug
Set the feed to run On form submission and enable Store full response to capture the raw JSON for testing.

/services/data/v61.0/query – the endpoint that executes SOQL and returns JSON.
{Email:5} to find the matching Lead, then returning First Name, Last Name, Company, Email, and Status.
records/0/FirstName, records/0/LastName, and records/0/Company fill the entry after submit.
Part 5 – Test
Submit the form using an Email that exists in Salesforce. Open the entries list and confirm that First Name, Last Name, and Company are populated from the returned JSON. If “Store full response” is enabled, review the JSON to verify the paths. Logs will show a fulfillment line (e.g., “Entry #… marked as fulfilled.”).




After testing, you’ll have a reliable Gravity Forms Salesforce integration that enriches entries with data from your organization.
Gravity Forms Salesforce integration Quick fixes
- Nothing filled? Confirm the merge tag uses the correct field ID ({Email:5} in this example).
- totalSize: 0 in JSON? No matching Lead for the submitted Email.
- Specific field empty? Ensure it’s both selected in SELECT and mapped to a field.
- Auth error? Verify Client ID/Secret, Token URL, app Enabled status, and Client Credentials Flow.
Format output with Advanced Merge Tags.
Optional extensions
- Query Contact instead of Lead by changing FROM Lead to FROM Contact and updating mappings.
- Add more fields by extending SELECT and mapping the new JSON paths.
- If pre-submit auto-fill is desired, switch the feed trigger to run on Email field change (different UX, not covered here).
Copy blocks
Endpoint (relative to Base URL)
/services/data/v61.0/query
SOQL
SELECT+Id,FirstName,LastName,Company,Email,Status+FROM+Lead+WHERE+Email='{Email:5}'+ORDER+BY+CreatedDate+DESC+LIMIT+1
JSON paths
records/0/FirstName
records/0/LastName
records/0/Company
Read tutorials about
How to Replace Zapier with n8n (Using the GravityWP n8n Connector)
Tired of burning Zapier tasks on every Gravity Forms submission? This guide shows you how to replace Zapier with n8n using the GravityWP n8n Connector. You’ll learn how to move an existing Zap step-by-step into n8n, cut automation costs, and keep full control over where your data lives.
n8n vs Zapier: Which Automation Tool Actually Fits Your Work?
Trying to decide between n8n vs Zapier? This article breaks down pricing, hosting, integrations, AI features, and where self-hosted n8n on a cheap VPS can beat Zapier’s task-based plans. You’ll also see how Gravity Forms users can plug in the GravityWP n8n Connector and move key workflows off Zapier without rebuilding their forms.
Cloudflare Tunnel + n8n: Expose Local n8n for Webhook Testing (Dev Only)
This guide shows how to use Cloudflare Tunnel Quick Tunnels to put a local n8n instance on the internet for real webhook testing. It’s a dev-only recipe that lets tools like GravityWP’s n8n Connector call your local n8n over HTTPS, without renting a VPS or opening ports.
Self-Host n8n with Docker on a VPS
Learn how to self-host n8n with Docker on a VPS using a production-ready setup. This step-by-step guide walks you through configuring Docker Compose, Postgres, HTTPS, and WEBHOOK_URL so you can run reliable, secure n8n workflows on your own server.