sshvarzman-salesforce/claude-skills

sf-agent-api-setup

Agent API onboarding — External Client App (ECA), OAuth client credentials flow, token minting, and agent ID retrieval.

View source

How to use

  1. Copy the installation command and review the source package before installing it in your own agent environment.
  2. Check the source document for required tools, credentials and supported hosts.
  3. Describe your input and desired deliverable; review the output against the source material.
npx skills add https://github.com/sshvarzman-salesforce/claude-skills --skill sf-agent-api-setup

Before you start

  • Installation does not include a model subscription, API allowance or permission to access your files.
  • Repository stars and installation counts describe activity, not an independent quality or security test.
Original skill document

Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.

Agent API Setup and Authentication

Use This Skill When

  • Standing up access to the Agentforce Agent API (einstein/ai-agent/v1) for the first time.
  • Creating the External Client App (ECA) and choosing OAuth scopes and flow settings.
  • Minting a bearer token via the client credentials flow.
  • Resolving the correct base endpoint (api.salesforce.com vs api.gov.salesforce.com) and My Domain URL.
  • Finding the agent ID from the Legacy or new Agentforce Builder.

Prerequisites

  • Agentforce enabled with at least one activated agent.
  • Agent API is not supported for agents of type "Agentforce (Default)".
  • A Run As user with at least API Only access for the client credentials flow.

Quick Start (Setup Path)

Follow these steps in order. For screen-by-screen ECA settings and the full token/response reference, see reference.md.

1. Create the External Client App

Setup → External Client Apps Manager → New External Client App. Set name + contact email, enable OAuth, and add these scopes:

  • api — Manage user data via APIs
  • refresh_token, offline_access — Perform requests at any time
  • chatbot_api — Access chatbot services
  • sfap_api — Access the Salesforce API Platform

Enable Client Credentials Flow and Issue JWT-based access tokens for named users. Deselect the three "Require secret / Require PKCE" options. Then on the Policy tab, enable Client Credentials Flow and set Run As to an API-only user.

2. Get the consumer key and secret

App Settings tab → OAuth Settings → Consumer Key and Secret. Copy both. Never commit these.

3. Mint a token (client credentials)

bash
curl https://{MY_DOMAIN_URL}/services/oauth2/token \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id={CONSUMER_KEY}' \
--data-urlencode 'client_secret={CONSUMER_SECRET}'

Copy access_token from the JSON response. This bearer token is required on every Agent API call.

4. Get the agent ID

  • Legacy Agentforce Builder: open the Agent Overview page in Setup; copy the 18-character ID at the end of the URL (for example 0XxSB000000IPCr0AO).
  • New Agentforce Builder: the bot ID is the agent ID. Query BotDefinition:
sql
SELECT Id, DeveloperName FROM BotDefinition WHERE DeveloperName = 'Agentforce_Service_Agent'

Or via CLI: sf data query --query "SELECT Id, DeveloperName, AgentType FROM BotDefinition"

5. Make your first call

bash
curl --location -X POST https://api.salesforce.com/einstein/ai-agent/v1/agents/{AGENT_ID}/sessions \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {ACCESS_TOKEN}' \
--data '{
  "externalSessionKey": "{RANDOM_UUID}",
  "instanceConfig": { "endpoint": "https://{MY_DOMAIN_URL}" },
  "streamingCapabilities": { "chunkTypes": ["Text"] },
  "bypassUser": true
}'

Endpoint Reference

PurposeBase URL
Standardhttps://api.salesforce.com/einstein/ai-agent/v1
Government Cloudhttps://api.gov.salesforce.com/einstein/ai-agent/v1

instanceConfig.endpoint must be your My Domain URL (https://xxx.my.salesforce.com), not the Lightning URL (*.lightning.force.com).

Guardrails

  • Store the consumer secret and access token server-side only; never ship them to a browser or commit them to source control.
  • Use the My Domain URL for instanceConfig.endpoint — using the Lightning URL causes EngineConfigLookupException (HTTP 500).
  • bypassUser: true runs as the agent-assigned user; false runs as the token user. Pick deliberately based on data-access requirements.
  • Government Cloud orgs must use api.gov.salesforce.com everywhere — the standard host returns 404.
  • Tokens are short-lived; build refresh into the client rather than pasting a static token.

Deliverables

  • Configured ECA with the four required scopes and client credentials flow enabled.
  • A documented token-minting command/secret-storage plan.
  • The resolved agent ID and My Domain URL captured for the target org.
  • A verified first Start Session response.

Additional Resources

Related by task

from this repository

More skills

All skills
sshvarzman-salesforce
Community

activating-datacloud

Salesforce Data Cloud Act phase. Use this skill when the user manages activations, activation targets, data actions, or downstream delivery of Data Cloud audiences and data. TRIGGER when: user manages activations, activation targets, data actions, or downstream delivery of Data Cloud audiences and data. DO NOT TRIGGER when: the task is segment creation (use segmenting-datacloud), data retrieval/search work (use retrieving-datacloud), or STDM/session tracing (use observing-agentforce).

installs
1
GitHub stars
0
Updated
Oct 15
sshvarzman-salesforce
Community

agentforce-skills-research

Research Agentforce configuration patterns — topics, actions, instructions, CLTs, knowledge, planner behavior. Searches Salesforce docs, Trailhead, internal repos (git.soma), Slack channels, and Google Docs to find working examples, known issues, and best practices.

installs
1
GitHub stars
0
Updated
Oct 15
sshvarzman-salesforce
Community

harmonizing-datacloud

Salesforce Data Cloud Harmonize phase. Use this skill when the user works with DMOs, mappings, relationships, identity resolution, unified profiles, data graphs, or universal IDs. TRIGGER when: user works with DMOs, mappings, relationships, identity resolution, unified profiles, data graphs, or universal IDs. DO NOT TRIGGER when: the task is only about streams/DLOs (use preparing-datacloud), segments/insights (use segmenting-datacloud), retrieval/search (use retrieving-datacloud), or STDM/sessio

installs
1
GitHub stars
0
Updated
Oct 15
sshvarzman-salesforce
Community

preparing-datacloud

Salesforce Data Cloud Prepare phase. Use this skill when the user creates or manages Data Cloud data streams, DLOs, transforms, or Document AI configurations. TRIGGER when: user creates or manages Data Cloud data streams, DLOs, transforms, or Document AI configurations, or asks about ingestion into Data Cloud. DO NOT TRIGGER when: the task is connection setup only (use connecting-datacloud), DMOs and identity resolution (use harmonizing-datacloud), or query/search work (use retrieving-datacloud)

installs
1
GitHub stars
0
Updated
Oct 15