Skip to content

App APIs

Integrations

A Greenlight app can offer an API to other Greenlight apps. Once IT publishes it, it is an integration like any other: apps ask for a scope with a grant, call it through Greenlight’s proxy, and every call is checked and audited.

  • Apps never reach each other directly. The only path from one app to another is the proxy, which checks the calling app’s grant before forwarding anything.
  • IT decides what becomes a data source. Declaring an API makes it publishable. Only an administrator can publish it, and approve each app’s grant to a scope.
  • The provider app knows who is calling. Greenlight tells it the calling app, the scope that app was granted, and the signed-in person when there is one, in headers nothing outside the proxy can set.
  • The provider app decides what each scope may do. Greenlight checks that the caller holds a grant to a scope. The app’s own code decides which operations that scope allows.
  1. The provider’s agent declares the API in the app’s greenlight.yml: where it lives, its scopes, and an OpenAPI document.

    api:
    base_path: /api
    openapi: openapi.yaml
    scopes:
    - slug: read
    description: "Read approved and pending expenses (no receipts)"
    - slug: write
    description: "Create expenses and attach receipts"
  2. IT publishes it from Integrations. Administrators are alerted when an app declares an API.

  3. A consumer’s agent finds and reads it. listGrantableIntegrations lists it with kind: "app" and the app that provides it. getAppApi (CLI: greenlight integrations api) returns its scopes and OpenAPI document, so the agent can pick a scope before it asks for one.

  4. The consumer declares a grant to the scope it needs, and IT approves it.

    grants:
    - integration: expense-tracker
    credential: read
  5. The consumer calls it through the proxy with the same address and key it uses for every integration. A provider serving /api/expenses is called as ${GREENLIGHT_PROXY_URL}/expense-tracker/expenses.

Builder agents learn these rules from the app-apis Skill bundled in the Greenlight plugin. They are worth checking when IT reviews a provider app.

  • Enforce every scope in its own code. The proxy checks that the caller holds a grant to one of the app’s scopes and names it in X-Greenlight-Caller-Scope. It never maps a scope to routes. The app keeps one map of each route and the scopes allowed to call it, and answers 403 to an app-API call whose route is not in the map or whose scope the route does not allow.
  • Keep browser requests and app-API calls apart. A request from another app carries X-Greenlight-Caller-Kind. A request without it came from a person’s browser and follows the app’s ordinary sign-in rules.
  • Keep its own per-person rules. When the call carries the signed-in person, the scope says what the calling app may do, and the provider’s per-person rules still decide which records that person may see.
  • Never pass on data read as a person. Data the provider read through a user passthrough integration, live or stored, never leaves through its API, even to a call made for that same person. A consumer that needs that data asks IT for its own access to the upstream.
  • Document each operation’s scope in the OpenAPI document, and keep that document current.
More detail: the headers a provider receives
Header Value
X-Greenlight-Caller-Kind app for a calling app, user for a person’s own grant
X-Greenlight-Caller-App-Id, X-Greenlight-Caller-App-Slug The calling app (absent for user)
X-Greenlight-Caller-Scope The scope the call was granted under
X-Greenlight-Caller-Purpose runtime, or local when a developer runs the consumer on their laptop
X-User-Id, X-User-Email, X-User-Name The signed-in person, when the consumer forwarded them and they can open the provider app
X-User-Roles That person’s roles on the provider app, when the provider declares roles

Greenlight’s edge removes these headers from every request that arrives from a browser, and the proxy removes any the consumer set itself, so only the proxy can put them in front of a provider. The threat model covers what a compromised app can and cannot do with a granted app API.

  • The same contract as any proxied integration: GREENLIGHT_PROXY_URL, GREENLIGHT_DATA_KEY, and the inbound X-Greenlight-Actor-Token forwarded when serving a person.
  • 503 proxy.app_api_unavailable when the provider is paused, has no running instance, or dropped the scope. The consumer shows that feature as unavailable and keeps the rest of the app working.
  • 403 proxy.app_api_user_not_admitted when the signed-in person cannot open the provider app. A consumer never becomes a way into an app its user cannot open.
More detail: audit and local development
  • Audit. Every call writes a data-access event naming the calling app, the scope, the path and the person. It appears in both apps’ audit views.
  • Local development. A developer running the consumer on their laptop with greenlight run reaches the deployed provider, under the developer’s own identity, as with every proxied integration.