SCALIX help

← All tools

salesforce_create_campaign

Salesforce write medium risk

Part of the Salesforce Agent.

What it does

Creates a Salesforce Campaign — the marketing-initiative object that LinkedIn campaigns map onto for attribution (members are leads/contacts; influenced opportunities roll up here). 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{} (Name required; Type e.g. 'LinkedIn', Status e.g. 'In Progress', IsActive, StartDate, EndDate, a custom field linking the LinkedIn campaign id/URN, BudgetedCost/ActualCost, plus custom __c), 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 to mirror a LinkedIn ad campaign as a Salesforce Campaign so leads/contacts can be attributed (via salesforce_add_campaign_member) and influenced opportunities tracked. Stamp the LinkedIn campaign id/URN into a custom field to key the nightly sync. Preview to validate fields and dedupe by Name; require explicit approval.

Inputs

NameTypeRequiredDescription
fieldsobjectyesCampaign field map. REQUIRED: Name. Common: Type (active CampaignType picklist, e.g. 'LinkedIn'), Status (active CampaignStatus), IsActive (bool), StartDate/EndDate (YYYY-MM-DD), the custom field carrying the LinkedIn campaign id/URN (e.g. LinkedIn_Campaign_Id__c), BudgetedCost, ActualCost. 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 (validate required/picklist fields, dedupe by Name) then commit only on explicit approval; never auto-create. Strict per-account isolation — create campaigns only in the authorizing client's own org. The Campaign mirrors a LinkedIn initiative for the client only; use only the client's OWN campaign data for consented purposes — never use member data for prospecting/enrichment, build a cross-account/unaffiliated database, or commingle across clients. Honor deletion on request; member-data retention (profile <=24h, social activity <=48h) applies to any cached source data.

Reminder

Confirm Name and valid Type/Status in preview, then create one Campaign in this client's org only.

Errors

Error classMeansWhat to doRetry
TOKEN_REVOKEDSession expired/invalid (HTTP 401 INVALID_SESSION_ID).needs_reauth — refresh once; only retry the POST if no Id was returned. Else prompt reconnect.yes
VALIDATION_ERRORMissing/invalid field (HTTP 400 REQUIRED_FIELD_MISSING for Name, INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST for Type/Status, FIELD_CUSTOM_VALIDATION_EXCEPTION).Surface errors[].message + fields[]; verify Type/Status picklist values; re-preview.no
CONFLICTPreview dedupe matched an existing Campaign by Name (or org rule blocked).Surface the matched Campaign Id; reuse it (add members) rather than creating a duplicate.no
PERMISSION_DENIEDUser lacks Create on Campaign or the Marketing User permission/field access (HTTP 403 INSUFFICIENT_ACCESS).Request the Marketing User flag + Create on Campaign; not retryable as-is.no
RATE_LIMITEDAPI limit exceeded (HTTP 403 REQUEST_LIMIT_EXCEEDED or 503 Retry-After).Backoff, honor Retry-After, report quota; do not blind-retry a POST.yes
PREVIEW_EXPIREDpreview_id unknown/expired or fields changed since preview.Re-run preview before committing.no
PLATFORM_UNAVAILABLESalesforce 5xx (HTTP 500/502/503).Retry with backoff after re-querying by Name to confirm the Campaign was not already created.yes

Edge cases

  • Preview (no preview_id) echoes the request and returns a preview_id; nothing is sent to Salesforce.
  • Creating a Campaign requires the Marketing User permission in addition to object Create — surface clearly if missing.
  • Type/Status are restricted picklists; inactive values are rejected — read valid values via describe.
  • Dedupe by Name: prefer reusing an existing Campaign for the same LinkedIn initiative over creating a near-duplicate.
  • Idempotency: plain create is not idempotent; on ambiguous 5xx re-query before retry.
  • Hierarchy: ParentId can nest campaigns; stats roll up — note when setting it.