Skip to main content
RapidDev - Software Development Agency
v0-integrationsNext.js API Route

How to Integrate LeadSquared with V0

To integrate LeadSquared with V0 by Vercel, generate a lead capture form UI with V0, create a Next.js API route that posts lead data to the LeadSquared REST API using your Access Key and Secret Key, and store credentials in Vercel environment variables. LeadSquared is popular in India and APAC markets — this setup enables real-time lead capture, activity tracking, and CRM sync from your V0-generated forms.

What you'll learn

  • How to create new leads in LeadSquared via the REST API from a Next.js API route
  • How to post lead activities (form fills, page visits, custom events) to LeadSquared from your app
  • How to build a lead capture form with V0 that syncs to LeadSquared in real time
  • How to use LeadSquared's lead scoring fields and custom fields in your API payloads
  • How to securely store LeadSquared credentials in Vercel environment variables
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Intermediate14 min read25 minutesMarketingMarch 2026RapidDev Engineering Team
TL;DR

To integrate LeadSquared with V0 by Vercel, generate a lead capture form UI with V0, create a Next.js API route that posts lead data to the LeadSquared REST API using your Access Key and Secret Key, and store credentials in Vercel environment variables. LeadSquared is popular in India and APAC markets — this setup enables real-time lead capture, activity tracking, and CRM sync from your V0-generated forms.

Syncing Leads from Your V0 App to LeadSquared CRM

LeadSquared is widely used by Indian enterprises, edtech companies, healthcare providers, and financial services firms for their marketing automation and sales CRM needs. If your target market includes India or APAC businesses, or if you're building for clients who use LeadSquared, this integration lets you capture leads from beautiful V0-generated forms and funnel them directly into the LeadSquared pipeline.

The integration pattern is straightforward: your V0-generated form collects information (name, email, phone, company, interest area), the user submits the form, and a Next.js API route on Vercel sends that data to LeadSquared's REST API. LeadSquared creates the lead record, assigns it to the appropriate queue, triggers automated follow-up workflows, and makes it available to the sales team in their dashboard — all within seconds of form submission.

Beyond basic lead capture, LeadSquared's API supports activity tracking — you can send custom events like 'Viewed Pricing Page', 'Started Free Trial', or 'Watched Demo Video' that LeadSquared uses for lead scoring and segmentation. This level of behavioral tracking is normally only possible with dedicated marketing automation platforms, but the LeadSquared API makes it accessible from any event in your V0 application.

Integration method

Next.js API Route

V0 generates the lead capture form UI. A Next.js API route receives form submissions and forwards them to the LeadSquared REST API as new leads with associated activities. Your LeadSquared Access Key and Secret Key are stored in Vercel environment variables and never exposed to the browser.

Prerequisites

  • A LeadSquared account — start at leadsquared.com; the REST API is available on Professional and Enterprise plans
  • LeadSquared API credentials — Access Key and Secret Key from your LeadSquared account under Settings → API → API Credentials
  • Your LeadSquared API host URL — this varies by region: ap-southeast-1.api.leadsquared.com (India/APAC), us-1.api.leadsquared.com (US), etc.
  • A V0 account and Next.js project deployed to Vercel
  • Basic familiarity with LeadSquared's lead fields — check Settings → Lead → Lead Fields in your LeadSquared account to see available standard and custom field names

Step-by-step guide

1

Generate the Lead Capture Form UI with V0

Use V0 to generate a professional lead capture form that matches your brand and converts visitors effectively. V0 excels at building clean form layouts with Tailwind CSS — the key is to be specific about the fields, layout, and copy you want. Lead capture forms in B2B contexts perform best when they ask for the minimum necessary information upfront. A good starting set is: full name, work email, phone number, company name, and a brief description of requirements. Avoid overwhelming visitors with 10+ fields — you can progressively collect more information via follow-up activities. Prompt V0 to include proper form validation feedback — inline error messages when required fields are empty, an email format check, and a phone number format indicator. After submission, show a clear success message that sets expectations ('Our team will contact you within 24 hours') rather than a generic 'Form submitted' message. This small detail significantly improves user trust. For multi-page or popup forms, describe the interaction pattern in your V0 prompt — V0 handles modal forms, slide-in sidebars, and multi-step wizards well. Once the form layout looks right in V0's preview, move to creating the API route before connecting the form.

