> ## Documentation Index
> Fetch the complete documentation index at: https://explore.airia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Salesforce

> Create, read, update, and delete Salesforce leads, accounts, contacts, and opportunities from inside an agent workflow.

Salesforce actions let an agent work with CRM records directly in a flow. An agent can create, read, update, and delete leads, accounts, contacts, and opportunities, then pass the results to later steps.

## Supported actions

| Group           | Actions                              |
| --------------- | ------------------------------------ |
| **Lead**        | Create, Update, Get, Get All, Delete |
| **Account**     | Create, Update, Get, Get All, Delete |
| **Contact**     | Create, Update, Get, Get All, Delete |
| **Opportunity** | Create, Update, Get, Get All, Delete |

## Prerequisites

<AccordionGroup>
  <Accordion title="Create a Salesforce credential" icon="key">
    Connect Salesforce as a **Salesforce OAuth** credential in [Credential Management](/admin-hub/account_settings/credential-management), then select it on every Salesforce action. For the connection steps, see the [Salesforce OAuth setup guide](/integrations/oauth-setup/salesforce). These actions also support end user authentication, so a step can run against the credential of the person using the agent.
  </Accordion>
</AccordionGroup>

## How to use these actions

* **Map text inputs from earlier steps.** Inputs such as names, IDs, and field values accept a value mapped from a previous step. The **Limit** number takes a fixed value.
* **Filter the Get All actions with SOQL.** The **Where Clause** is the part of a SOQL query that comes after `WHERE`, entered without the keyword.
* **Choose which fields to return.** The **Fields** input is a comma separated list of fields. Leave it empty to return the default set.
* **Set fields that are not shown.** **Additional Fields JSON** accepts a JSON object for any fields not shown as their own input.

## Actions

### Lead

#### Salesforce Lead Create

Creates a new lead.

| Input                      | Required | Description                                                                          |
| -------------------------- | -------- | ------------------------------------------------------------------------------------ |
| **Last Name**              | Yes      | The lead's last name.                                                                |
| **Company**                | Yes      | The company name.                                                                    |
| **First Name**             | No       | The lead's first name.                                                               |
| **Email**                  | No       | The lead's email address.                                                            |
| **Phone**                  | No       | The lead's phone number.                                                             |
| **Title**                  | No       | The lead's job title.                                                                |
| **Lead Source**            | No       | Where the lead came from, for example `Web`, `Phone Inquiry`, or `Partner Referral`. |
| **Status**                 | No       | The lead status, for example `Open`, `Working`, or `Closed`.                         |
| **Additional Fields JSON** | No       | A JSON object of extra fields to set on the lead.                                    |

#### Salesforce Lead Update

Updates an existing lead.

| Input                      | Required | Description                                       |
| -------------------------- | -------- | ------------------------------------------------- |
| **Lead ID**                | Yes      | The unique identifier of the lead to update.      |
| **Last Name**              | No       | The lead's last name.                             |
| **Company**                | No       | The company name.                                 |
| **First Name**             | No       | The lead's first name.                            |
| **Email**                  | No       | The lead's email address.                         |
| **Phone**                  | No       | The lead's phone number.                          |
| **Title**                  | No       | The lead's job title.                             |
| **Lead Source**            | No       | Where the lead came from.                         |
| **Status**                 | No       | The lead status.                                  |
| **Additional Fields JSON** | No       | A JSON object of extra fields to set on the lead. |

#### Salesforce Lead Get

Retrieves a lead by ID.

| Input       | Required | Description                                                                  |
| ----------- | -------- | ---------------------------------------------------------------------------- |
| **Lead ID** | Yes      | The unique identifier of the lead to retrieve.                               |
| **Fields**  | No       | A comma separated list of fields to return. Leave empty for the default set. |

#### Salesforce Lead Get All

Lists leads.

| Input            | Required | Description                                                                  |
| ---------------- | -------- | ---------------------------------------------------------------------------- |
| **Where Clause** | No       | A SOQL filter, the part after `WHERE` entered without the keyword.           |
| **Fields**       | No       | A comma separated list of fields to return. Leave empty for the default set. |
| **Limit**        | No       | Maximum number of records to return. Defaults to 200.                        |

#### Salesforce Lead Delete

Deletes a lead.

| Input       | Required | Description                                  |
| ----------- | -------- | -------------------------------------------- |
| **Lead ID** | Yes      | The unique identifier of the lead to delete. |

### Account

#### Salesforce Account Create

