X Enterprises
fastify-xwhatconverts

leads.create

Create a new WhatConverts lead under a profile with type, contact info, and attribution data.

leads.create

Create a new lead in WhatConverts under the specified profile. profileId and leadType are required.

Signature

fastify.xwhatconverts.leads.create(params: {
  profileId: string;
  leadType: "phone_call" | "form" | "chat" | "transaction";
  sendNotification?: boolean;
  dateTime?: string;
  quotable?: boolean;
  quoteValue?: number;
  salesValue?: number;
  leadSource?: string;
  leadMedium?: string;
  leadCampaign?: string;
  leadContent?: string;
  leadKeyword?: string;
  contactName?: string;
  contactEmail?: string;
  contactPhone?: string;
  leadUrl?: string;
  additionalFields?: Record<string, unknown>;
}): Promise<object>

Params

NameTypeRequiredDescription
profileIdstringYesWhatConverts profile ID to create the lead under.
leadTypestringYesLead type: phone_call, form, chat, or transaction.
sendNotificationbooleanNoSend notification email on creation.
dateTimestringNoLead date/time in YYYY-MM-DD HH:MM:SS format.
quotablebooleanNoWhether the lead is quotable.
quoteValuenumberNoQuote value for the lead.
salesValuenumberNoSales value for the lead.
leadSourcestringNoTraffic source (e.g. "google").
leadMediumstringNoTraffic medium (e.g. "cpc").
leadCampaignstringNoCampaign name.
leadContentstringNoAd content identifier.
leadKeywordstringNoSearch keyword.
contactNamestringNoContact's full name.
contactEmailstringNoContact's email address.
contactPhonestringNoContact's phone number.
leadUrlstringNoPage URL where the lead originated.
additionalFieldsobjectNoCustom key-value fields.

Returns

The created WhatConverts lead object.

Throws

  • [xWhatConverts] leads.create: params object is required — called without a params object.
  • [xWhatConverts] leads.create: profileId is required — missing profileId.
  • [xWhatConverts] leads.create: leadType is required — missing leadType.
  • [xWhatConverts] Network error: <message> — network-level failure.
  • [xWhatConverts] API error: <status> — non-2xx response from WhatConverts.

Examples

Basic — create a form lead

const lead = await fastify.xwhatconverts.leads.create({
  profileId: "98765",
  leadType: "form",
  contactName: "Jane Smith",
  contactEmail: "jane@example.com",
  leadSource: "google",
  leadMedium: "cpc",
});

console.log(lead.lead_id); // created lead ID

Realistic — capture a contact form submission with attribution

fastify.post("/contact", async (request, reply) => {
  const { name, email, phone, message } = request.body;
  const { utm_source, utm_medium, utm_campaign } = request.query;

  const lead = await fastify.xwhatconverts.leads.create({
    profileId: process.env.WC_PROFILE_ID,
    leadType: "form",
    contactName: name,
    contactEmail: email,
    contactPhone: phone,
    leadSource: utm_source,
    leadMedium: utm_medium,
    leadCampaign: utm_campaign,
    leadUrl: request.headers.referer,
    sendNotification: true,
    additionalFields: { message },
  });

  return { leadId: lead.lead_id };
});

See Also

AI Context

package: "@xenterprises/fastify-xwhatconverts"
method: fastify.xwhatconverts.leads.create(params)
use-when: Create a new WhatConverts lead programmatically (e.g. form submission, offline conversion import)
params: profileId (string, required), leadType (string, required), plus optional contact/attribution fields
returns: created WhatConverts lead object
Copyright © 2026