Skip to Content

SALESFORCE_APIS

Overview

salesforce_apis retrieves the available Salesforce REST APIs for a given instance and access token, returning a 2D list suitable for Excel. The first row contains headers.

Usage

To use the SALESFORCE_APIS function in Excel, enter it as a formula in a cell, specifying your Salesforce instance URL and OAuth access token:

=SALESFORCE_APIS(instance_url, token)

Parameters

ParameterTypeRequiredDescription
instance_urlstringYesSalesforce instance URL (e.g., https://MyDomainName.my.salesforce.com)
tokenstringYesSalesforce OAuth access token

Return Value

Return ValueTypeDescription
result2D list2D list with columns [Service, URL Path]. First row is headers.

Demo

If the provided credentials are invalid or missing, a message is returned in a single-cell 2D list indicating the need for valid credentials.

Limitations

  • Requires a valid Salesforce instance URL and OAuth access token.
  • Only lists REST APIs available for the provided instance.
  • Internet connection required.
  • If the access token is invalid or expired, a message is returned instead of raising an exception.

Benefits

  • Quickly discover available Salesforce REST APIs for integration or automation.
  • Returns results in a format directly usable in Excel.

Example

List Salesforce REST APIs

Sample Input:

=SALESFORCE_APIS("https://MyDomainName.my.salesforce.com", "00Dxx0000001gPFTAY!AR8AQ...")

Sample Output:

ServiceURL Path
sobjects/services/data/v63.0/sobjects
tooling/services/data/v63.0/tooling

If credentials are invalid: | You need to replace Salesforce instance_url and token with your own. |

List Salesforce REST APIs (with your own credentials)

Sample Input:

=SALESFORCE_APIS("https://orgfarm-27d44b5d7b-dev-ed.develop.my.salesforce.com", "00DgK000000cukN!AQEAQLxqWc_kgktvqZaOilY2CSRGCrVwLmLO1_vVlLKU9sAUGkijqOs5SuSRfepeag9on70FL3X57If2NLPX5DEne8fn5M2O")

Sample Output:

ServiceURL Path
sobjects/services/data/v63.0/sobjects
tooling/services/data/v63.0/tooling

If credentials are invalid: | You need to replace Salesforce instance_url and token with your own. |

How to Acquire a Salesforce Access Token

See the Salesforce REST API Quick Start

To use the SALESFORCE_APIS function, you need a valid Salesforce OAuth access token. Follow these steps to obtain one using the Salesforce CLI:

1. Prerequisites

  • Install the Salesforce CLI and ensure it is available in your PATH.
  • Have a Salesforce user account with API access.

2. Authenticate to Your Org

Open Windows PowerShell and run:

sf org login web --alias dev-instance
  • This opens a browser window for login. After login, credentials are stored under the alias dev-instance.

3. Fetch the Access Token

Run the following command to display your access token:

sf org display --target-org dev-instance --json
  • Look for the accessToken field in the output. This is your API key for use in Excel or API calls.

4. Update Your Usage

  • Copy the new access token and use it as the token parameter in the SALESFORCE_APIS function.

Source Code

import requests from requests.exceptions import HTTPError def salesforce_apis(instance_url, token): """ Get available Salesforce REST APIs and return as 2D list. Args: instance_url (str): Salesforce instance URL (e.g., https://MyDomainName.my.salesforce.com) token (str): OAuth access token Returns: list: 2D list with columns [Service, URL Path]. First row contains headers. Raises: requests.exceptions.RequestException: If the API request fails (except 401) """ # Ensure instance_url doesn't end with a slash instance_url = instance_url.rstrip('/') proxy_url = "https://cors.boardflare.com/" # Construct the endpoint URL url = f"{proxy_url}{instance_url}/services/data/v63.0/" # Set up the headers with the authorization token headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json" } try: response = requests.get(url, headers=headers) response.raise_for_status() data = response.json() result = [["Service", "URL Path"]] for service_name, url_path in data.items(): result.append([service_name, url_path]) return result except HTTPError: return "Invalid Salesforce instance_url or token. (HTTP error)" except Exception: return "An error occurred. Please check your instance_url and token."
Last updated on