SCALIX help

← All tools

salesforce_update_lead

Salesforce write high risk

Part of the Salesforce Agent.

What it does

Updates fields on an existing Lead by Id. 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). Salesforce PATCH returns 204 No Content on success (no body). Key inputs: record_id, fields{} (only the fields to change), preview_id. Use to correct lead data, set Status, reassign OwnerId, or stamp LinkedIn campaign attribution fields. 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 change specific fields on a Lead the client owns — update Status as it progresses, reassign owner, correct contact details, or stamp LinkedIn attribution fields (campaign, source). Always preview the diff and get explicit approval; only the supplied fields change. Do not use to convert (use salesforce_convert_lead) or to write data from anyone but this client's consented audience.

Inputs

NameTypeRequiredDescription
record_idstringyes18-char (preferred) Lead Id to update.
fieldsobjectyesSparse map of ONLY the fields to change (e.g. {Status:'Working - Contacted', OwnerId:'005...'}). Omitted fields are untouched. Setting a field to null clears it. Reject unknown fields.
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: preview the before->after diff, commit only on explicit approval; never auto-update. Edit only Leads in the authorizing client's own org (strict per-account isolation). Any LinkedIn-derived values written must be the client's OWN consented data used ONLY for consented purposes — never use member data for enrichment/prospecting, append/verify profiles, build a cross-account/unaffiliated database, or commingle across clients. Do not log PII; honor deletion on request and member-data retention (profile <=24h, social activity <=48h) for cached source data.

Reminder

Confirm the previewed before->after diff before committing a sparse PATCH; client's own org and consented data only.

Errors

Error classMeansWhat to doRetry
TOKEN_REVOKEDSession expired/invalid (HTTP 401 INVALID_SESSION_ID).needs_reauth — refresh once and retry; PATCH is idempotent so retry is safe. Else prompt reconnect.yes
NOT_FOUNDLead Id does not exist, was converted/deleted, or is out of sharing scope (HTTP 404 NOT_FOUND / ENTITY_IS_DELETED).Verify the Id and that the Lead is not already converted. Not retryable unchanged.no
VALIDATION_ERRORInvalid field/value (HTTP 400 INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST, STRING_TOO_LONG, FIELD_CUSTOM_VALIDATION_EXCEPTION) or attempt to edit a read-only/converted Lead (CANNOT_UPDATE_CONVERTED_LEAD).Surface the exact errors[].message + fields[]; fix and re-preview. A converted Lead is immutable — do not retry.no
PERMISSION_DENIEDUser lacks Edit on Lead or a field (HTTP 403 INSUFFICIENT_ACCESS), or record not shared for edit.Surface the object/field; request access or remove the field. Not retryable as-is.no
RATE_LIMITEDAPI limit exceeded (HTTP 403 REQUEST_LIMIT_EXCEEDED or 503 Retry-After).Backoff, honor Retry-After, report remaining quota.yes
PREVIEW_EXPIREDpreview_id unknown/expired or fields/record_id 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; PATCH is idempotent so safe to retry the same change.yes

Edge cases

  • Preview (no preview_id) echoes the request and returns a preview_id; nothing is sent to Salesforce.
  • Sparse update: only supplied fields change; to clear a field pass it explicitly as null.
  • Converted Lead is immutable — updates fail with CANNOT_UPDATE_CONVERTED_LEAD.
  • No-op update (values already equal) still returns 204; surface 'no change' to the user.
  • Idempotency: PATCH by Id is naturally idempotent — re-applying the same body is safe.
  • Retention/consent: any LinkedIn-derived value must be the client's own consented data; do not retain source caches beyond 24h/48h.