# How to Integrate LeadSquared with V0

- Tool: V0
- Difficulty: Intermediate
- Time required: 25 minutes
- Last updated: March 2026

## 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.

## Before you start

- 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.

**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.

```
import { NextResponse } from 'next/server';

const LS_HOST = process.env.LEADSQUARED_HOST!;
const LS_ACCESS_KEY = process.env.LEADSQUARED_ACCESS_KEY!;
const LS_SECRET_KEY = process.env.LEADSQUARED_SECRET_KEY!;

interface LeadFormData {
  name: string;
  email: string;
  phone: string;
  company?: string;
  teamSize?: string;
  requirement?: string;
  source?: string;
}

function buildLeadAttributes(data: LeadFormData) {
  const [firstName, ...lastNameParts] = data.name.trim().split(' ');
  const lastName = lastNameParts.join(' ');

  const attributes = [
    { Attribute: 'FirstName', Value: firstName },
    { Attribute: 'LastName', Value: lastName || '' },
    { Attribute: 'EmailAddress', Value: data.email },
    { Attribute: 'Phone', Value: data.phone },
    { Attribute: 'Source', Value: data.source || 'Website' },
  ];

  if (data.company) {
    attributes.push({ Attribute: 'Company', Value: data.company });
  }
  if (data.teamSize) {
    attributes.push({ Attribute: 'mx_Team_Size', Value: data.teamSize });
  }
  if (data.requirement) {
    attributes.push({ Attribute: 'mx_Requirement', Value: data.requirement });
  }

  return attributes;
}

export async function POST(request: Request) {
  if (!LS_HOST || !LS_ACCESS_KEY || !LS_SECRET_KEY) {
    return NextResponse.json(
      { error: 'LeadSquared credentials not configured' },
      { status: 500 }
    );
  }

  const formData: LeadFormData = await request.json();

  if (!formData.email || !formData.name) {
    return NextResponse.json(
      { error: 'Name and email are required' },
      { status: 400 }
    );
  }

  const leadAttributes = buildLeadAttributes(formData);

  const url = `https://${LS_HOST}/v2/LeadManagement.svc/Lead.Capture?accessKey=${LS_ACCESS_KEY}&secretKey=${LS_SECRET_KEY}`;

  const response = await fetch(url, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(leadAttributes),
  });

  if (!response.ok) {
    const errorText = await response.text();
    console.error('LeadSquared API error:', response.status, errorText);
    return NextResponse.json(
      { error: 'Failed to create lead in LeadSquared' },
      { status: 502 }
    );
  }

  const result = await response.json();
  return NextResponse.json({ success: true, leadId: result.Message?.Id });
}
```

**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
LEADSQUARED_ACCESS_KEY=your_access_key_here
LEADSQUARED_SECRET_KEY=your_secret_key_here
LEADSQUARED_HOST=ap-southeast-1.api.leadsquared.com
```

**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
import { NextResponse } from 'next/server';

const LS_HOST = process.env.LEADSQUARED_HOST!;
const LS_ACCESS_KEY = process.env.LEADSQUARED_ACCESS_KEY!;
const LS_SECRET_KEY = process.env.LEADSQUARED_SECRET_KEY!;

// Map your custom activity event names to LeadSquared event IDs
// Get these IDs from LeadSquared Settings → Lead Activities
const ACTIVITY_IDS: Record<string, number> = {
  'Viewed Pricing': 101,
  'Downloaded Case Study': 102,
  'Watched Demo': 103,
  'Started Free Trial': 104,
};

export async function POST(request: Request) {
  const { email, activityName, notes } = await request.json();

  if (!email || !activityName) {
    return NextResponse.json({ error: 'email and activityName required' }, { status: 400 });
  }

  const activityEventId = ACTIVITY_IDS[activityName];
  if (!activityEventId) {
    return NextResponse.json({ error: `Unknown activity: ${activityName}` }, { status: 400 });
  }

  const payload = [
    {
      RelatedProspectEmail: email,
      ActivityEvent: activityEventId,
      ActivityNote: notes || activityName,
      Fields: [
        { SchemaName: 'mx_Source_URL', Value: request.headers.get('referer') || '' },
      ],
    },
  ];

  const url = `https://${LS_HOST}/v2/ProspectActivity.svc/Create?accessKey=${LS_ACCESS_KEY}&secretKey=${LS_SECRET_KEY}`;

  const response = await fetch(url, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(payload),
  });

  return NextResponse.json({ success: response.ok });
}
```

**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.

## 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

## 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.

Prompt example:

```
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.'
```

### 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.

Prompt example:

```
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.
```

### 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.

Prompt example:

```
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.
```

## 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.

```
// Wrong: 'Team Size' or 'teamSize'
// Correct: the Schema Name from LeadSquared settings
{ 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.

## 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.

---

Source: https://www.rapidevelopers.com/v0-integrations/leadsquared
© RapidDev — https://www.rapidevelopers.com/v0-integrations/leadsquared
