> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/salesforce.md).

# Salesforce

Query and manage your Salesforce instance with CRUD operations.

* MCP connection

## Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector          | Authentication |
| ------------------ | -------------- |
| Salesforce (OAuth) | OAuth sign-in  |
| Salesforce         | Credentials    |
| Salesforce (MCP)   | MCP with OAuth |

### Salesforce (OAuth)

Connect to Salesforce using OAuth with automatic credential management by StackAI.

#### Set up in Salesforce

1. Use a Salesforce account with access to the records and operations that your workflow needs.
2. If your organization restricts application access or user consent, have its administrator approve the connection before you sign in.

#### Set up in StackAI

1. Open **Settings → Connections**, add a connection, and select **Salesforce (OAuth)**.
2. Select **Connect**, sign in to the provider account, and review the requested access. Complete authorization to return to StackAI.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

StackAI obtains the OAuth credentials during sign-in. You do not need to paste an access token or refresh token.

**Provider documentation:** [Setup reference](https://help.salesforce.com/s/articleView?id=sf.connected_app_overview.htm\&type=5).

### Salesforce

Connect to Salesforce CRM to access business objects. Supports reading and writing to Salesforce records.

#### Set up in Salesforce

1. Sign in to Salesforce as an admin and open Setup.
2. Obtain that user's security token (Setup - reset My Security Token, sent to the user's email) if your org requires it in addition to the password.

#### Set up in StackAI