V0 Prompt

Create a lead capture form for a B2B SaaS product. The form has a card layout with fields for: Full Name (required), Work Email (required, with email validation), Phone Number (required, with +91 placeholder), Company Name (required), Team Size (dropdown: 1-10, 11-50, 51-200, 200+), and a textarea for 'What are you looking for?'. Add a blue 'Get Started' submit button. On submit, show a loading spinner in the button, then show a green success card saying 'Thanks! We'll reach out within 24 hours.'

Paste this in V0 chat

Pro tip: Ask V0 to use React Hook Form or a simple controlled input pattern for the form state — this makes it straightforward to collect form values and pass them to the API route in the submit handler.

Expected result: A polished lead capture form in V0 with validation, a submit state, and a success confirmation message — ready to be connected to the LeadSquared API.

2

Create the LeadSquared API Route for Lead Creation

Build the Next.js API route that receives form data from your component and creates a new lead in LeadSquared via their REST API. LeadSquared's REST API uses HMAC-SHA256 request signing for authentication — you compute an HMAC signature using your Secret Key over the request timestamp and body, then include it as a query parameter. Alternatively, for the Capture API (lead creation endpoint), LeadSquared supports basic API key authentication passed as query parameters. The LeadSquared Capture API endpoint for creating leads is: POST https://{your-host}/v2/LeadManagement.svc/Lead.Capture. The request body is a JSON array of lead field objects with the format [{Attribute: 'EmailAddress', Value: 'user@example.com'}, ...]. Standard field names include EmailAddress, FirstName, LastName, Phone, Company, mx_Custom_Field for custom fields. LeadSquared maps incoming data to lead fields based on field names defined in your account. For standard fields like EmailAddress and Phone, the API handles deduplication automatically — if a lead with the same email already exists, the API updates the existing lead rather than creating a duplicate. This is an important behavior to understand: submitting the same email twice updates the lead rather than creating duplicates. For the access key and secret key authentication, pass them as query parameters: ?accessKey=YOUR_KEY&secretKey=YOUR_SECRET. While this looks insecure, the API is called from your server-side API route (not the browser), so these credentials never appear in client-side network requests.

app/api/leadsquared/lead/route.ts
1import { NextResponse } from 'next/server';
2
3const LS_HOST = process.env.LEADSQUARED_HOST!;
4const LS_ACCESS_KEY = process.env.LEADSQUARED_ACCESS_KEY!;
5const LS_SECRET_KEY = process.env.LEADSQUARED_SECRET_KEY!;
6
7interface LeadFormData {
8 name: string;
9 email: string;
10 phone: string;
11 company?: string;
12 teamSize?: string;
13 requirement?: string;
14 source?: string;
15}
16
17function buildLeadAttributes(data: LeadFormData) {
18 const [firstName, ...lastNameParts] = data.name.trim().split(' ');
19 const lastName = lastNameParts.join(' ');
20
21 const attributes = [
22 { Attribute: 'FirstName', Value: firstName },
23 { Attribute: 'LastName', Value: lastName || '' },
24 { Attribute: 'EmailAddress', Value: data.email },
25 { Attribute: 'Phone', Value: data.phone },
26 { Attribute: 'Source', Value: data.source || 'Website' },
27 ];
28
29 if (data.company) {
30 attributes.push({ Attribute: 'Company', Value: data.company });
31 }
32 if (data.teamSize) {
33 attributes.push({ Attribute: 'mx_Team_Size', Value: data.teamSize });
34 }
35 if (data.requirement) {
36 attributes.push({ Attribute: 'mx_Requirement', Value: data.requirement });
37 }
38
39 return attributes;
40}
41
42export async function POST(request: Request) {
43 if (!LS_HOST || !LS_ACCESS_KEY || !LS_SECRET_KEY) {
44 return NextResponse.json(
45 { error: 'LeadSquared credentials not configured' },
46 { status: 500 }
47 );
48 }
49
50 const formData: LeadFormData = await request.json();
51
52 if (!formData.email || !formData.name) {
53 return NextResponse.json(
54 { error: 'Name and email are required' },
55 { status: 400 }
56 );
57 }
58
59 const leadAttributes = buildLeadAttributes(formData);
60
61 const url = `https://${LS_HOST}/v2/LeadManagement.svc/Lead.Capture?accessKey=${LS_ACCESS_KEY}&secretKey=${LS_SECRET_KEY}`;
62
63 const response = await fetch(url, {
64 method: 'POST',
65 headers: { 'Content-Type': 'application/json' },
66 body: JSON.stringify(leadAttributes),
67 });
68
69 if (!response.ok) {
70 const errorText = await response.text();
71 console.error('LeadSquared API error:', response.status, errorText);
72 return NextResponse.json(
73 { error: 'Failed to create lead in LeadSquared' },
74 { status: 502 }
75 );
76 }
77
78 const result = await response.json();
79 return NextResponse.json({ success: true, leadId: result.Message?.Id });
80}

