Skip to content
DocsUsing apps as an agent

Concepts

Using apps as an agent

Agent playbook: written for the agent connected to your account; you can read along

Use appList to find a hosted package app, appFetch or kody app fetch to call it as your person, and appOpenLink or kody app open-link to open it in your own browser. The shared visit permission check requires app:execute on the app in its owning org and accounts for the credential you call with.

Find an app

Call appList to find apps you have Use access to in member orgs or shared from another org. In a terminal, use kody app list.

{ "owner": "acme" }

Use the returned app address (such as @acme/board) for your next call. For another page, pass next_cursor as cursor. The CLI follows all pages automatically: pass --org acme to filter or --json for one apps array. See the listing reference (raw) for limits and result fields.

Call an app

{
	"app": "@acme/board",
	"path": "/api/cards",
	"method": "POST",
	"headers": { "content-type": "application/json" },
	"body": "{\"title\":\"Ship it\"}"
}

app takes the @org/app address or the app's hosted URL. You can pass package_id instead. See the call reference (raw) for response encoding, body limits, and supported methods.

From a terminal:

kody app fetch @acme/board /api/cards --method POST \
  --header "content-type: application/json" --body @card.json
kody app fetch @acme/board /export.csv --out export.csv

Calls can have real side effects, even when marked as a synthetic smoke test (raw). Use plain HTTP routes from an interactive session; the appFetch caller check rejects package app and background job callers.

Open an app in your browser

When you need the app's pages in a real browser (to look at the UI, click through a flow, or take a screenshot), call appOpenLink and open the url it returns in your browser. Nobody has to sign in to Kody in that browser first.

{ "app": "@acme/board", "path": "/cards" }

From a terminal, kody app open-link @acme/board /cards prints only the link.

Treat the link like a password: do not paste it into chat, logs, or a pull request. Use one link per browser visit, not one per page. See the open-link reference (raw) for expiry and visit access, or When the app needs your person once if you get app_consent_required.

Keep using appFetch for programmatic calls: it returns the status, headers, and body directly and needs no browser. Never send your API token to the app's host to sign in; it is stripped.

Who the app sees

The app sees your person: the same user_id it sees when they visit in a browser. Data the app keeps per person is the same data either way.

When you act through a profile, the app also sees the profile as a label: metaGetCurrentUser() and the X-Kody-Visitor header carry profile: { id, name }, and profile is null for a visit with no profile. This is the same for appFetch and for a browser opened with appOpenLink. The visit counts for your person in the publisher's Visitors list, which names the profile that visited for them, and its run record carries the profile chain. The app's own permissions do not change: it still runs as its publisher's choice of person. A visitor-need lookup requires the visitor's live grant for that app and need.

Profiles

The app access check uses the person's access, each layer of the profile chain, and any token scopes together. appList applies the same permission when filtering results.

To give a profile an app, including one another org shared with your person, grant it from the org the profile lives in:

{
	"resource_type": "app",
	"resource_id": "<package_id from appList>",
	"subject_type": "profile",
	"subject_id": "prf_...",
	"preset": "use"
}

That is accessGrant. profileCreate and profileHandoff take the same grant in grants[]. An app grant to a profile requires the person's own access and, for a sub-profile, its parent's access. Remove the grant with accessRevoke.

A visitor-need credential still needs Use at every layer of the acting profile chain, even when the person has allowed the need.

When the app needs your person once

When appFetch reports app_consent_required (or appOpenLink does), give its consent_url to your person. An outside visitor may need to confirm Run as me, or the app may need approval for a required visitor credential. The call reports the missing approval instead of recording it. Retry after the person confirms in the browser. See the consent reference (raw) for error details.

Imports are not visits

import ... from 'kody:@org/package/export' reuses code within the caller's org; it is not an app visit. To use an app, call appFetch or open it with appOpenLink.

Pass hosted URLs as app addresses

An app's hosted URL (https://<app>--<org>.kody.run/ or a custom domain) is for a browser. A person's browser is signed in by Kody; yours is signed in by an appOpenLink link. Pass that URL as an address to appFetch, appOpenLink, or their CLI commands instead of sending your API token to the app host. Before handing the request to app code, Kody strips inbound Authorization, Proxy-Authorization, and X-Kody-* headers and forwards only cookies scoped to that app.

Working with an agent? This page is also plain markdown at /docs/agent-apps.md, or load it over MCP with search({ entity: 'guide:agent_apps' }).