YSUITE Lead API Integration Guide

Base URL: https://api.ysuite.org/api/leads/create/{ACCESS_KEY}

This API allows your website forms (e.g., Contact Us, Get a Quote, Book a Demo, etc.) to automatically send new leads to your YSUITE CRM account in real-time.

1. Authentication

Each organization receives:

• Access Key → included in the URL path
• Secret → passed as a request header

Example:

Access Key: YSUITEAKIA7ABCDEF123
Secret: q8T7d1hG7xK1zF6l2o9W3kJ0hM8u2R1b
Endpoint Example: https://api.ysuite.org/api/leads/create/YKIA7ABCDEF123
Header: x-ysuite-secret: q8T7d1hG7xK1zF6l2o9W3kJ0hM8u2R1b

Actual Access Key and Secret will be shared separately.

2. Request Format

Method: POST
Headers:
Content-Type: application/json
x-ysuite-secret: <YOUR_SECRET_KEY>

Body Example (JSON):

{
  "lead_name": "John Doe",
  "lead_email": "john@example.com",
  "lead_phone": "+971501234567",
  "lead_source": "Website Contact Form",
  "utm_campaign": "summer_sale",
  "utm_medium": "google_ads",
  "message": "Interested in your services."
}

3. Example Integrations

A. WordPress (Contact Form 7)

Add the following PHP snippet to your theme’s functions.php file to automatically send form data to YSUITE upon submission:

add_action('wpcf7_mail_sent', 'ysuite_send_to_api');
function ysuite_send_to_api($contact_form) {
    $access_key = 'YSUITEAKIA7ABCDEF123';
    $secret_key = 'q8T7d1hG7xK1zF6l2o9W3kJ0hM8u2R1b';
    $url = "https://api.ysuite.org/api/leads/create/$access_key";

    $submission = WPCF7_Submission::get_instance();
    if ($submission) {
        $data = $submission->get_posted_data();
        $payload = [
            "lead_name" => sanitize_text_field($data['your-name']),
            "lead_email" => sanitize_email($data['your-email']),
            "lead_phone" => sanitize_text_field($data['your-phone']),
            "lead_source" => "Website Contact Form"
        ];
        $response = wp_remote_post($url, [
            'headers' => [
                'Content-Type' => 'application/json',
                'x-ysuite-secret' => $secret_key
            ],
            'body' => wp_json_encode($payload),
            'timeout' => 10,
            'method' => 'POST'
        ]);
    }
}

B. Elementor Pro Form

1. Open your Elementor Form → Actions After Submit → Add ‘Webhook’.
2. Webhook URL: https://api.ysuite.org/api/leads/create/YSUITEAKIA7ABCDEF123
3. Headers:
   x-ysuite-secret: q8T7d1hG7xK1zF6l2o9W3kJ0hM8u2R1b
   Content-Type: application/json
4. Elementor will send form fields as JSON automatically.

C. Custom PHP Form

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $access_key = "YSUITEAKIA7ABCDEF123";
    $secret_key = "q8T7d1hG7xK1zF6l2o9W3kJ0hM8u2R1b";
    $url = "https://api.ysuite.org/api/leads/create/$access_key";

    $data = [
        "lead_name" => $_POST['name'],
        "lead_email" => $_POST['email'],
        "lead_phone" => $_POST['phone'],
        "lead_source" => "Website Form"
    ];

    $ch = curl_init($url);
    curl_setopt_array($ch, [
        CURLOPT_POST => 1,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_HTTPHEADER => [
            "Content-Type: application/json",
            "x-ysuite-secret: $secret_key"
        ],
        CURLOPT_POSTFIELDS => json_encode($data)
    ]);
    $response = curl_exec($ch);
    curl_close($ch);
}

4. Security Guidelines

• Keep Secret private — do not expose it in frontend JavaScript.
• Always send API requests from your backend (PHP, Node, etc.).
• HTTPS is required.

5. Troubleshooting

• 401 Unauthorized → Invalid Access Key
• 403 Forbidden → Invalid Secret
• 400 Bad Request → Missing required fields
• 500 Internal Error → Network or API issue

6. Support

For configuration assistance, raise a support ticket or contact us.

Leave a Reply

Your email address will not be published. Required fields are marked *