Pro tip: LeadSquared custom field names use the prefix 'mx_' followed by the field name with underscores replacing spaces — for example, 'Team Size' becomes 'mx_Team_Size'. Check your LeadSquared account under Settings → Lead → Lead Fields to get the exact API names for your custom fields.

Expected result: Submitting a form with name, email, and phone creates a new lead in LeadSquared within a few seconds, visible in the Leads section of your LeadSquared dashboard.

3

Add LeadSquared Credentials to Vercel Environment Variables

Store your LeadSquared credentials in Vercel's environment variable system. You need three values: your Access Key, Secret Key, and the host URL for your LeadSquared region. All three are server-only secrets — they must never be exposed to the browser. Find your LeadSquared API credentials in your account: go to Settings (gear icon) → API → API Credentials. You'll see your Access Key and Secret Key listed there. Copy both values. For the host URL, LeadSquared uses region-specific endpoints. India/Singapore: ap-southeast-1.api.leadsquared.com. US East: us-1.api.leadsquared.com. Check your LeadSquared account region or ask your LeadSquared account manager if you're unsure. In Vercel Dashboard → Settings → Environment Variables, create three variables: LEADSQUARED_ACCESS_KEY, LEADSQUARED_SECRET_KEY, and LEADSQUARED_HOST (just the hostname, without https://). Select all three scopes (Production, Preview, Development). After saving, trigger a redeployment. For local development, add all three to your .env.local file. You can use the same credentials for development and production — LeadSquared uses the same API for both environments; you'll just see test leads appearing in your account. If this is a concern, create a separate LeadSquared account or use a test pipeline/stage for development-originated leads.

.env.local
1# .env.local
2LEADSQUARED_ACCESS_KEY=your_access_key_here
3LEADSQUARED_SECRET_KEY=your_secret_key_here
4LEADSQUARED_HOST=ap-southeast-1.api.leadsquared.com

Pro tip: Tag all leads created via your API integration with a 'Source' field set to 'Website' or a specific campaign name — this helps your sales team filter API-created leads from manually entered ones and properly attribute conversions in LeadSquared's analytics.

Expected result: All three LeadSquared environment variables are configured in Vercel, and the API route creates leads successfully in your LeadSquared dashboard.

4

Add Activity Tracking for Lead Scoring

Beyond lead creation, LeadSquared's real power comes from activity tracking — sending behavioral events that update lead scores and trigger automation workflows. Create a second API route for posting activities to LeadSquared. The LeadSquared Activity API endpoint is: POST https://{host}/v2/ProspectActivity.svc/Create?accessKey={key}&secretKey={secret}. Each activity has a RelatedProspectId (the lead's ID returned when you create the lead) or an EmailAddress to look up the lead, an ActivityEvent (integer ID for the activity type — defined in your LeadSquared account), and optional parameters with additional data. Common activity events you'll want to set up in your LeadSquared account include: page visits, resource downloads, demo requests, free trial starts, and pricing page views. Create these event types in LeadSquared under Settings → Lead Activities, note their integer IDs, and map them to constants in your Next.js code. Store the lead ID returned from the lead creation API response in a session cookie or localStorage so subsequent activity events can reference the correct lead. If the lead ID isn't available (for anonymous visitors), pass the EmailAddress instead — LeadSquared will look up the lead by email.

