SCALIX help

← All tools

salesforce_convert_lead

Salesforce write high risk

Part of the Salesforce Agent.

What it does

Converts a qualified Lead into an Account + Contact (and optionally an Opportunity) via the standard convertLead invocable action. Two-phase write (Scalix guardrail, ADR-028/029): the first call (no preview_id) echoes the exact payload as the preview and returns a preview_id WITHOUT calling Salesforce - no dedupe, diff or picklist validation happens at preview; re-call with that preview_id and identical arguments to COMMIT: the request executes, Salesforce's response is returned, and an immutable audit row is written (single-use token, 30 min; a changed, forged or replayed token fails closed). Lead conversion is irreversible. Key inputs: lead_id, converted_status (an active 'converted' LeadStatus), optional account_id/contact_id to merge into existing records, opportunity_name or do_not_create_opportunity, owner_id, send_notification_email, preview_id. Returns {success:true,data:{applied,result}} where result is Salesforce's response (e.g. {id,success,errors} on create; empty on a 204 PATCH).

When to use it

Use when a Lead the client owns is qualified and should become an Account + Contact (and usually an Opportunity) so LinkedIn-sourced demand can be attributed to revenue. Preview to confirm the converted status, whether/what Opportunity is created, and any existing Account/Contact to merge into; require explicit approval. Do not convert speculatively — conversion cannot be undone and the Lead becomes read-only.

Inputs

NameTypeRequiredDescription
lead_idstringyes18-char Id of the Lead to convert. Must not be already converted.
converted_statusstringyesA LeadStatus MasterLabel where IsConverted=true (e.g. 'Closed - Converted'). Verify against the org's LeadStatus picklist; an invalid value is rejected.
account_idstringnoExisting Account Id to attach the Contact to (merge) instead of creating a new Account. Omit to create a new Account from the Lead's Company.
contact_idstringnoExisting Contact Id to merge into instead of creating a new Contact. Omit to create a new Contact.
opportunity_namestringnoName for a new Opportunity created on convert. Ignored if do_not_create_opportunity=true. If both omitted, Salesforce auto-names from the Company.
do_not_create_opportunitybooleannoTrue = convert without creating an Opportunity (Account + Contact only). Maps to the action's doNotCreateOpportunity input. Default false.
owner_idstringnoOptional User/Queue Id to own the created records (action input ownerId); defaults to the Lead owner.
send_notification_emailbooleannoWhether to email the new owner on convert (action input sendNotificationEmail). Default false.
preview_idstringnoOmit it to preview: nothing is applied, and the call returns a preview_id bound to this exact request. Pass it only after the user approves that preview in a later message, with the same arguments (leave out validate_only, and add any confirmation flag the preview names). Single-use, expires in 30 minutes; changed arguments need a fresh preview.

Safeguards

A change in two steps. The first call previews and changes nothing; Claude shows you the preview and applies it only after you approve, within 30 minutes and with the same arguments. Every applied change goes to the audit log. How changes are approved.

Policy

Two-phase and irreversible: preview the exact create/merge plan, commit only on explicit approval; never auto-convert. Operate only within the authorizing client's own org (strict per-account isolation). Lead data must be the client's OWN consented data used ONLY for consented purposes — never use member data for prospecting/enrichment, append/verify profiles, build a cross-account/unaffiliated database, or commingle leads across clients. Honor deletion on request; member-data retention (profile <=24h, social activity <=48h) applies to any cached source data. Do not log PII.

Reminder

Conversion is irreversible — confirm the previewed Account/Contact/Opportunity plan and a valid converted LeadStatus before committing; client's own org only.

Errors

Error classMeansWhat to doRetry
TOKEN_REVOKEDSession expired/invalid (HTTP 401 INVALID_SESSION_ID).needs_reauth — refresh once; only retry the convert if it did not already succeed (re-read the Lead's IsConverted first). Else prompt reconnect.yes
VALIDATION_ERRORInvalid input (HTTP 200 with isSuccess=false, or 400): bad/blank convertedStatus, missing required Opportunity fields, or a validation rule on created records.Surface the action's errors[].message; verify converted_status is an IsConverted=true MasterLabel and fix any required field; re-preview.no
CONFLICTLead already converted (CANNOT_UPDATE_CONVERTED_LEAD / already-converted error).Surface that the Lead is already converted and return the existing Account/Contact/Opportunity if known. Do not retry.no
NOT_FOUNDlead_id, account_id, or contact_id not found / out of scope (HTTP 404 / action error).Verify the Ids belong to this org and are accessible. Not retryable unchanged.no
PERMISSION_DENIEDUser lacks Convert Leads permission or Create/Edit on Account/Contact/Opportunity (HTTP 403 INSUFFICIENT_ACCESS).Request the Convert Leads permission and object access; do not retry as-is.no
RATE_LIMITEDAPI limit exceeded (HTTP 403 REQUEST_LIMIT_EXCEEDED or 503 Retry-After).Backoff, honor Retry-After, report quota.yes
PREVIEW_EXPIREDpreview_id unknown/expired or inputs changed since preview.Re-run preview to regenerate a fresh preview_id before committing.no
PLATFORM_UNAVAILABLESalesforce 5xx (HTTP 500/502/503).Retry with backoff ONLY after re-reading the Lead's IsConverted to confirm it did not already convert (action is not safely repeatable).yes

Edge cases

  • Preview (no preview_id) echoes the request and returns a preview_id; nothing is sent to Salesforce.
  • convertLead action returns HTTP 200 even on logical failure — must inspect isSuccess per input, not just the HTTP status.
  • Already-converted Lead: re-converting is blocked; surface the prior Account/Contact/Opportunity.
  • do_not_create_opportunity=true skips Opportunity creation (Account + Contact only).
  • Merging into an existing account_id/contact_id avoids duplicate Accounts — prefer it when a match exists.
  • Conversion is irreversible and makes the Lead read-only; never auto-run.
  • Retention/consent: source LinkedIn data must be the client's own consented data, not retained beyond 24h/48h.