Creates a new account.

| Input                      | Required | Description                                          |
| -------------------------- | -------- | ---------------------------------------------------- |
| **Name**                   | Yes      | The account name.                                    |
| **Industry**               | No       | The account's industry.                              |
| **Phone**                  | No       | The account's phone number.                          |
| **Website**                | No       | The account's website.                               |
| **Description**            | No       | A description of the account.                        |
| **Additional Fields JSON** | No       | A JSON object of extra fields to set on the account. |

#### Salesforce Account Update

Updates an existing account.

| Input                      | Required | Description                                          |
| -------------------------- | -------- | ---------------------------------------------------- |
| **Account ID**             | Yes      | The unique identifier of the account to update.      |
| **Name**                   | No       | The account name.                                    |
| **Industry**               | No       | The account's industry.                              |
| **Phone**                  | No       | The account's phone number.                          |
| **Website**                | No       | The account's website.                               |
| **Description**            | No       | A description of the account.                        |
| **Additional Fields JSON** | No       | A JSON object of extra fields to set on the account. |

#### Salesforce Account Get

Retrieves an account by ID.

| Input          | Required | Description                                                                  |
| -------------- | -------- | ---------------------------------------------------------------------------- |
| **Account ID** | Yes      | The unique identifier of the account to retrieve.                            |
| **Fields**     | No       | A comma separated list of fields to return. Leave empty for the default set. |

#### Salesforce Account Get All

Lists accounts.

| Input            | Required | Description                                                                  |
| ---------------- | -------- | ---------------------------------------------------------------------------- |
| **Where Clause** | No       | A SOQL filter, the part after `WHERE` entered without the keyword.           |
| **Fields**       | No       | A comma separated list of fields to return. Leave empty for the default set. |
| **Limit**        | No       | Maximum number of records to return. Defaults to 200.                        |

#### Salesforce Account Delete

Deletes an account.

| Input          | Required | Description                                     |
| -------------- | -------- | ----------------------------------------------- |
| **Account ID** | Yes      | The unique identifier of the account to delete. |

### Contact

#### Salesforce Contact Create

Creates a new contact.

| Input                      | Required | Description                                          |
| -------------------------- | -------- | ---------------------------------------------------- |
| **Last Name**              | Yes      | The contact's last name.                             |
| **First Name**             | No       | The contact's first name.                            |
| **Email**                  | No       | The contact's email address.                         |
| **Phone**                  | No       | The contact's phone number.                          |
| **Account ID**             | No       | The associated account.                              |
| **Title**                  | No       | The contact's job title.                             |
| **Additional Fields JSON** | No       | A JSON object of extra fields to set on the contact. |

#### Salesforce Contact Update

Updates an existing contact.

| Input                      | Required | Description                                          |
| -------------------------- | -------- | ---------------------------------------------------- |
| **Contact ID**             | Yes      | The unique identifier of the contact to update.      |
| **Last Name**              | No       | The contact's last name.                             |
| **First Name**             | No       | The contact's first name.                            |
| **Email**                  | No       | The contact's email address.                         |
| **Phone**                  | No       | The contact's phone number.                          |
| **Account ID**             | No       | The associated account.                              |
| **Title**                  | No       | The contact's job title.                             |
| **Additional Fields JSON** | No       | A JSON object of extra fields to set on the contact. |

#### Salesforce Contact Get

Retrieves a contact by ID.

| Input          | Required | Description                                                                  |
| -------------- | -------- | ---------------------------------------------------------------------------- |
| **Contact ID** | Yes      | The unique identifier of the contact to retrieve.                            |
| **Fields**     | No       | A comma separated list of fields to return. Leave empty for the default set. |

#### Salesforce Contact Get All

Lists contacts.

| Input            | Required | Description                                                                  |
| ---------------- | -------- | ---------------------------------------------------------------------------- |
| **Where Clause** | No       | A SOQL filter, the part after `WHERE` entered without the keyword.           |
| **Fields**       | No       | A comma separated list of fields to return. Leave empty for the default set. |
| **Limit**        | No       | Maximum number of records to return. Defaults to 200.                        |

#### Salesforce Contact Delete

Deletes a contact.

| Input          | Required | Description                                     |
| -------------- | -------- | ----------------------------------------------- |
| **Contact ID** | Yes      | The unique identifier of the contact to delete. |

### Opportunity

#### Salesforce Opportunity Create

Creates a new opportunity.