app/api/leadsquared/activity/route.ts
1// app/api/leadsquared/activity/route.ts
2import { NextResponse } from 'next/server';
3
4const LS_HOST = process.env.LEADSQUARED_HOST!;
5const LS_ACCESS_KEY = process.env.LEADSQUARED_ACCESS_KEY!;
6const LS_SECRET_KEY = process.env.LEADSQUARED_SECRET_KEY!;
7
8// Map your custom activity event names to LeadSquared event IDs
9// Get these IDs from LeadSquared Settings → Lead Activities
10const ACTIVITY_IDS: Record<string, number> = {
11 'Viewed Pricing': 101,
12 'Downloaded Case Study': 102,
13 'Watched Demo': 103,
14 'Started Free Trial': 104,
15};
16
17export async function POST(request: Request) {
18 const { email, activityName, notes } = await request.json();
19
20 if (!email || !activityName) {
21 return NextResponse.json({ error: 'email and activityName required' }, { status: 400 });
22 }
23
24 const activityEventId = ACTIVITY_IDS[activityName];
25 if (!activityEventId) {
26 return NextResponse.json({ error: `Unknown activity: ${activityName}` }, { status: 400 });
27 }
28
29 const payload = [
30 {
31 RelatedProspectEmail: email,
32 ActivityEvent: activityEventId,
33 ActivityNote: notes || activityName,
34 Fields: [
35 { SchemaName: 'mx_Source_URL', Value: request.headers.get('referer') || '' },
36 ],
37 },
38 ];
39
40 const url = `https://${LS_HOST}/v2/ProspectActivity.svc/Create?accessKey=${LS_ACCESS_KEY}&secretKey=${LS_SECRET_KEY}`;
41
42 const response = await fetch(url, {
43 method: 'POST',
44 headers: { 'Content-Type': 'application/json' },
45 body: JSON.stringify(payload),
46 });
47
48 return NextResponse.json({ success: response.ok });
49}

Pro tip: Use fire-and-forget for activity tracking calls from the browser — wrap the fetch call in a non-awaited async call so activity tracking doesn't block UI interactions. Activity tracking failures should be silent from the user's perspective.

Expected result: User interactions on your V0 app (page views, downloads, etc.) are tracked as activities in LeadSquared, visible in the lead's activity timeline and contributing to their lead score.

Common use cases

Lead Capture Form for Marketing Landing Page

Replace manual CRM data entry with automatic lead creation from your website's contact or demo request form. When a visitor fills out the form on your V0-generated landing page, their information is instantly created as a new lead in LeadSquared with the correct source, campaign, and stage assigned.

V0 Prompt

Create a lead capture landing page with a hero section and a form card on the right side. The form has fields for Full Name, Work Email, Phone Number, Company Name, and a 'Tell us your requirement' textarea. Add a prominent 'Request a Demo' submit button. On submit, call /api/leadsquared/lead. Show a success message after submission: 'Thanks! Our team will contact you within 24 hours.'

Copy this prompt to try it in V0

Lead Scoring Activity Tracker

Track user behavior on your app and send activity events to LeadSquared for lead scoring. When a known lead views your pricing page, downloads a resource, or watches a product demo, send the corresponding activity to LeadSquared — this automatically updates their lead score and can trigger sales alerts.

V0 Prompt

Create a product features page with a 'Download Case Study' button and a pricing section. When the Download button is clicked, call /api/leadsquared/activity with an activity type of 'Downloaded Case Study'. When the pricing section scrolls into view, call the same endpoint with 'Viewed Pricing'. Show a subtle 'Resources saved' toast when the download activity is tracked.

Copy this prompt to try it in V0

Multi-Step Inquiry Form with Lead Qualification

Build a multi-step form that collects progressive lead information across several screens. After each step, send partial lead data to LeadSquared so the sales team can see incomplete form fills. On final submission, update the lead with the complete profile and trigger a qualified lead workflow.

V0 Prompt

Create a 3-step lead qualification form. Step 1: Name, Email, Phone. Step 2: Company name, team size (dropdown: 1-10, 11-50, 51-200, 200+), industry. Step 3: Use case description and budget range. Show a progress indicator between steps. On each step completion, save progress to localStorage and call /api/leadsquared/lead with the partial data. Show a completion screen after step 3.

Copy this prompt to try it in V0

Troubleshooting

