1. Get your website credentials
- Sign in to Admin or Client login and open Websites / My websites.
- Under your website, select Generate key. Copy the new submission key before leaving the page.
- Copy the form’s public ID and submission endpoint from the same website card.
- Save the key in your website backend’s private environment configuration.
Private backend .env
KUSHWAHA_LEADS_URL=https://leads.kushwahatechsolutions.com
KUSHWAHA_LEADS_API_KEY=YOUR_WEBSITE_API_KEY
KUSHWAHA_LEADS_FORM_ID=YOUR_FORM_PUBLIC_IDReplace both placeholders with your own values. Examples on this public page contain no real credentials or client configuration.
2. Send a test inquiry
Run this from a trusted terminal. Replace the key and form ID. This creates a real test lead, which you can review and delete in your dashboard.
cURL
curl --request POST \
'https://leads.kushwahatechsolutions.com/api/v1/forms/YOUR_FORM_PUBLIC_ID/submissions' \
--header 'Authorization: Bearer YOUR_WEBSITE_API_KEY' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: unique-inquiry-123' \
--data '{
"name": "Jane Smith",
"email": "jane@example.com",
"message": "Please send details about your service.",
"fields": {"service": "Website development"}
}'Use a new Idempotency-Key for each new inquiry; reuse the same key and content when retrying that inquiry.
3. Integrate a Laravel backend
Place the configuration mapping in config/services.php and the helper in your backend service code. Call storeKushwahaInquiry($validated, $inquiryId) after local validation and spam checks. Supply a stable inquiry ID stored by your backend.
Laravel HTTP client
<?php
// On the origin Laravel website: add these values to config/services.php.
// 'kushwaha_leads' => [
// 'url' => env('KUSHWAHA_LEADS_URL'),
// 'api_key' => env('KUSHWAHA_LEADS_API_KEY'),
// 'form_id' => env('KUSHWAHA_LEADS_FORM_ID'),
// ],
// Validate the origin form and apply CSRF/spam controls before calling.
// Persist one inquiry ID locally and reuse it with the same data for retries.
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
function storeKushwahaInquiry(array $validated, string $inquiryId): array
{
try {
$response = Http::withToken(config('services.kushwaha_leads.api_key'))
->acceptJson()->withHeaders(['Idempotency-Key' => $inquiryId])
->connectTimeout(3)->timeout(10)
->post(rtrim(config('services.kushwaha_leads.url'), '/')
.'/api/v1/forms/'.config('services.kushwaha_leads.form_id').'/submissions', $validated);
} catch (ConnectionException) {
return ['stored' => false, 'retryable' => true, 'message' => 'Storage could not be confirmed.'];
}
return [
'stored' => $response->status() === 201,
'submission_id' => $response->status() === 201 ? $response->json('data.submission_id') : null,
'retryable' => $response->serverError() || $response->status() === 429,
'retry_after' => $response->header('Retry-After'),
];
}
Only show a success message if stored is true. Keep your local inquiry and ID when retryable is true. Respect retry_after when supplied.
4. Integrate a plain PHP backend
Requires PHP with cURL. Set the three environment variables on your server. This transport helper belongs in your backend, after request validation, CSRF checks, and spam protection. It is not a complete public form handler.
PHP cURL helper
<?php
// Transport helper for your origin backend, not a public proxy endpoint.
// Validate input, CSRF and spam controls before calling. Persist inquiry ID
// and validated content locally if durable retries are required.
function storeKushwahaInquiry(array $validated, string $inquiryId): array
{
if (! preg_match('/\A[\x21-\x7E]{1,100}\z/', $inquiryId)) {
throw new InvalidArgumentException('Invalid inquiry ID.');
}
$url = rtrim(getenv('KUSHWAHA_LEADS_URL') ?: '', '/');
$key = getenv('KUSHWAHA_LEADS_API_KEY');
$form = getenv('KUSHWAHA_LEADS_FORM_ID');
if (! str_starts_with($url, 'https://') || ! $key || ! $form) {
throw new RuntimeException('Configure the HTTPS URL, private API key and form ID.');
}
$curl = curl_init($url.'/api/v1/forms/'.rawurlencode($form).'/submissions');
curl_setopt_array($curl, [
CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 3, CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => ['Authorization: Bearer '.$key, 'Content-Type: application/json', 'Accept: application/json', 'Idempotency-Key: '.$inquiryId],
CURLOPT_POSTFIELDS => json_encode($validated, JSON_THROW_ON_ERROR),
]);
$result = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);
return ['stored' => $result !== false && $status === 201, 'retryable' => $result === false || $status >= 500 || $status === 429];
}
The Laravel and PHP helpers are alternatives; use the one matching your backend.
Test with Postman
- Set the method to POST and paste your form’s submission endpoint.
- Under Authorization, choose Bearer Token and enter your website submission key. Keep it out of shared collections.
- Under Body, choose raw → JSON and use the inquiry JSON from the cURL example.
- Add
Accept: application/jsonand an optionalIdempotency-Keyheader, then send. - Expect 201 and find the inquiry in your dashboard’s Leads page.
Understand the response
HTTP 201
{
"success": true,
"message": "Your inquiry has been submitted successfully.",
"data": { "submission_id": 1024 }
}201 means stored in the database. It does not mean email was sent—email notifications are disabled.
| HTTP status | What to do |
|---|---|
| 401 | Check the website key; it may be missing, expired, or revoked. |
| 403 | Check whether the website is enabled. |
| 404 | Check the form public ID, whether it is active, and whether the key belongs to the same website. |
| 409 | The idempotency key was used with different content. Reuse the original content for a retry, or a new key for a new inquiry. |
| 413 | Reduce the request to 32 KB or less. |
| 415 | Send Content-Type: application/json. |
| 422 | Correct the validation errors. Include an email or phone and a nonblank message. |
| 429 | Wait for Retry-After, then retry using the same inquiry ID. |
| 500 | Keep the inquiry locally and retry later with the same ID. |
Before connecting a public form
Your browser form should send to your own backend, which calls this API. Validate locally, apply CSRF and spam controls, and rate-limit visitors. A timeout can happen after the lead has been saved; preserve the inquiry ID for safe retries. For reliable collection during downtime, store inquiries durably on your origin backend.
Message limit: 5,000 characters. Contact requires email or phone. Optional custom fields support up to 20 keys and shallow scalar arrays. See the full request contract for all limits.