ApproxIt registers AJAX actions on the standard WordPress wp_ajax_* and wp_ajax_nopriv_* hooks. All requests POST to wp-admin/admin-ajax.php.
Authentication and nonces are noted per endpoint. Pro-only endpoints are marked.
Public Endpoint (No Auth)
ax_submit_lead
The single endpoint customers POST to when submitting an estimate.
Registered on: wp_ajax_nopriv_ax_submit_lead and wp_ajax_ax_submit_lead
Auth: None. Anti-spam guards (honeypot, timing token, IP rate limit) substitute for nonce-based auth.
Payload: application/x-www-form-urlencoded or multipart/form-data (for photo uploads in Pro).
| Field | Required | Description |
action | Yes | Must be ax_submit_lead. |
name | Yes | Customer name. |
email | Yes | Customer email (validated server-side). |
phone | No | Customer phone. |
address | No | Customer address. |
notes | No | Customer notes (max 1000 chars; truncated server-side). |
lead_data | Yes | JSON-stringified estimate breakdown (services, package, totals). |
form_token | Yes (non-local) | HMAC-signed timing token from axAjax.formToken. |
ax_hp_website | Yes | Honeypot field — must be empty. |
nonce | Yes | axAjax.nonce. |
ax_photos[] | No (Pro) | File uploads — only handled when Pro is active. |
Response (Success):
JSON
{
"success": true,
"data": { "message": "Lead saved" }
}
Response (Error):
JSON
{
"success": false,
"data": "Missing required fields"
}
Common Error Messages:
Missing required fieldsSubmission rejected. Please refresh and try again.Too many requests from your connection. Please try again later.An estimate was recently submitted with this email. Please wait a few minutes before trying again.
Side Effects on Success:
- Creates an
ax_leadpost. - Saves all the
_ax_lead_*meta. - Fires the
ax_lead_createdaction.
Admin Endpoints
All admin endpoints require a WordPress user with manage_options capability and a valid nonce (action: ax_leads_action unless otherwise noted).
ax_update_lead_status
Change a lead’s status.
Payload:
Plaintext
action=ax_update_lead_status
nonce=...
lead_id=42
status=contacted
Response: { success: true } or { success: false, data: <error> }.
Side effects: Updates _ax_lead_status, fires ax_lead_status_updated action.
ax_update_lead_score (Pro only)
Manually override a lead’s score.
Payload:
Plaintext
action=ax_update_lead_score
nonce=...
lead_id=42
score=hot
Side effects: Updates _ax_lead_score, sets _ax_lead_score_override to 1.
ax_save_lead_notes (Pro only)
Save admin notes on a lead.
Payload:
Plaintext
action=ax_save_lead_notes
nonce=...
lead_id=42
notes=Called 5/12, left voicemail
ax_delete_lead
Move a lead to the trash.
Payload:
Plaintext
action=ax_delete_lead
nonce=...
lead_id=42
ax_analyze_lead_photos (Pro only)
Run Gemini photo analysis on a lead’s attached photos. Runs synchronously and returns the analysis when complete (can take 10-30s for multiple photos).
Payload:
Plaintext
action=ax_analyze_lead_photos
nonce=...
lead_id=42
Response:
JSON
{
"success": true,
"data": {
"results": {
"123": { "note": "...", "red_flags": [...], "confidence": 0.85, "thumb": "..." }
}
}
}
ax_analyze_property (Pro only)
Run Gemini property research for a lead’s address.
Payload:
Plaintext
action=ax_analyze_property
nonce=...
lead_id=42
ax_send_quote (Pro only)
Trigger a follow-up “quote” email to the customer. Records the timestamp in _ax_lead_quote_sent meta.
ax_test_notification (Pro only)
Send a test SMS or email to verify Twilio / SendGrid integration.
Payload:
Plaintext
action=ax_test_notification
nonce=...
type=sms | email
ax_ai_assist_description (Pro only)
Auto-draft a Business Context description using Gemini, based on site name, estimators, and recent leads.
ax_dismiss_onboarding (Pro only)
Dismiss the Pro onboarding banner on the settings page.
ax_duplicate_estimator (Pro only)
Duplicate an estimator with all its services, packages, and questions.
ax_load_template
Load an industry template into an estimator post, replacing its current services and packages.
Payload:
Plaintext
action=ax_load_template
nonce=...
post_id=42
template=hvac
Side effects: Overwrites _ax_estimator_services, _ax_estimator_packages, _ax_estimator_questions, and the accent color on the target post.
Export Endpoints (admin-post.php)
Two CSV/JSON exports run through admin-post.php instead of admin-ajax.php because they need to set Content-Type headers and stream a file download.
ax_export_leads_csv & ax_export_leads_json
Method: GET to wp-admin/admin-post.php?action=ax_export_leads_csv&_wpnonce=...&filters=...
Auth: manage_options + nonce (action: ax_export_leads).
Response: A file download with Content-Disposition: attachment header.
Pro-Only Public Endpoint
ax_log_abandoned (Pro only)
Endpoint hit by navigator.sendBeacon when a customer leaves the form without submitting. Pro uses this to fire the ax_lead_abandoned action.
Registered on: wp_ajax_nopriv_ax_log_abandoned and wp_ajax_ax_log_abandoned
Auth: None (same anti-spam philosophy as ax_submit_lead).
Adding Your Own AJAX Endpoints
To register custom AJAX actions that fit ApproxIt’s lifecycle:
PHP
add_action( 'ax_leads_ajax_init', function () {
add_action( 'wp_ajax_my_custom_action', function () {
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( 'Unauthorized' );
}
check_ajax_referer( 'ax_leads_action', 'nonce' );
// Your logic.
wp_send_json_success( array( 'result' => 'OK' ) );
} );
} );
The leads dashboard JS exposes a global axLeads.ajaxurl and axLeads.nonce you can reuse. Here is the JavaScript implementation:
JavaScript
fetch(axLeads.ajaxurl, {
method: 'POST',
body: new URLSearchParams({
action: 'my_custom_action',
nonce: axLeads.nonce,
// your params
}),
}).then(r => r.json()).then(res => console.log(res));
Nonce Reference
| Nonce Action | Used For |
ax_submit_lead | Public form submission (frontend-only nonce). |
ax_leads_action | All admin leads-dashboard AJAX (status, notes, score, delete). |
ax_save_data | Estimator save (estimator workshop). |
ax_load_template | Template loading. |
ax_test_notification | Pro test notification. |
ax_dismiss_onboarding | Pro onboarding banner dismissal. |
ax_export_leads | CSV / JSON exports. |