API returns 401 or 'Security Exception' — lead creation fails with authentication error

Cause: The Access Key or Secret Key is incorrect, or the API host URL doesn't match your LeadSquared account's region.

Solution: Double-check both credentials in LeadSquared Settings → API → API Credentials. Verify the host matches your account region — Indian accounts use ap-southeast-1.api.leadsquared.com, US accounts use us-1.api.leadsquared.com. Test credentials directly using LeadSquared's API explorer in the developer portal.

Leads are created but custom fields (team size, requirement) appear empty in LeadSquared

Cause: Custom field names in LeadSquared must match exactly — they use the mx_ prefix and the specific schema name defined in LeadSquared's field settings, not the display name.

Solution: Go to LeadSquared Settings → Lead → Lead Fields, find your custom field, and click on it to see the 'Schema Name' — use this exact value (including mx_ prefix) as the Attribute name in your API payload.

typescript
1// Wrong: 'Team Size' or 'teamSize'
2// Correct: the Schema Name from LeadSquared settings
3{ Attribute: 'mx_Team_Size', Value: data.teamSize }

Duplicate leads being created — same email appears multiple times in LeadSquared

Cause: LeadSquared deduplicates by email address by default, but this can be overridden by account settings. Multiple submissions from the same email may create duplicates if deduplication is disabled or if email is not being used as the dedup key.

Solution: Check your LeadSquared account settings under Settings → Lead → Duplicate Check to ensure email deduplication is enabled. Add client-side form submission throttling to prevent accidental double-submissions. Consider adding a debounce on the submit button to prevent rapid re-clicks.

Best practices

  • Always include a 'Source' field in your LeadSquared lead payloads ('Website', 'Landing Page', etc.) so your sales team can segment leads by acquisition channel in reports
  • Store the LeadSquared lead ID returned from the creation API in the user's session (localStorage or cookie) so subsequent activity tracking can reference the specific lead
  • Use fire-and-forget for activity tracking API calls — don't await them in user-facing interactions to avoid adding latency to page interactions
  • Validate lead data on the server before sending to LeadSquared — check that email format is valid and required fields are present, returning a 400 error before making the LeadSquared API call
  • Map your form's source/campaign data to LeadSquared's lead source fields — this is critical for attribution reporting and measuring ROI of different marketing channels
  • Test lead creation thoroughly in your LeadSquared sandbox or with a test pipeline stage before enabling in production — remove test leads periodically to keep your CRM clean
  • Implement retry logic for LeadSquared API failures — if the API call fails due to a transient error, log the lead data and retry via a Vercel cron job or queue rather than losing the lead entirely

Alternatives

Frequently asked questions

What is LeadSquared and how is it different from HubSpot?

LeadSquared is a CRM and marketing automation platform particularly strong in India and APAC markets, with specific features for education, healthcare, and financial services industries. HubSpot is more prominent in US/European markets with a larger ecosystem and better free tier. LeadSquared often has pricing advantages for high-volume lead operations in APAC.

How do I find my LeadSquared API region/host URL?

Log into your LeadSquared account and look at the URL in your browser — the subdomain indicates your region. If it's app.leadsquared.com you're on India/APAC region (ap-southeast-1.api.leadsquared.com). Contact your LeadSquared account manager or check the API documentation at developer.leadsquared.com for your specific host URL.

Can I use the LeadSquared API on the free or starter plan?

The LeadSquared REST API is available on Professional and Enterprise plans. Basic and Starter plans may have limited or no API access. Check your account's API settings page or contact LeadSquared support to confirm API access for your subscription tier.

How do I retrieve existing leads from LeadSquared in my V0 app?

Use the LeadSquared Retrieve API: GET /v2/LeadManagement.svc/Leads.Get with your access and secret keys as query parameters. You can filter by email, phone, or custom field values. This returns lead objects with all their field values and activity history. Build a lead management dashboard in V0 that displays and updates this data.

What activity event IDs should I use for common tracking events?

Activity event IDs are defined in your LeadSquared account under Settings → Lead Activities. The specific integer IDs are account-specific and cannot be shared across accounts. Create your custom activity types in that settings section and note the IDs assigned to each. Common standard events (email sent, email opened) have pre-defined IDs documented in LeadSquared's API documentation.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.