salesforce_create_lead
Salesforce write high risk
Part of the Salesforce Agent.
What it does
Creates a new Lead record. 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). Key inputs: fields{} (LastName, Company required; Email, FirstName, Title, Phone, Status, LeadSource, OwnerId, plus any custom __c fields), consent_confirmed, preview_id. For LinkedIn-sourced leads prefer salesforce_upsert_lead_from_linkedin (consent-gated, idempotent by external 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 to file a NEW inbound lead the client owns (e.g. a LinkedIn Lead Gen Form submission) into their CRM. Always preview first to dedupe by Email and confirm LastName+Company; require explicit approval to write. Prefer salesforce_upsert_lead_from_linkedin when a LinkedIn external Id exists so re-syncs are idempotent. Do not use to create leads sourced from anyone other than this client's own consented audience.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
fields | object | yes | Lead field map. REQUIRED: LastName (string), Company (string). Common: Email, FirstName, Title, Phone, Status (must match an active LeadStatus picklist value), LeadSource (e.g. 'LinkedIn'), OwnerId. Include the LinkedIn external-id custom field (e.g. LinkedIn_Lead_Id__c) when applicable. Reject unknown fields rather than silently dropping them. |
consent_confirmed | boolean | yes | Must be true to proceed (checked at preview and at commit): caller attests the client has a lawful basis/consent to store this person's PII. False blocks the write. |
preview_id | string | no | Omit 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: preview (dedupe + required-field check) then commit only on explicit approval; never auto-create. LinkedIn member/lead data may be used ONLY for the authorizing client and ONLY for consented purposes — set consent_confirmed=true (lawful basis) before committing a LinkedIn-sourced lead; NEVER use member data for prospecting/enrichment, append/verify profiles, build a cross-account or unaffiliated lead database, or commingle leads across clients; forward only the client's OWN leads. Hash PII where the destination supports it. Strict per-account isolation (write only to this client's org). Honor deletion on request and member-data retention (profile <=24h, social activity <=48h) for any cached source data.
Reminder
Preview + dedupe first, confirm consent for LinkedIn-sourced PII, then commit one Lead to this client's org only — never for enrichment or prospecting.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
TOKEN_REVOKED | Session expired/invalid (HTTP 401 INVALID_SESSION_ID). | needs_reauth — refresh once and retry the same commit (POST is non-idempotent: only retry if no Id was returned). Else prompt reconnect. | yes |
VALIDATION_ERROR | Missing/invalid field (HTTP 400 REQUIRED_FIELD_MISSING e.g. LastName/Company, INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST for a bad Status, STRING_TOO_LONG, INVALID_EMAIL_ADDRESS) or a validation-rule/trigger error (FIELD_CUSTOM_VALIDATION_EXCEPTION). | Surface Salesforce's exact field-level message (errors[].message + fields[]); fix the named field and re-preview. Do not guess picklist values. | no |
CONFLICT | Org duplicate rules blocked the insert (HTTP 400/409 DUPLICATES_DETECTED) or preview dedupe found an existing Lead with the same Email. | Surface the matched record Id(s); recommend salesforce_update_lead / upsert instead of create. Do not force-insert a duplicate. | no |
PERMISSION_DENIED | User lacks Create on Lead or on a supplied field (HTTP 403 INSUFFICIENT_ACCESS). | Surface the object/field; request access. Not retryable as-is. | no |
CONSENT_REQUIRED | Lead is LinkedIn-sourced but consent_confirmed was not true (blocked client-side before commit). | Confirm lawful basis/consent for storing this client's own lead, then set consent_confirmed=true and re-preview. Never proceed without consent. | no |
RATE_LIMITED | Daily/concurrent API limit exceeded (HTTP 403 REQUEST_LIMIT_EXCEEDED or 503 Retry-After). | Backoff, honor Retry-After; report remaining quota. Do not blind-retry a POST that may have succeeded. | yes |
PREVIEW_EXPIRED | preview_id is unknown/expired or fields changed since preview. | Re-run preview to regenerate a fresh preview_id before committing. | no |
PLATFORM_UNAVAILABLE | Salesforce 5xx (HTTP 500/502/503). | Retry with backoff; because POST is non-idempotent, first re-query by Email to confirm the Lead was not already created before retrying. | yes |
Edge cases
- Preview (no preview_id) echoes the request and returns a preview_id; nothing is sent to Salesforce.
- Dedupe collision at preview: surface the existing Lead Id and steer to update/upsert rather than create.
- Org duplicate/matching rules can still block at commit even if preview found no match (rules may key on more than Email).
- Restricted Status picklist: an inactive/invalid LeadStatus value is rejected — read valid values via describe or SOQL on LeadStatus.
- Person-Account orgs: standard Lead still applies, but converted targets differ — note for downstream convert.
- Idempotency: a plain create is NOT idempotent; on ambiguous 5xx re-query before retry to avoid a duplicate. For repeatable LinkedIn syncs use salesforce_upsert_lead_from_linkedin.
- Retention/consent: any LinkedIn source payload used to build this Lead must be the client's own consented data and not retained beyond 24h/48h caches.