1. Open **Settings → Connections**, add a connection, and select **Salesforce**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field     | Required                 | What to enter                                                                                                                                                                     |
| ----------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Username          | Yes                      | Your Salesforce username (email address).                                                                                                                                         |
| Password          | Yes                      | Your Salesforce password.                                                                                                                                                         |
| Security Token    | Yes                      | Your Salesforce security token. Reset it in your Salesforce settings if needed. [Provider instructions](https://help.salesforce.com/s/articleView?id=sf.user_security_token.htm). |
| Domain (Optional) | Optional / as applicable | Custom domain for your Salesforce instance (e.g., 'na1' for North America).                                                                                                       |
| Sandbox           | Optional / as applicable | Whether this is a Salesforce sandbox instance.                                                                                                                                    |

**Provider documentation:** [Setup reference](https://help.salesforce.com/s/articleView?id=sf.user_security_token.htm\&type=5).

### Salesforce (MCP)

Connect to a Salesforce Hosted MCP server using an External Client App. The selected server and Salesforce permissions govern available tools.

#### Set up in Salesforce

1. Select a Salesforce Hosted MCP server or an administrator-configured custom MCP server. Use the endpoint for the correct Salesforce environment.
2. Create a Salesforce External Client App with the StackAI callback URL, PKCE, and the mcp\_api scope.
3. Record the consumer key and, if required by the client configuration, its consumer secret. Give the authorizing user the Salesforce permissions needed by the tools.

#### Set up in StackAI

1. Open **Settings → Connections**, add a connection, and select **Salesforce (MCP)**.
2. Complete the connector configuration below. If you do not have access to these settings, ask your StackAI administrator to configure the connector.
3. Select **Connect**, sign in to the provider account, and review the requested access. Complete authorization to return to StackAI.
4. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connector configuration**

| StackAI field          | Required                 | What to enter                                                                                                                                                      |
| ---------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Server URL             | Yes                      | Salesforce Hosted MCP server URL. Use the sandbox URL for a sandbox org, or paste the URL of an admin-configured custom server.                                    |
| Scopes                 | Read-only                | OAuth scopes required by Salesforce Hosted MCP servers. This value is shown for reference; it is not an editable credential.                                       |
| Consumer Key           | Optional / as applicable | Consumer key from a Salesforce External Client App configured with StackAI's callback URL, PKCE, and the mcp\_api scope.                                           |
| Consumer Secret        | Optional / as applicable | Optional consumer secret from the External Client App. Public PKCE clients can leave this blank.                                                                   |
| Authorization Endpoint | Optional / as applicable | The OAuth endpoint URL (e.g., <https://mcp.example.com/oauth2/authorize>). You probably don't have to set this, the OAuth flow will try to discover it on its own. |
| Custom Headers         | Optional / as applicable | Optional custom headers to send to the MCP server for authentication or other purposes.                                                                            |

**Provider documentation:** [Setup reference](https://developer.salesforce.com/docs/platform/hosted-mcp-servers/guide/client-connection-overview.html).

### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Detailed setup guides

* [Configure Salesforce authentication](/integrations/catalog/salesforce/configure-salesforce-authentication.md)
* [Build a Salesforce agent](/integrations/catalog/salesforce/build-a-salesforce-agent.md)

## Use an action

1. Add the required **Salesforce** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

## Actions

### Query Salesforce

Query Salesforce using SOQL queries

#### Inputs

| Field | Type   | Required | Description                                          |
| ----- | ------ | -------- | ---------------------------------------------------- |
| Query | string | Yes      | SOQL query to execute against Salesforce. Default: . |

#### Outputs

| Field   | Type   | Description                       |
| ------- | ------ | --------------------------------- |
| Query   | string | The SOQL query that was executed. |
| Results | string | The results of the query.         |

### Create Case

Create a new case in Salesforce

#### Inputs

| Field       | Type     | Required | Description                                                   |
| ----------- | -------- | -------- | ------------------------------------------------------------- |
| Subject     | string   | Yes      | The subject/title of the case.                                |
| Status      | string   | No       | The status of the case. Default: New.                         |
| Priority    | string   | No       | The priority level of the case. Default: Medium.              |
| Origin      | string   | No       | The origin/source of the case.                                |
| Description | textarea | No       | The detailed description of the case.                         |
| Account ID  | string   | No       | The Salesforce ID of the account to associate with this case. |
| Contact ID  | string   | No       | The Salesforce ID of the contact to associate with this case. |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Case ID | string  | The ID of the created case.                |
| Success | boolean | Whether the case was created successfully. |

### Update Case

Update an existing case in Salesforce

#### Inputs

| Field         | Type     | Required | Description                                                                            |
| ------------- | -------- | -------- | -------------------------------------------------------------------------------------- |
| Case ID       | string   | Yes      | The Salesforce ID of the case to update.                                               |
| Subject       | string   | No       | The subject/title of the case.                                                         |
| Status        | string   | No       | The status of the case.                                                                |
| Priority      | string   | No       | The priority level of the case.                                                        |
| Origin        | string   | No       | The origin/source of the case.                                                         |
| Description   | textarea | No       | The detailed description of the case.                                                  |
| Account ID    | string   | No       | The Salesforce ID of the account to associate with this case.                          |
| Contact ID    | string   | No       | The Salesforce ID of the contact to associate with this case.                          |
| Custom Fields | object   | No       | Additional Case fields to update, keyed by Salesforce API name (e.g. PO\_Number\_\_c). |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Case ID | string  | The ID of the updated case.                |
| Success | boolean | Whether the case was updated successfully. |

### Delete Case

Delete a case from Salesforce

#### Inputs

| Field   | Type   | Required | Description                              |
| ------- | ------ | -------- | ---------------------------------------- |
| Case ID | string | Yes      | The Salesforce ID of the case to delete. |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Case ID | string  | The ID of the deleted case.                |
| Success | boolean | Whether the case was deleted successfully. |

### Get Case

Retrieve a case from Salesforce by ID

#### Inputs

| Field   | Type          | Required | Description                                                        |
| ------- | ------------- | -------- | ------------------------------------------------------------------ |
| Case ID | string        | Yes      | The Salesforce ID of the case to retrieve.                         |
| Fields  | string\_array | No       | Fields to return. Leave empty to return every field on the record. |

#### Outputs

| Field | Type   | Description                      |
| ----- | ------ | -------------------------------- |
| Case  | object | The case returned by Salesforce. |

### Create Opportunity

Create a new opportunity in Salesforce

#### Inputs

| Field            | Type            | Required | Description                                                                                                                                                                                                                  |
| ---------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Opportunity Name | string          | Yes      | The name of the opportunity.                                                                                                                                                                                                 |
| Stage Name       | string          | Yes      | The sales stage of the opportunity.                                                                                                                                                                                          |
| Close Date       | string          | Yes      | The expected close date of the opportunity.                                                                                                                                                                                  |
| Amount           | number          | No       | The opportunity amount.                                                                                                                                                                                                      |
| Account          | select (string) | No       | The Account associated with this opportunity. Pick by name from the dropdown OR paste a Salesforce Account ID directly. The value stored is the Salesforce Account ID either way. Options load from the selected connection. |
| Description      | textarea        | No       | A description of the opportunity.                                                                                                                                                                                            |
| Record Type ID   | string          | No       | The Salesforce Record Type ID for this opportunity (e.g. Strategic Opportunity, Pre-Sales Request). Leave blank to land in the org's default record type.                                                                    |
| Custom Fields    | object          | No       | Additional Opportunity fields as a JSON object (API name → value).                                                                                                                                                           |

#### Outputs

| Field          | Type    | Description                                       |
| -------------- | ------- | ------------------------------------------------- |
| Opportunity ID | string  | The ID of the created opportunity.                |
| Success        | boolean | Whether the opportunity was created successfully. |

### Update Opportunity

Update an existing opportunity in Salesforce

#### Inputs

| Field            | Type            | Required | Description                                                                                                                                                            |
| ---------------- | --------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Opportunity ID   | string          | Yes      | The Salesforce ID of the opportunity to update.                                                                                                                        |
| Opportunity Name | string          | No       | The new name of the opportunity.                                                                                                                                       |
| Stage Name       | string          | No       | The new sales stage of the opportunity.                                                                                                                                |
| Close Date       | string          | No       | The new expected close date.                                                                                                                                           |
| Amount           | number          | No       | The new opportunity amount.                                                                                                                                            |
| Account          | select (string) | No       | Reassign this opportunity to a different Account. Pick by name from the dropdown OR paste a Salesforce Account ID directly. Options load from the selected connection. |
| Description      | textarea        | No       | The new description of the opportunity.                                                                                                                                |
| Custom Fields    | object          | No       | Additional Opportunity fields as a JSON object (API name → value).                                                                                                     |

#### Outputs

| Field          | Type    | Description                                       |
| -------------- | ------- | ------------------------------------------------- |
| Opportunity ID | string  | The ID of the updated opportunity.                |
| Success        | boolean | Whether the opportunity was updated successfully. |

### Delete Opportunity

Delete an opportunity from Salesforce

#### Inputs

| Field          | Type   | Required | Description                                     |
| -------------- | ------ | -------- | ----------------------------------------------- |
| Opportunity ID | string | Yes      | The Salesforce ID of the opportunity to delete. |

#### Outputs

| Field          | Type    | Description                                       |
| -------------- | ------- | ------------------------------------------------- |
| Opportunity ID | string  | The ID of the deleted opportunity.                |
| Success        | boolean | Whether the opportunity was deleted successfully. |

### Create Record

Create a new record in any Salesforce object dynamically

#### Inputs

| Field         | Type   | Required | Description                                                                        |
| ------------- | ------ | -------- | ---------------------------------------------------------------------------------- |
| Object Name   | string | Yes      | The API name of the Salesforce object to create a record in.                       |
| Record Fields | object | Yes      | A dictionary of field-value pairs representing the data to populate in the record. |

#### Outputs

| Field       | Type    | Description                                  |
| ----------- | ------- | -------------------------------------------- |
| Record ID   | string  | The ID of the created record.                |
| Success     | boolean | Whether the record was created successfully. |
| Object Name | string  | The object name that was used for creation.  |

### Update Record

Update an existing record in any Salesforce object dynamically

#### Inputs

| Field         | Type   | Required | Description                                                                      |
| ------------- | ------ | -------- | -------------------------------------------------------------------------------- |
| Object Name   | string | Yes      | The API name of the Salesforce object to update a record in.                     |
| Record ID     | string | Yes      | The Salesforce ID of the record to update.                                       |
| Record Fields | object | Yes      | A dictionary of field-value pairs representing the data to update in the record. |

#### Outputs

| Field       | Type    | Description                                   |
| ----------- | ------- | --------------------------------------------- |
| Record ID   | string  | The ID of the updated record.                 |
| Success     | boolean | Whether the record was updated successfully.  |
| Object Name | string  | The object name that was used for the update. |

### Get Record

Retrieve a record from any Salesforce object by ID

#### Inputs

| Field       | Type          | Required | Description                                                        |
| ----------- | ------------- | -------- | ------------------------------------------------------------------ |
| Object Name | string        | Yes      | The API name of the Salesforce object to read a record from.       |
| Record ID   | string        | Yes      | The Salesforce ID of the record to retrieve.                       |
| Fields      | string\_array | No       | Fields to return. Leave empty to return every field on the record. |

#### Outputs

| Field  | Type   | Description                        |
| ------ | ------ | ---------------------------------- |
| Record | object | The record returned by Salesforce. |

### Create Contact

Create a new contact in Salesforce

#### Inputs

| Field      | Type   | Required | Description                                  |
| ---------- | ------ | -------- | -------------------------------------------- |
| Last Name  | string | Yes      | The last name of the contact.                |
| First Name | string | No       | The first name of the contact.               |
| Email      | string | No       | The email address of the contact.            |
| Phone      | string | No       | The phone number of the contact.             |
| Account ID | string | No       | The Account ID associated with this contact. |
| Title      | string | No       | The job title of the contact.                |

#### Outputs

| Field      | Type    | Description                                   |
| ---------- | ------- | --------------------------------------------- |
| Contact ID | string  | The ID of the created contact.                |
| Success    | boolean | Whether the contact was created successfully. |

### Update Contact

Update an existing contact in Salesforce

#### Inputs

| Field      | Type   | Required | Description                                 |
| ---------- | ------ | -------- | ------------------------------------------- |
| Contact ID | string | Yes      | The Salesforce ID of the contact to update. |
| Last Name  | string | No       | The last name of the contact.               |
| First Name | string | No       | The first name of the contact.              |
| Email      | string | No       | The email address of the contact.           |
| Phone      | string | No       | The phone number of the contact.            |
| Title      | string | No       | The job title of the contact.               |

#### Outputs

| Field      | Type    | Description                                   |
| ---------- | ------- | --------------------------------------------- |
| Contact ID | string  | The ID of the updated contact.                |
| Success    | boolean | Whether the contact was updated successfully. |

### Delete Contact

Delete a contact from Salesforce

#### Inputs

| Field      | Type   | Required | Description                                 |
| ---------- | ------ | -------- | ------------------------------------------- |
| Contact ID | string | Yes      | The Salesforce ID of the contact to delete. |

#### Outputs

| Field      | Type    | Description                                   |
| ---------- | ------- | --------------------------------------------- |
| Contact ID | string  | The ID of the deleted contact.                |
| Success    | boolean | Whether the contact was deleted successfully. |

### Create Lead

Create a new lead in Salesforce

#### Inputs

| Field                  | Type            | Required | Description                                                                                                                      |
| ---------------------- | --------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Last Name              | string          | Yes      | The last name of the lead.                                                                                                       |
| Company                | string          | Yes      | The company name of the lead.                                                                                                    |
| First Name             | string          | No       | The first name of the lead.                                                                                                      |
| Email                  | string          | No       | The email address of the lead.                                                                                                   |
| Phone                  | string          | No       | The phone number of the lead.                                                                                                    |
| Title                  | string          | No       | The job title of the lead.                                                                                                       |
| Status                 | select (string) | No       | The status of the lead (values may vary by Salesforce org). Available values: New, Contacted, Nurturing, Qualified, Unqualified. |
| Description            | textarea        | No       | Additional description or notes about the lead.                                                                                  |
| Website                | string          | No       | The company website URL (must be http or https).                                                                                 |
| Has Opted Out of Email | boolean         | No       | Whether the lead has opted out of receiving emails. Default: false.                                                              |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Lead ID | string  | The ID of the created lead.                |
| Success | boolean | Whether the lead was created successfully. |

### Update Lead

Update an existing lead in Salesforce

#### Inputs

| Field                  | Type            | Required | Description                                                                                                                      |
| ---------------------- | --------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Lead ID                | string          | Yes      | The Salesforce Lead ID (15 or 18 alphanumeric characters).                                                                       |
| Last Name              | string          | No       | The last name of the lead.                                                                                                       |
| Company                | string          | No       | The company name of the lead.                                                                                                    |
| First Name             | string          | No       | The first name of the lead.                                                                                                      |
| Email                  | string          | No       | The email address of the lead.                                                                                                   |
| Phone                  | string          | No       | The phone number of the lead.                                                                                                    |
| Title                  | string          | No       | The job title of the lead.                                                                                                       |
| Status                 | select (string) | No       | The status of the lead (values may vary by Salesforce org). Available values: New, Contacted, Nurturing, Qualified, Unqualified. |
| Description            | textarea        | No       | Additional description or notes about the lead.                                                                                  |
| Website                | string          | No       | The company website URL (must be http or https).                                                                                 |
| Has Opted Out of Email | boolean         | No       | Whether the lead has opted out of receiving emails.                                                                              |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Lead ID | string  | The ID of the updated lead.                |
| Success | boolean | Whether the lead was updated successfully. |

### Delete Lead

Delete a lead from Salesforce

#### Inputs

| Field   | Type   | Required | Description             |
| ------- | ------ | -------- | ----------------------- |
| Lead ID | string | Yes      | The Salesforce Lead ID. |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Lead ID | string  | The ID of the deleted lead.                |
| Success | boolean | Whether the lead was deleted successfully. |

### Get Lead

Retrieve a lead from Salesforce by ID

#### Inputs

| Field   | Type          | Required | Description                                                        |
| ------- | ------------- | -------- | ------------------------------------------------------------------ |
| Lead ID | string        | Yes      | The Salesforce Lead ID.                                            |
| Fields  | string\_array | No       | Fields to return. Leave empty to return every field on the record. |

#### Outputs

| Field | Type   | Description                      |
| ----- | ------ | -------------------------------- |
| Lead  | object | The lead returned by Salesforce. |

### Search Leads

Search and filter Salesforce leads

#### Inputs

| Field       | Type   | Required | Description                                                 |
| ----------- | ------ | -------- | ----------------------------------------------------------- |
| Search Text | string | No       | Text to search across lead name, email, and company fields. |
| Limit       | number | No       | Maximum number of leads to return (1-50). Default: 20.      |
| Offset      | number | No       | Number of records to skip (for pagination). Default: 0.     |

#### Outputs

| Field           | Type          | Description                                            |
| --------------- | ------------- | ------------------------------------------------------ |
| Leads           | object\_array | List of leads matching the search criteria.            |
| Total Returned  | number        | Number of leads in this result set.                    |
| Total Available | number        | Total leads available for the query (from Salesforce). |
| Limit           | number        | Requested page size.                                   |
| Offset          | number        | Requested offset.                                      |
| Next Offset     | number        | Next offset if more pages exist; null otherwise.       |

### Search Accounts

Search Salesforce Accounts by name

#### Inputs

| Field       | Type    | Required | Description                                                                                 |
| ----------- | ------- | -------- | ------------------------------------------------------------------------------------------- |
| Search Text | string  | No       | Partial Account name to search for. Leave blank to list the most recently-created accounts. |
| Limit       | integer | No       | Maximum number of accounts to return (max 200).                                             |

#### Outputs

| Field      | Type          | Description                                                          |
| ---------- | ------------- | -------------------------------------------------------------------- |
| Accounts   | object\_array | Matching accounts.                                                   |
| Total Size | integer       | Total accounts matched by the query (may exceed the returned count). |

### Search Contacts

Search Salesforce Contacts by name or email

#### Inputs

| Field       | Type    | Required | Description                                                                                                                          |
| ----------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Search Text | string  | No       | Partial Contact name or email to search for. Matches against Name and Email. Leave blank to list the most recently-created contacts. |
| Limit       | integer | No       | Maximum number of contacts to return (max 200).                                                                                      |

#### Outputs

| Field      | Type          | Description                                                          |
| ---------- | ------------- | -------------------------------------------------------------------- |
| Contacts   | object\_array | Matching contacts.                                                   |
| Total Size | integer       | Total contacts matched by the query (may exceed the returned count). |

### Create Comment

Create a new comment in Salesforce (typically a Case Comment)

#### Inputs

| Field        | Type     | Required | Description                                                           |
| ------------ | -------- | -------- | --------------------------------------------------------------------- |
| Parent ID    | string   | Yes      | The ID of the parent record (e.g., Case, Opportunity, etc.).          |
| Comment Body | textarea | Yes      | The text content of the comment.                                      |
| Is Published | boolean  | No       | Whether the comment is published/visible to customers. Default: true. |

#### Outputs

| Field      | Type    | Description                                   |
| ---------- | ------- | --------------------------------------------- |
| Comment ID | string  | The ID of the created comment.                |
| Success    | boolean | Whether the comment was created successfully. |

### Update Comment

Update an existing comment in Salesforce

#### Inputs

| Field        | Type     | Required | Description                                            |
| ------------ | -------- | -------- | ------------------------------------------------------ |
| Comment ID   | string   | Yes      | The Salesforce ID of the comment to update.            |
| Comment Body | textarea | No       | The text content of the comment.                       |
| Is Published | boolean  | No       | Whether the comment is published/visible to customers. |

#### Outputs

| Field      | Type    | Description                                   |
| ---------- | ------- | --------------------------------------------- |
| Comment ID | string  | The ID of the updated comment.                |
| Success    | boolean | Whether the comment was updated successfully. |

### Delete Comment

Delete a comment from Salesforce

#### Inputs

| Field      | Type   | Required | Description                                 |
| ---------- | ------ | -------- | ------------------------------------------- |
| Comment ID | string | Yes      | The Salesforce ID of the comment to delete. |

#### Outputs

| Field      | Type    | Description                                   |
| ---------- | ------- | --------------------------------------------- |
| Comment ID | string  | The ID of the deleted comment.                |
| Success    | boolean | Whether the comment was deleted successfully. |

### Create Task

Create a new task in Salesforce

#### Inputs

| Field                               | Type            | Required | Description                                                                                                       |
| ----------------------------------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------------- |
| Subject                             | string          | Yes      | The subject/title of the task.                                                                                    |
| Status                              | select (string) | No       | The status of the task. Available values: Not Started, In Progress, Completed, Waiting on someone else, Deferred. |
| Priority                            | select (string) | No       | The priority level of the task. Available values: High, Normal, Low.                                              |
| Description                         | textarea        | No       | Additional description or notes about the task.                                                                   |
| Due Date                            | string          | No       | The due date for the task (YYYY-MM-DD format).                                                                    |
| Related To (Contact/Lead ID)        | string          | No       | The Salesforce ID of the related Contact or Lead.                                                                 |
| Related To (Account/Opportunity ID) | string          | No       | The Salesforce ID of the related Account or Opportunity.                                                          |
| Owner ID                            | string          | No       | The Salesforce User ID of the task owner.                                                                         |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Task ID | string  | The ID of the created task.                |
| Success | boolean | Whether the task was created successfully. |

### Update Task

Update an existing task in Salesforce

#### Inputs

| Field                               | Type            | Required | Description                                                                                                       |
| ----------------------------------- | --------------- | -------- | ----------------------------------------------------------------------------------------------------------------- |
| Task ID                             | string          | Yes      | The Salesforce Task ID (15 or 18 alphanumeric characters).                                                        |
| Subject                             | string          | No       | The subject/title of the task.                                                                                    |
| Status                              | select (string) | No       | The status of the task. Available values: Not Started, In Progress, Completed, Waiting on someone else, Deferred. |
| Priority                            | select (string) | No       | The priority level of the task. Available values: High, Normal, Low.                                              |
| Description                         | textarea        | No       | Additional description or notes about the task.                                                                   |
| Due Date                            | string          | No       | The due date for the task (YYYY-MM-DD format).                                                                    |
| Related To (Contact/Lead ID)        | string          | No       | The Salesforce ID of the related Contact or Lead.                                                                 |
| Related To (Account/Opportunity ID) | string          | No       | The Salesforce ID of the related Account or Opportunity.                                                          |
| Owner ID                            | string          | No       | The Salesforce User ID of the task owner.                                                                         |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Task ID | string  | The ID of the updated task.                |
| Success | boolean | Whether the task was updated successfully. |

### Delete Task

Delete a task from Salesforce

#### Inputs

| Field   | Type   | Required | Description                                                |
| ------- | ------ | -------- | ---------------------------------------------------------- |
| Task ID | string | Yes      | The Salesforce Task ID (15 or 18 alphanumeric characters). |

#### Outputs

| Field   | Type    | Description                                |
| ------- | ------- | ------------------------------------------ |
| Task ID | string  | The ID of the deleted task.                |
| Success | boolean | Whether the task was deleted successfully. |

### Get Task

Retrieve a task from Salesforce by ID

#### Inputs

| Field   | Type          | Required | Description                                                        |
| ------- | ------------- | -------- | ------------------------------------------------------------------ |
| Task ID | string        | Yes      | The Salesforce Task ID (15 or 18 alphanumeric characters).         |
| Fields  | string\_array | No       | Fields to return. Leave empty to return every field on the record. |

#### Outputs

| Field | Type   | Description                      |
| ----- | ------ | -------------------------------- |
| Task  | object | The task returned by Salesforce. |

### Search Tasks

Search and filter Salesforce tasks

#### Inputs

| Field       | Type   | Required | Description                                                                  |
| ----------- | ------ | -------- | ---------------------------------------------------------------------------- |
| Search Text | string | Yes      | Text to search for across all task fields including subject and description. |
| Limit       | number | No       | Maximum number of tasks to return. Default: 20.                              |

#### Outputs

| Field          | Type          | Description                                 |
| -------------- | ------------- | ------------------------------------------- |
| Tasks          | object\_array | List of tasks matching the search criteria. |
| Total Returned | number        | Number of tasks returned in this response.  |
| Limit          | number        | The limit used for this request.            |

### List Objects

List all available Salesforce objects for schema discovery

#### Inputs

| Field  | Type    | Required | Description                          |
| ------ | ------- | -------- | ------------------------------------ |
| Search | string  | No       | Filter objects by name or label.     |
| Limit  | integer | No       | Maximum number of objects to return. |

#### Outputs

| Field       | Type   | Description                                |
| ----------- | ------ | ------------------------------------------ |
| Objects     | string | List of Salesforce objects in JSON format. |
| Total Count | number | Total number of objects returned.          |

### Download Case Files

Download every file attached to a Salesforce Case (including files on the case's email messages) and return signed URLs.

#### Inputs

| Field                  | Type    | Required | Description                                                                                                                             |
| ---------------------- | ------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| Case Number or Case ID | string  | Yes      | A Case Number (e.g. 00001026) or the 15/18-character Case ID. Both are accepted — Case Number is resolved to the Case ID automatically. |
| Max files              | integer | No       | Maximum number of files to download (default 10, hard cap 50). Default: 10.                                                             |

#### Outputs

| Field           | Type          | Description                                                                                                                                                                                         |
| --------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Case ID         | string        | The resolved 18-character Salesforce Case Id.                                                                                                                                                       |
| File count      | number        | Number of files successfully downloaded and re-hosted.                                                                                                                                              |
| Truncated       | boolean       | True when the case has more files than max\_files allowed; raise max\_files or narrow the case scope to retrieve them all.                                                                          |
| Total available | number        | Total number of files (ContentVersion + Attachment) visible to this user for the case, before max\_files truncation.                                                                                |
| Files           | object\_array | List of files with signed file\_url, file\_name, file\_size, content\_type, source ('content\_version' or 'attachment'), salesforce\_id, parent\_id, and parent\_type ('case' or 'email\_message'). |

### Upload File

Upload a file from a URL and attach it to a Salesforce record (Case, Opportunity, Account, or any object with Files enabled).

#### Inputs

| Field            | Type     | Required | Description                                                                                                                                 |
| ---------------- | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| File URL         | string   | Yes      | Public or signed URL of the file to upload. The file is downloaded from this URL and stored in Salesforce.                                  |
| Parent Record ID | string   | Yes      | The 15/18-character Id of the record to attach the file to — a Case, Opportunity, Account, or any object with Files enabled.                |
| File name        | string   | Yes      | File name shown in Salesforce, including the extension (e.g. report.pdf). Salesforce uses the extension to classify the file type.          |
| Title            | string   | No       | Display title of the file in Salesforce. Defaults to the file name.                                                                         |
| Description      | textarea | No       | Optional description stored on the file in Salesforce.                                                                                      |
| Content type     | string   | No       | Optional MIME type of the file, used to derive a file extension when file\_name has none. Inferred from the download response when omitted. |

#### Outputs

| Field               | Type    | Description                                                |
| ------------------- | ------- | ---------------------------------------------------------- |
| Parent Record ID    | string  | Id of the record the file was attached to.                 |
| Content Document ID | string  | Id of the ContentDocument created for the file.            |
| Content Version ID  | string  | Id of the ContentVersion created for the file.             |
| File name           | string  | Final file name stored in Salesforce (extension included). |
| Success             | boolean | True when the file was uploaded and linked to the record.  |

## Triggers

A trigger starts a workflow when its configured event occurs. Configure the event and filters before enabling the trigger.

### On Field Change

Trigger when a specific field value changes in a Salesforce object

#### Configuration

| Field                                | Type            | Required | Description                                                                                                              |
| ------------------------------------ | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------ |
| Salesforce Object                    | select (string) | Yes      | The Salesforce object to monitor (e.g., Account, Contact, Lead, Opportunity). Options load from the selected connection. |
| Field to Monitor                     | select (string) | Yes      | The specific field to monitor for changes (e.g., Status, Stage, Amount). Options load from the selected connection.      |
| Additional Fields to Return          | string          | No       | Additional fields to include in the output (comma-separated, optional).                                                  |
| Filter Condition (SOQL WHERE clause) | string          | No       | Optional SOQL WHERE clause to filter records (e.g., Priority = 'High').                                                  |

#### Event inputs

| Field              | Type   | Required | Description                                     |
| ------------------ | ------ | -------- | ----------------------------------------------- |
| Record ID          | string | Yes      | The ID of the record that changed. Default: .   |
| Object Name        | string | Yes      | The Salesforce object type. Default: .          |
| Field Name         | string | Yes      | The field that changed. Default: .              |
| Old Value          | string | No       | The previous value of the field.                |
| New Value          | string | No       | The new value of the field.                     |
| Last Modified Date | string | Yes      | When the record was last modified. Default: .   |
| Record Data        | string | Yes      | Complete record data in JSON format. Default: . |

#### Outputs

| Field              | Type   | Description                          |
| ------------------ | ------ | ------------------------------------ |
| Record ID          | string | The ID of the record that changed.   |
| Object Name        | string | The Salesforce object type.          |
| Field Name         | string | The field that changed.              |
| Old Value          | string | The previous value of the field.     |
| New Value          | string | The new value of the field.          |
| Last Modified Date | string | When the record was last modified.   |
| Record Data        | string | Complete record data in JSON format. |

### On Record Created

Trigger when a new record is created in a Salesforce object

#### Configuration

| Field                                | Type            | Required | Description                                                                                                  |
| ------------------------------------ | --------------- | -------- | ------------------------------------------------------------------------------------------------------------ |
| Object                               | select (string) | Yes      | The Salesforce object to monitor (e.g., Case, Lead, Opportunity). Options load from the selected connection. |
| Fields                               | string\_array   | No       | Fields to return. Leave empty to return every field on the record.                                           |
| Filter Condition (SOQL WHERE clause) | string          | No       | Optional SOQL WHERE clause to filter records (e.g., Priority = 'High').                                      |

#### Event inputs

| Field     | Type   | Required | Description                                     |
| --------- | ------ | -------- | ----------------------------------------------- |
| Record ID | string | Yes      | The ID of the new record. Default: .            |
| Record    | dict   | Yes      | The record returned by Salesforce. Default: {}. |

#### Outputs

| Field     | Type   | Description                        |
| --------- | ------ | ---------------------------------- |
| Record ID | string | The ID of the new record.          |
| Record    | dict   | The record returned by Salesforce. |

## Important behavior

If an operation is denied, check the connection’s granted permissions and the account’s access in the provider. Reauthorize the connection when it needs additional permissions.

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/salesforce.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
