Get Started with ADL API (Beta)

This guide shows you how to work with Connect REST API resources to manage Agentforce data libraries (ADL).

There are a few tools and items that we need for this quick start. The instructions focus on macOS and Linux but they should work with minimal changes on a different OS.

Salesforce CLI is a command-line interface that simplifies development and build automation when working with your Salesforce org. We use it to authenticate and get information about an org.
Install the CLI by using the Salesforce CLI Setup Guide.

We use jq for parsing JSON. To see if jq is already installed on your computer, run:
jq --version

If jq isn’t installed, run:
brew install jq

You need a PDF on your machine. The content doesn't matter. We use the PDF as a file in your first data library.

Set up an org for the quick start. For org requirements, see Setting Up Data Libraries in Salesforce Help.

To securely use Connect API endpoints for ADL, you must create an External Client App (ECA).

Create an external client app with OAuth and usage of a JWT access token enabled. Use these instructions to get set up: Create a Local External Client App

When creating the app, include these settings.

  1. Use these OAuth Scopes:

    • Access Connect REST API Resources (chatter_api)
    • Manage user data via APIs (api)
    • Manage user data via Web browsers (web)
    • Perform requests at any time (refresh_token, offline_access)

    OAuth scopes settings

  2. Select these additional OAuth settings:

    • Enable Client Credentials Flow
    • Issue JSON Web Token (JWT)-based access tokens for named users

    OAuth flow and security settings

  3. After creating the app, make sure that the API caller has the correct client credentials and that the client can issue JWT-based access tokens.

    • Click the Policies tab for the app, and then click Edit.
    • Select the Enable Client Credentials Flow checkbox.
    • Specify the client user in the Run As field.
    • Select the Issue JSON Web Token (JWT)-based access tokens checkbox. By default, this token expires in 30 minutes. You can change this value to less than 30 minutes.

To create a token, you need the consumer key and the consumer secret from your ECA.

  1. From Setup, find and select External Client Apps.
  2. Select your app and click the Settings tab.
  3. Expand the OAuth Settings section.
  4. Click the Consumer Key and Consumer Secret button, and copy your secrets. You need these values to mint this token.
  5. Important: Store your consumer secret in a secure location.
  6. From Setup, in the Quick Find box, enter My Domain, and then select My Domain.
  7. Copy the value shown in the Current My Domain URL field.
  8. Request a JWT access token from Salesforce by using a POST request, specifying the values for your consumer key, consumer secret, and domain name.

All calls to Connect API require an access token. Create a token by using the consumer key, the consumer secret, and your domain name. For more information, see the Connect REST API Developer Guide.

In a Terminal, set these environment variables after you replace {CONSUMER_KEY}, {CONSUMER_SECRET}, and {MY_DOMAIN_URL} with values from your org.

  • MY_DOMAIN_URL: Get the domain from Setup by searching for My Domain. Copy the value shown in the Current My Domain URL field.
  • CONSUMER_KEY, CONSUMER_SECRET: Get the consumer key and secret by following the instructions in Get Credentials.

Run this command block to get an access token.

If you get a JSON response (even an empty array), OAuth is working.

Copy and paste this block into your terminal. It sets up a unique library name for your session.

Update FILE_NAME to point to your test PDF.

We're using a specific library naming convention for this quick start. You can choose any naming scheme for your libraries.