| Input                      | Required | Description                                                                   |
| -------------------------- | -------- | ----------------------------------------------------------------------------- |
| **Name**                   | Yes      | The opportunity name.                                                         |
| **Stage Name**             | Yes      | The sales stage, for example `Prospecting`, `Qualification`, or `Closed Won`. |
| **Close Date**             | Yes      | The expected close date in `YYYY-MM-DD` format.                               |
| **Account ID**             | No       | The associated account.                                                       |
| **Amount**                 | No       | The monetary amount, entered as a fixed number.                               |
| **Probability**            | No       | The win probability from 0 to 100, entered as a fixed number.                 |
| **Description**            | No       | A description of the opportunity.                                             |
| **Additional Fields JSON** | No       | A JSON object of extra fields to set on the opportunity.                      |

#### Salesforce Opportunity Update

Updates an existing opportunity.

| Input                      | Required | Description                                              |
| -------------------------- | -------- | -------------------------------------------------------- |
| **Opportunity ID**         | Yes      | The unique identifier of the opportunity to update.      |
| **Name**                   | No       | The opportunity name.                                    |
| **Stage Name**             | No       | The sales stage.                                         |
| **Close Date**             | No       | The expected close date in `YYYY-MM-DD` format.          |
| **Account ID**             | No       | The associated account.                                  |
| **Amount**                 | No       | The monetary amount, entered as a fixed number.          |
| **Probability**            | No       | The win probability, entered as a fixed number.          |
| **Description**            | No       | A description of the opportunity.                        |
| **Additional Fields JSON** | No       | A JSON object of extra fields to set on the opportunity. |

#### Salesforce Opportunity Get

Retrieves an opportunity by ID.

| Input              | Required | Description                                                                  |
| ------------------ | -------- | ---------------------------------------------------------------------------- |
| **Opportunity ID** | Yes      | The unique identifier of the opportunity to retrieve.                        |
| **Fields**         | No       | A comma separated list of fields to return. Leave empty for the default set. |

#### Salesforce Opportunity Get All

Lists opportunities.

| Input            | Required | Description                                                                  |
| ---------------- | -------- | ---------------------------------------------------------------------------- |
| **Where Clause** | No       | A SOQL filter, the part after `WHERE` entered without the keyword.           |
| **Fields**       | No       | A comma separated list of fields to return. Leave empty for the default set. |
| **Limit**        | No       | Maximum number of records to return. Defaults to 200.                        |

#### Salesforce Opportunity Delete

Deletes an opportunity.

| Input              | Required | Description                                         |
| ------------------ | -------- | --------------------------------------------------- |
| **Opportunity ID** | Yes      | The unique identifier of the opportunity to delete. |

## Example

An agent that turns an inbound inquiry into a tracked deal:

<Steps>
  <Step title="Find the account">
    A **Salesforce Account Get All** action filters with a **Where Clause** such as `Name = 'Acme Corp'` so a model step can confirm whether the company already exists.
  </Step>

  <Step title="Create the contact">
    A **Salesforce Contact Create** action sets **Last Name** and **Email** from the inquiry and maps **Account ID** to the account from the previous step.
  </Step>

  <Step title="Open the opportunity">
    A **Salesforce Opportunity Create** action sets **Name**, **Stage Name** to `Prospecting`, and **Close Date**, mapping **Account ID** to the same account.
  </Step>

  <Step title="Confirm">
    A model step summarizes the created records, including their returned IDs, for the activity log.
  </Step>
</Steps>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Required field missing" icon="triangle-exclamation">
    Salesforce rejects records that lack a required field. A lead needs **Last Name** and **Company**, and an opportunity needs **Name**, **Stage Name**, and **Close Date**.
  </Accordion>

  <Accordion title="Invalid Where Clause" icon="circle-question">
    The **Where Clause** must be valid SOQL with the `WHERE` keyword removed. Quote string values with single quotes, for example `Status = 'Open'`.
  </Accordion>

  <Accordion title="Insufficient access rights on object" icon="lock">
    The connected user does not have permission for the object or record. Confirm the user's profile grants access to the leads, accounts, contacts, or opportunities you are calling.
  </Accordion>

  <Accordion title="Authentication or token expired" icon="key">
    Reconnect the Salesforce OAuth credential. If a step uses end user authentication, the person running the agent may need to authorize Salesforce again.
  </Accordion>
</AccordionGroup>

For issues common to every vendor, see the [Actions overview](/building-and-deploying-agents/agent-basics/actions/overview#troubleshooting).
