All articles

Agentforce

Heroku AppLink: running your own code as an Agentforce action

Your agent needs to run a Python model, render a PDF, or crunch a dataset bigger than a batch job allows. Apex can't, and External Services only forwards to an API you already have. Heroku AppLink is the action type that hosts and runs your code, in any language, and hands the agent back a governed action.

The agent needs to do real work. Score a record with a Python model. Render a branded PDF and hand it back. Reprice ten thousand lines of a quote with a library that does not exist in Apex. None of that fits in a governor-limited transaction, and none of it is a call to an API you already run.

Every other way to give an agent an action assumes the code lives somewhere else and you are just reaching it. Apex custom actions run in-org under governor limits. External Services forwards to a REST API that already exists. MuleSoft governs APIs your integration team already owns.

Heroku AppLink is the one that is different. It hosts and runs your code, in whatever language you wrote it, and publishes it into Salesforce as an action the agent calls under the same permissions and trust controls as any other.

My rule: reach for AppLink when the action needs to run code, not reach an endpoint. Heavy compute, a language or library Salesforce does not offer, work that runs longer or over more data than the platform allows.

For a plain in-and-out call to a REST service, it is the wrong tool and External Services is less setup. The whole value of AppLink is that the code is yours and it runs on your dynos.

Agentforce can reach outside the org several ways, and they split on a single question of whether you need to run code or only reach code that already runs.

  • Apex when the logic belongs in-org, close to the data, inside a transaction, and fits the governor limits.
  • External Services when a REST API already exists, publishes an OpenAPI spec, and a Named Credential can log in. The least setup of any option for a thin pass-through.
  • MuleSoft when the API is one of many your team curates and reuses across agents.
  • MCP when a tool provider ships a Model Context Protocol server and you want the agent to discover its tools. Heroku can host a custom MCP server too, which blurs the line, though the action-type decision is the same.
  • Heroku AppLink when the work is your own code: a Python or Node service doing something Apex cannot, at a scale or for a duration the platform will not allow.

AppLink, External Services, MuleSoft, and Apex REST all converge on the same mechanism inside Salesforce: an OpenAPI spec becomes auto-generated Apex and a registered action. What separates AppLink is that it also runs the code behind the spec. The others register a door to code hosted elsewhere; AppLink builds the room and the door together.

Heroku AppLink went generally available on July 14, 2025 (it was called Heroku Integration during the beta). It works with Salesforce editions that have API access, and the add-on itself is free: you pay for the Heroku compute and data resources the app uses, billed the normal Heroku way.

The build: spec in, action out

The setup is a short run of CLI commands that ends with a published action. The commands below are the documented flow; run them against the Heroku Dev Center for your release, since the AppLink CLI has moved fast.

Install the plugin, create the app, add the service-mesh buildpack (a proxy that authenticates and authorizes the requests Salesforce sends), and provision the add-on:

heroku plugins:install @heroku-cli/plugin-applink
heroku create
heroku buildpacks:add heroku/heroku-applink-service-mesh
heroku addons:create heroku-applink

The add-on sets two config vars on the app, HEROKU_APPLINK_API_URL and HEROKU_APPLINK_TOKEN, which the AppLink SDK reads. The SDK ships for Node and Python; it hydrates the invocation event and a context object carrying the invoking org and user, so your handler knows who called it and can call back into Salesforce.

Then connect an org and publish your OpenAPI spec against that connection:

heroku salesforce:connect
heroku salesforce:publish api-spec.yaml \
  --client-name QuoteRepricer \
  --connection-name agent-org \
  --authorization-permission-set-name QuoteRepricer

Publishing is the step that generates everything on the Salesforce side. From the spec it creates invocable Apex classes that wrap your operations, an External Service registration with an API Catalog entry, and a Named Credential and External Credential for the endpoint and its auth. It also creates the Agent Actions themselves, a permission set built from Heroku’s template, and the OAuth client the app authenticates through.

The --client-name drives the default naming, so a clean, specific name here pays off across all of those artifacts.

The spec is where you declare what becomes an agent action. An operation becomes one when you annotate it with x-sfdc/agent/action/publishAsAgentAction: true. A topic declared in the spec carries four fields: a classification description, a scope, instructions, and a name.

One documented rule catches people: if you declare a topic, you must define at least one action under it. The exact annotation layout has shifted between doc versions, so validate yours against a known-good published spec rather than hand-copying nesting from memory.

The last step is in Salesforce, not Heroku. In Setup, open Agentforce Assets, the Actions tab, and create a new agent action of type API, category Heroku, pointing at the published API. Assign the generated permission set to the users and the agent, add the action to a topic from the Asset Library, and activate.

From there it behaves like any other action, and the instruction you write on it decides whether the agent ever calls it correctly, the same discipline every action type demands.

Which user the action runs as

