Developers’ Guide to Sending WPForms Submissions to Any REST API
Integrating WPForms with external services is a common need for developers working on modern WordPress projects. Whether you're sending leads to a CRM, pushing user data to a custom backend, or connecting to a third-party SaaS tool, WPForms offers enough flexibility to make this possible, especially when paired with webhooks or custom code.
In this comprehensive developer-focused guide, you’ll learn how to send WPForms to any REST API, with clear steps, code examples, and tips for handling authentication, debugging, and error management.
Why Integrate WPForms with REST APIs?
WPForms is one of the most user-friendly form builders for WordPress. However, out of the box, it doesn’t natively support sending form submissions to external APIs unless you use the WPForms Webhooks addon or write custom functions.
Here’s why integrating WPForms with APIs matters:
📤 Automatically send leads to CRMs like Salesforce, HubSpot, or Zoho
📦 Connect to email marketing tools like Mailchimp or ConvertKit
📈 Push user activity to analytics or BI tools
🔄 Sync with internal systems or external apps via custom APIs
🧩 Enable custom workflows without relying on third-party automation platforms
If you’re a developer building efficient, automated systems—this skill is a must.
Before we dive in, make sure you have the following:
A WordPress website with WPForms installed and configured.
A form created in WPForms with necessary fields.
Familiarity with WordPress hooks, PHP, and basic API concepts.
The WPForms Webhooks addon (optional but helpful for no-code or low-code use cases).
An endpoint to test with (e.g., Webhook.site or your own REST API).
Option 1: Using the WPForms Webhooks Addon (No Code)
If you're looking for a simpler method, WPForms offers a Webhooks Addon to send form data directly to any REST API endpoint without coding.
Enable the Webhooks Addon Go to WPForms > Addons and activate the Webhooks Addon.
Edit Your Form Navigate to WPForms > All Forms > Edit your target form.
Enable Webhook Integration
Go to Settings > Webhooks
Paste your API Endpoint URL
Configure Request Settings
Map your form fields to the JSON keys or parameters expected by the API
Test the Submission Submit the form and check if data reaches the target API.
This method is best for straightforward integrations and services that don’t require advanced authentication.
Option 2: Custom Code Integration (PHP Hook Method)
For more advanced use cases—like sending data to private APIs, handling tokens, headers, or transforming data—you’ll want to use the wpforms_process_complete hook.
This action fires after WPForms has successfully processed and saved form data:
add_action( 'wpforms_process_complete', 'send_wpform_data_to_api', 10, 4 );
Step-by-Step Custom Integration
1. Add Code to functions.php or Custom Plugin
add_action( 'wpforms_process_complete', 'send_wpform_data_to_api', 10, 4 );
function send_wpform_data_to_api( $fields, $entry, $form_data, $entry_id ) {
// Get data from form fields
$name = $fields[1]['value']; // Change 1 to your field ID
$email = $fields[2]['value']; // Change accordingly
$message = $fields[3]['value'];
// Create the API payload
'Content-Type' => 'application/json',
'Authorization' => 'Bearer YOUR_API_KEY' // If needed
$response = wp_remote_post( 'https://your-api-endpoint.com/submit', [
// Log response (optional)
if ( is_wp_error( $response ) ) {
error_log( 'API Request failed: ' . $response->get_error_message() );
error_log( 'API Response: ' . wp_remote_retrieve_body( $response ) );
🔄 Tip: Replace field IDs with actual IDs from your WPForm. Use print_r($fields) to inspect structure during development.
You can test your endpoint using:
Webhook.site for viewing raw request payloads.
Postman to test API endpoints before integrating.
Debug bar plugin to inspect error logs inside WordPress.
Validate the API request method, headers, response status, and body output.
Most APIs require authentication. Here are common methods:
'Authorization' => 'Bearer YOUR_TOKEN'
'Authorization' => 'Basic '. base64_encode( 'user:password' )
'X-API-KEY' => 'your_api_key'
'https://api.example.com/endpoint?api_key=YOUR_KEY'
Check the target API documentation for required formats.
Error Handling and Logging
Good error handling prevents silent failures and helps with debugging.
if ( is_wp_error( $response ) ) {
error_log( 'API Request Error: ' . $response->get_error_message() );
$status = wp_remote_retrieve_response_code( $response );
$body = wp_remote_retrieve_body( $response );
error_log( 'Status: ' . $status );
error_log( 'Response Body: ' . $body );
For production sites, consider using a logging plugin like WP Log Viewer or routing logs to an external service.
Map form fields to lead object in CRMs like HubSpot, Zoho, Salesforce.
Trigger workflow automation upon submission.
Send to Google Sheets via Apps Script
Connect to a Google Apps Script Web App URL.
Store submissions as spreadsheet rows.
Custom Backend Integration
Push form data to Laravel/Node.js/PHP backend API.
Trigger real-time email, database actions, or notifications.
Alternatives & Enhancements
Here are some tools and plugins that support advanced WPForms-to-API connections:
WP Webhooks: No-code plugin to trigger external APIs.
Zapier / Make (Integromat): Great for non-devs but may have rate limits or costs.
Contact Form to Any API: Lightweight plugin designed for form-to-API integration.
Formidable Forms: For more complex data structures and logic.
✅ Always sanitize and validate user inputs before sending to APIs.
✅ Backup your site before adding custom code.
✅ Use test mode endpoints during development.
✅ Avoid exposing API secrets in public code (use wp-config.php).
✅ Log both success and failure responses for visibility.
WPForms is a powerful form plugin on its own, but its real strength is revealed when you integrate it with external APIs. Whether you're sending leads to a CRM, triggering custom workflows, or updating third-party systems, this guide has shown you how to:
Use Webhooks Addon for simple no-code integrations
Write custom PHP code for advanced and secure API requests
Handle authentication, testing, and logging properly
For developers, integrating WPForms with REST APIs opens up a whole new layer of automation and flexibility, turning simple forms into powerful tools.