Create Salesforce Flow
sf_create_flowCreate or update Salesforce Flows via Metadata API. Supports AutoLaunched, Screen, RecordTriggered, Scheduled flows and advanced elements such as decisions, record operations, loops, and screens.
Instructions
Creates or updates a Salesforce Flow via the Metadata API. Supports AutoLaunchedFlow (required for Agentforce actions), Screen Flow, RecordTriggeredFlow, and ScheduledFlow. Supports advanced elements: Decision, GetRecords, CreateRecords, DeleteRecords, SendEmailAlert, ApexAction, Subflow, Loop, Assignment, Screen via the 'elements' array. GetRecords filter operators supported: EqualTo, NotEqualTo, GreaterThan, LessThan, GreaterThanOrEqualTo, LessThanOrEqualTo, IsNull, StartsWith, EndsWith. Contains is NOT supported by Salesforce Flow record lookups and will return an error. IMPORTANT for Agentforce: set flowType to 'AutoLaunchedFlow' and status to 'Active' — Draft flows and Screen flows cannot be invoked by agents.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | Yes | Human-readable flow label, e.g. 'New Lead Onboarding' | |
| status | No | Flow activation status. IMPORTANT: Agentforce agents can ONLY invoke Active flows — Draft flows are invisible to agents and will cause silent failures. Set to 'Active' when creating flows for agent actions. | Draft |
| apiName | Yes | API name for the flow, e.g. 'New_Lead_Onboarding' | |
| elements | No | Advanced flow elements: Decision, GetRecords, CreateRecords, UpdateRecords, DeleteRecords, SendEmailAlert, ApexAction, Subflow, Loop, Assignment, Screen. (Wait and PlatformEvent are not supported — they produced invalid XML and were removed.) | |
| flowType | No | Flow type: 'AutoLaunchedFlow' (required for Agentforce actions — agents can ONLY invoke AutoLaunchedFlow, not Screen flows), 'Flow' (Screen flow for guided UI), 'RecordTriggeredFlow' (fires on record create/update/delete), 'ScheduledFlow' (runs on a schedule). | AutoLaunchedFlow |
| formulas | No | Formula resources — recalculated every time they are referenced. Use for derived values instead of an Assignment when the value should always reflect current data. | |
| constants | No | Constant resources — fixed values that never change during the flow run. | |
| variables | No | Input/output variables | |
| description | No | Description of what this flow does | |
| triggerType | No | When to trigger: RecordBeforeSave, RecordAfterSave, RecordBeforeDelete | |
| fieldUpdates | No | Simple field updates on the triggering record (for RecordTriggeredFlow) | |
| textTemplates | No | Text template resources — reusable text blocks with merge fields, typically for email bodies. | |
| triggerObject | No | Object API name for record-triggered flows, e.g. 'Opportunity' | |
| recordTriggerType | No | Which record changes fire the flow: 'Create' (new records only), 'Update' (edits only), 'CreateAndUpdate' (default), 'Delete'. Ignored for RecordBeforeDelete, which is already delete-only. | |
| scheduleFrequency | No | How often a ScheduledFlow runs. Defaults to Daily. | |
| scheduleStartDate | No | Date a ScheduledFlow starts running, YYYY-MM-DD. Defaults to today. | |
| scheduleStartTime | No | Time of day a ScheduledFlow runs, e.g. '13:00:00.000Z'. Defaults to midnight UTC. | |
| triggerFilterFormula | No | Formula to filter which records trigger the flow, e.g. "ISPICKVAL(StageName,'Closed Won')" | |
| submitForApprovalProcessName | No | API name of the Approval Process to automatically submit the record into. Works with any approval process — just pass its API name. |