An AppLink action does not run as “the app.” It runs under one of three user modes, and getting this wrong is how an action either sees nothing or sees too much.

  • user (the default) applies the invoking Salesforce user’s own permissions to any Salesforce work the app does. A rep triggering the action touches only what that rep can see.
  • user-plus adds a session-based permission set on top of the invoking user, a temporary, auditable elevation defined at publish time. It needs an OAuth client in the spec so a user token can be minted.
  • authorized-user runs as a specific stored identity, the pattern for a worker dyno or a nightly job that has no interactive user.

One rule is worth memorising. A call that originates in Salesforce and stays there can use any mode. The moment your Heroku app calls back into Salesforce on its own, that callback runs in authorized-user mode. Salesforce APIs always act in an authenticated user’s context, so there has to be a stored identity behind it.

On the Salesforce side, the person wiring this up needs the Manage Heroku AppLink permission to create the connections and authorizations, and the agent needs the generated permission set. The running-user model here is the same one that bites every agent action, covered in which user your agent runs as.

The thirty-second wall

The hard limit that shapes every AppLink action is the Heroku router timeout: 30 seconds, not configurable. If a synchronous request takes longer, the router cuts it, and no Apex setting saves you. Salesforce lets you set an Apex callout timeout as high as 120 seconds, the same ceiling External Services runs under, but against an AppLink app that 120 is moot. The router wins at 30.

That matters because the reason you reached for AppLink, heavy work, is exactly the work that runs long. The answer is the async pattern.

For anything that will not finish well under 30 seconds, the action starts a background job on a worker dyno and returns a handle immediately. The result comes back later, written to a record or pushed through a platform event the agent or a flow is waiting on.

Design the action as “kick off the work and acknowledge,” not “do the work and block,” the moment the work is anything but fast. The payload it returns to the agent should be a few fields it can read into the conversation, not a five-thousand-row dump that burns the token budget.

Connected apps are going away here too

If you are standing this up now, do not reach for a connected app. Since Spring ‘26, Salesforce disabled creating new connected apps by default, and Heroku deprecated connected-app support in AppLink in favour of External Client Apps as of April 30, 2026.

salesforce:publish takes a flag that points the published app at an External Client App instead. Check heroku help salesforce for the exact flag name in your CLI version, because it has been spelled more than one way across releases.

For a new integration, the External Client App is the client type to use, and the broader move off connected apps, with its staggered OAuth deadlines, is its own project covered in migrating off Connected Apps. The practical read for AppLink: a brand-new app should publish against an ECA from the start, so you are not migrating it six months later.

Where I would start

Before provisioning anything, decide whether this is really an AppLink job. Write down what the action does. If the sentence is “call this vendor’s REST API and return the result,” stop and use External Services. If it is “process this document,” “run this model,” “do math Apex cannot,” or “chew through more records than a batch job allows,” AppLink earns its setup.

Then build the smallest thing that runs: one operation, published, added to a topic, called once from the agent. Confirm the user mode does what you expect before you add a second action, because the identity behaves differently per mode and you want to see it on something simple. And design for the 30-second wall from the first commit, not after the router cuts your first long call.

One strategic note to weigh, not to panic over. Salesforce Ben has reported that Salesforce stopped selling Heroku Enterprise to new customers, while existing customers see no change. If you are choosing a compute home for agent actions your business will depend on for years, raise that with your account team rather than reading a blog’s tea leaves, this one included. The technology is sound and shipping; the commercial direction is a question worth asking out loud.

Understanding the basics

Heroku AppLink is a Heroku add-on that exposes an app running on Heroku as an API service inside Salesforce, so its code can be invoked from Flow, Apex, Data Cloud, and Agentforce. You publish the app’s OpenAPI spec, and AppLink generates the Salesforce artifacts (invocable Apex, an External Service registration, a Named Credential, agent actions, and a permission set). It went generally available on July 14, 2025, and was called Heroku Integration during the beta.

Use External Services when a REST API already exists and you only need to call it: that path is a thin, declarative pass-through with the least setup. Use Heroku AppLink when the action has to run your own code, in a language or with a library Salesforce does not offer, or at a compute scale or duration that would blow Apex governor limits. AppLink hosts and runs the code; External Services only registers a door to code hosted elsewhere.

A synchronous call is bounded by the Heroku router’s 30-second timeout, which is not configurable. Even though Salesforce allows an Apex callout timeout up to 120 seconds, the router cuts a longer AppLink request first. For work that runs longer, use the async pattern: the action starts a background job on a worker dyno, returns immediately, and the result is written back to a record or delivered through a platform event.

New integrations should use External Client Apps. Salesforce disabled creating new connected apps by default in Spring ‘26, and Heroku deprecated connected-app support in AppLink in favour of External Client Apps as of April 30, 2026. The salesforce:publish command takes a flag to point the published app at an External Client App; confirm the exact flag name with heroku help salesforce, since it has changed across CLI versions.


Deciding whether an agent’s next action is a Heroku app, an Apex class, an External Service, or a MuleSoft API, and wiring the user mode, the credential, and the async pattern so it holds up in production? Talk to us. Getting an agent to do real work outside the governor limits, without a pile of plumbing you maintain forever, is exactly the work we do.

Keep reading

All articles