# Salesforce

> Connect Salesforce to FlyMyAI agents - SOQL, CRUD, upsert and describe across all objects via OAuth.

Connects [Salesforce](https://www.salesforce.com) to FlyMyAI agents via OAuth.
Connect your Salesforce org once and the agent can query and modify any standard
or custom object through the Salesforce REST API - no token to paste.

## What it can do

- Run **SOQL** queries (and page through large result sets)
- Run **SOSL** searches across multiple objects
- **Create, read, update, delete** records of any sObject (Account, Contact, Lead, Opportunity, custom `*__c`)
- **Upsert** by external Id
- **Describe** an object (fields, picklists, relationships) and list all objects
- Read org **limits** and run **composite** multi-step requests

Access is generic over the REST API, so every object and field the connected user
can see is reachable - including custom objects.

> The agent acts as the connected Salesforce user and is bound by that user's
> profile and permissions. Confirm before bulk deletes or mass updates.

## How to get credentials

Salesforce uses OAuth - there's no token to copy.

1. In FlyMyAI, open the Salesforce MCP and start the setup flow.
2. A Salesforce login + consent screen opens. Sign in with the org/user the agent
   should act as and approve access.
3. You're redirected back to FlyMyAI; the tool flips to **Configured**.

Requirements:

- A Salesforce edition with **API access** (Enterprise, Unlimited, Developer or
  Performance; some Professional orgs need API access enabled).
- Your Salesforce admin must approve the FlyMyAI connected app and allow any
  IP/login ranges it uses.

To revoke access later, in Salesforce open **Setup -> Connected Apps -> OAuth
Connected Apps** (or your personal **Connections**) and remove FlyMyAI.

## Fields to fill in FlyMyAI

No fields - the OAuth flow stores the access token, refresh token and your org's
instance URL automatically. To switch orgs, remove the tool and reconnect.

## Troubleshooting

- **`INVALID_LOGIN` / OAuth denied** - the user lacks the API Enabled permission,
  or the org blocks the connected app. Ask your Salesforce admin to enable API
  access and approve FlyMyAI.
- **`401` after a while** - the session expired; FlyMyAI refreshes automatically,
  but if the refresh token was revoked (password reset, admin unlinked the app),
  reconnect.
- **`INVALID_FIELD` / `MALFORMED_QUERY`** - a field or object name in your SOQL is
  wrong; use **describe** to get the exact API names.
- **Sandbox org** - sandboxes log in via `test.salesforce.com`; ask the FlyMyAI
  team to point your tool at the sandbox login host.

## Links

- [Salesforce](https://www.salesforce.com)
- [Salesforce REST API Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/)
- [OAuth 2.0 Web Server Flow](https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_web_server_flow.htm)
