spotlight_integration

The spotlight_integration resource, and the integration resource of the API: a team's definition of an outside service, with the webhooks it sends, the happenings they raise, the tools agents may call on it, and how Spotlight connects to it. Its body is a definition object, sent as the definition of spotlight_integration in Terraform or as the JSON body of the resource API.

KindEndpointTerraformAddress
integration/api/v1/resources/teams/{teamId}/integrationsspotlight_integration<team key>/<integration>

See Resource API for the operations, headers and errors every kind shares, and Expressions for how the expressions inside a definition are written and the variables each can read.

Example

resource "spotlight_integration" "core_acme" {
  team_id = spotlight_team.core.id
  definition = {
    integration = "acme"
    name        = "Acme"
    webhook = {
      verify = {
        hmac = { secret = "secret.ACME_SIGNING", header = "acme-signature" }
      }
      events = [{
        when = "$${{ body.type == \"issue\" && body.action == \"updated\" }}"
        raise = {
          happening = "acme.issue.updated"
          marks     = [{ kind = "acme.issue", value = "$${{ body.issue.id }}" }]
        }
      }]
    }
    actions = {
      comment = {
        request = {
          method = "POST"
          url    = "https://api.acme.example/comments"
          body   = { issue = "$${{ inputs.issue }}", text = "$${{ inputs.body }}" }
          auth   = { secrets = ["secret.ACME_API_KEY"] }
        }
      }
    }
    tools = {
      comment = {
        action      = "comment"
        description = "Comment on an Acme issue."
        inputs = {
          issue = { type = "string", required = true }
          body  = { type = "string", required = true }
        }
      }
    }
  }
}

Acme is an example name for any HTTP service. A station enables this tool as acme.comment.

Top level

FieldTypeDefaultDescription
integrationstringrequiredThe name of the integration, as in slack. Prefixes its tools, happenings and webhook address. Immutable: an update that changes it is rejected; Terraform replaces the resource.
namestringnoneThe name shown in the web app. Without it, the integration value.
logostringnoneThe mark shown in the web app beside the name. A base64 data URI of an SVG, PNG, WebP or JPEG image, as in data:image/svg+xml;base64,PHN2Zy..., or an https address. At most 65,536 characters. The web app shows it as an image, so a script in an SVG does not run. Without it, a generic mark.
typesmap of name to object{}Named shapes that expressions are type-checked against.
connectionobjectnoneHow the team connects to the service. See connection.
webhookobjectnoneDeliveries the service sends. See webhook.
pollobjectnoneA request Spotlight repeats. See poll.
scheduleobjectnoneAn action Spotlight runs on a cron schedule. See schedule.
actionsmap of name to object{}Requests to the service. See actions.
toolsmap of name to object{}Actions offered to agents and hooks. See tools.
openapiobjectnoneAn OpenAPI spec to generate tools from. See API specs.
graphqlobjectnoneA GraphQL API to generate tools from. See API specs.
mcpobjectnoneA remote MCP server whose tools Spotlight lists and calls. See MCP servers.
onmap of name to object{}Actions run when a task event happens. See on.

A definition must do something: it has a webhook, a poll, a schedule, at least one action, at least one on binding, an openapi, a graphql or an mcp. Otherwise it is rejected with must do something: a webhook, a poll, a schedule, an action to run, or an API spec or MCP server to provide tools from. A definition with two of openapi, graphql and mcp is rejected with offers tools from one API spec: an openapi, a graphql or an mcp, not two.

A read adds three fields that cannot be set:

FieldTypeDescription
integrationstringEqual to the definition's integration.
toolsmap of name to stringEach tool the integration offers, written or generated, by its name in the integration, to the name stations and hooks use, as in { "comment": "acme.comment" }.
specobject or nullThe API spec or MCP server as Spotlight last read it. null when the definition names none. See Spec.

In Terraform, tools is known only after apply when the definition has an openapi, a graphql or an mcp. A station that names a generated tool through it that is not there fails the apply, not the plan.

Names

NamePatternExample
integrationlowercase letters and digits, one word; not catalogacme
action, toollowercase words joined by dashespost-message
tool inputa letter or _, then letters, digits, _ and -, at most 64 characters; not jsonissue, team_id
happeningthe integration's own name, a dot, then dotted words of lowercase letters, digits, _ and -acme.issue.updated
mark kindan integration name, a dot, then dotted words as for a happeningacme.issue
secret referencesecret. and a secret name of capitals, digits and _, starting with a capital, at most 64 characterssecret.ACME_API_KEY
type namestarts with a capital, then letters and digitsIssue

A happening that does not begin with the integration's name is rejected. One integration may not raise the same happening twice, offer the same tool twice, or bind the same task event twice.

An integration named github receives no webhook deliveries at its team address: every delivery there returns 401. The name github belongs to the built-in GitHub integration.

Shapes

A shape is a map from field name to a type, written as text such as string, list<Issue> or a type name from types, or to a nested shape. Shapes appear in types, webhook.shape, poll.shape and a request's response. They are used only to type-check expressions. A shape that cannot be read, or types that name themselves in a cycle, produce a warning and are then ignored.

Connection

FieldTypeDefaultDescription
actsAsstringteamteam or requester. Whose connection the integration's tools act with. See Acts as.
oauth2.discoverbooleanfalseFind the endpoints, the registration endpoint and the scopes from what the MCP server named in mcp.url publishes. See Discovery.
oauth2.authorizestringrequired unless discoverThe service's authorization endpoint.
oauth2.tokenstringrequired unless discoverThe service's token endpoint.
oauth2.scopesarray of strings[]Scopes requested, joined by scopeSeparator.
oauth2.scopeSeparatorstring" "" " or ",". What joins scopes in the authorization URL's scope parameter. Slack takes ",".
oauth2.pkcebooleantrueWhether the connection uses PKCE (RFC 7636). With false, the authorization URL has no code_challenge and the code exchange sends no code_verifier. Only a client with a secret may turn it off: client.secret, or a deployment's OAUTH_CLIENTS entry.
oauth2.identitystringnoneAn expression. Names the linked account, shown under "Team account" or "Your account" in the web app. Can read response, the token endpoint's response.
oauth2.hostsarray of strings[]Host names, as in files.slack.com. More hosts that get the access token, beside the hosts the definition writes out. See Token hosts.
oauth2.client.idstringnoneThe client ID that the service gave the team's own OAuth app. See OAuth client.
oauth2.client.secretstringnoneA secret reference, secret.<NAME>. The workspace secret that holds the client secret of the team's own OAuth app. Without it, token requests send no client_secret. Bind the secret to the host of token: Spotlight sends it only to a token endpoint it is bound to.
oauth2.registrationstringnoneA URL. The service's dynamic client registration endpoint (RFC 7591). Used when the definition has no client and the deployment has no OAuth client for the integration. See Client registration.
oauth2.resourcestringnoneA URL. Sent as the resource parameter (RFC 8707) on the authorization URL and on every token request.
manual.secretsarray of strings[]Secrets the connection uses, each a secret reference, secret.<NAME>.

Without discover, oauth2 must name both authorize and token. With discover = true it takes only scopes, identity, resource and hosts; naming authorize, token, registration, client, scopeSeparator or pkce beside it is rejected as an unrecognized key. A discovered server always gets scopes joined by spaces, and PKCE. discover without an mcp block is rejected at connection.oauth2 with discovers how to connect from its MCP server, but mcp.url names no MCP server. client with registration is rejected at connection.oauth2.client with names its own client, so it registers none: remove registration or client. pkce = false with a client that has no secret, or with registration, is rejected at connection.oauth2.pkce with is false, which only a client with a secret may use: give client.secret, or remove pkce: false. Any other key beside authorize and token is rejected as an unrecognized key. An empty client.id is rejected with is the client ID the provider gave. An entry of hosts that is not a host name, as a URL, is rejected at connection.oauth2.hosts.<n> with names a host, as in files.slack.com.

actsAs = "requester" without oauth2 is rejected with Integration <integration> takes each person's connection. A person can connect only over oauth2.

connection = {
  actsAs = "requester"
  oauth2 = {
    authorize    = "https://acme.example/oauth/authorize"
    token        = "https://acme.example/oauth/token"
    registration = "https://acme.example/oauth/register"
    resource     = "https://api.acme.example"
    scopes       = ["issues:write"]
  }
}

Acts as

Acts asA tool acts withPolls, schedules and on bindings act with
teamThe team's connection.The team's connection.
requesterThe connection of the person who started the task: the task's Created by field.The team's connection.

A team connection is made by an owner or admin of the workspace. A person's connection is made by that person, who must be on the team, and only for an integration whose actsAs is requester. See Integration connections.

When a tool of a requester integration is called, nothing is sent until Spotlight has that person's connection. It never uses the team's connection in its place.

SituationResult
The person has connected.The call is made with their access token.
The person has not connected, or the service could not refresh their connection.The task is assigned to them and put to them with a request to connect. The call fails with <tool> acts as the person who started this task, and they haven't connected <integration>. They've been asked in their inbox. Nothing was sent. Stop here and end your turn: you're resumed once they connect. When they connect, the request is answered with Connected <integration>.
No person started the task.The call fails with <tool> was not used, so nothing was sent: nobody started this task, so there is nobody whose <integration> connection it could act with.
The person who started the task is no longer on the team.The call fails with <tool> was not used, so nothing was sent: the person who started this task is no longer on the team, so it cannot act with their <integration> connection.
The task already waits on a person for something else.Nobody is asked. The call fails with <tool> was not used, so nothing was sent: this task is already waiting on someone, so nobody can be asked to connect <integration> until they answer.

<integration> is the integration's name. A hook step that calls a tool of a requester integration fails with not-allowed.

OAuth connect and callback

An integration with connection.oauth2 shows a Connect team account button, and Change account once connected, on the team's Integrations settings page. An integration whose actsAs is requester also shows Connect your account there, where each person connects their own account. It connects only when Spotlight has an OAuth client for it. See OAuth client.

StepEndpointBehaviour
BeginPOST /api/teams/{teamId}/integrations/{integration}/connectAn optional body with actsAs and returnTo. actsAs is team, the default, which needs a signed-in owner or admin of the workspace (the administer permission); requester, the caller's own connection, needs a signed-in person on the team, and an integration whose actsAs is requester. returnTo is where to return to afterwards, a path under /w/<slug>/inbox or /w/<slug>/settings. Returns { "url": ... }, the authorization URL with client_id, redirect_uri, response_type=code, scope, a signed state, code_challenge with code_challenge_method=S256 unless pkce is false, and resource when set, and sets a one-time cookie. For the errors, see Begin errors.
CallbackGET /api/integrations/oauth/callbackNeeds the same signed-in person, still allowed to make the connection, and the cookie. Exchanges the code, with its PKCE verifier unless pkce is false, and keeps the tokens encrypted. Redirects to returnTo with ?connected=<integration>, or else to /w/<slug>/settings/team/<teamId>/integrations?connected=<integration>, or to /?integration=failed.
ListGET /api/teams/{teamId}/connectionsNeeds a signed-in person on the team. Returns mine, the caller's own connections, each with integration, linkedAccount, connectedAt and tools, the caller's rule for each tool as { tool, rule }, and people, every person's connection in the team with personId and name as well, for an owner or admin, or null for anyone else. Never a token.
DisconnectDELETE /api/teams/{teamId}/integrations/{integration}/connections/mineNeeds a signed-in person on the team. Removes the caller's own connection. Returns 204. There is no endpoint to remove another person's connection.
Set a tool rulePUT /api/teams/{teamId}/integrations/{integration}/connections/mine/tools/{tool}Needs a signed-in person on the team. A body { "rule": ... }: allowed, the default, follows the team's rule; needs-approval asks the caller first; blocked never runs the tool. {tool} is the tool's full name, as in linear.comment. Applies only to calls made with the caller's own connection, and the stricter of the team's rule and the caller's wins. See Person rules. Returns 204. 404 when the caller is not on the team, the integration does not offer the tool, or its connection.actsAs is not requester. 422 validation error for a malformed tool name or any other rule.

The state expires after 10 minutes. A request with auth.oauth2 sends the access token as Authorization: Bearer, only to a host the integration names. See Token hosts. An event's lookup.request and an attachments.fetch send the team's access token, also for a requester integration. While the team has not connected, Spotlight sends neither, and the delivery fails with Integration <name> has no team connection. Connect the team account to read its deliveries.

Token hosts

Spotlight sends the access token only to these hosts:

  • The host of each url with auth.oauth2, where the definition writes the host out. https://slack.com/api/${{ inputs.method }} names slack.com.
  • The host of url and baseUrl of an openapi or graphql block with auth.oauth2.
  • Each host in oauth2.hosts.

A url whose host comes from an expression, as ${{ file.url_private_download }}, names no host. Its request gets the token only for a host in oauth2.hosts. For any other host, Spotlight does not send the request, and the request fails with <host> is not a host the integration names, so Spotlight did not send the connection token there. Add <host> to connection.oauth2.hosts.

connection = {
  oauth2 = {
    authorize = "https://slack.com/oauth/v2/authorize"
    token     = "https://slack.com/api/oauth.v2.access"
    hosts     = ["files.slack.com"]
  }
}

Begin errors

The Integrations settings page shows the message at the bottom of the page.

StatusMessageWhen
400A connection must act as team or requester. Received: <actsAs>actsAs is neither.
403Only a workspace owner or admin can connect a team account.actsAs is team, and the caller is not an owner or admin of the workspace.
403Outbound call to <host> blocked. <reason>Discovery or client registration calls a host that the deployment or the workspace does not allow. See Requests.
403Secret <NAME> is not bound to <origin>.The secret that oauth2.client.secret gives is not bound to the host of token. See Bindings.
404Team <teamId> not found.There is no such team, or the caller is not in its workspace.
404Integration <integration> not found.The team has no such integration.
404Integration <integration> doesn't take a team account. or Integration <integration> doesn't take a personal account.The integration has no connection.oauth2, or a person asks for their own connection and its actsAs is not requester.
409Secret <NAME> not found. Please create it first.The workspace has no secret of the name that oauth2.client.secret gives.
422Integration <integration> has no OAuth2 client.Spotlight has no OAuth client for the integration. See OAuth client.
422Integration <integration> has no OAuth2 client for its authorization server.The deployment's client for a discovered server has no issuer, or another one. See Discovery.
502OAuth2 endpoints for integration <integration> not found.Discovery found no endpoints. See Discovery.
502Client registration for integration <integration> failed.The registration endpoint did not register a client. See Client registration.

<integration> is the integration's integration name.

OAuth client

Spotlight connects with the first OAuth client it has for the integration:

  1. The team's own client, oauth2.client.
  2. The deployment's client for the integration's name, in OAUTH_CLIENTS.
  3. A client registered at oauth2.registration, or at the registration endpoint that discovery finds. See Client registration.

A connection with discover = true has no oauth2.client.

connection = {
  oauth2 = {
    authorize = "https://acme.example/oauth/authorize"
    token     = "https://acme.example/oauth/token"
    scopes    = ["issues:write"]
    client    = { id = "acme-client-id", secret = "secret.ACME_CLIENT_SECRET" }
  }
}

The service's OAuth app must name the redirect URL https://app.usespotlight.ai/api/integrations/oauth/callback, with the deployment's address in place of app.usespotlight.ai on a self-hosted Spotlight.

Spotlight reads the secret that client.secret names when a connection begins, when its code is exchanged and when its token is refreshed. It sends the value as client_secret on token requests, and nowhere else. The secret counts as one the integration names, so it cannot be deleted while the definition names it. See Rules. A client without secret sends no client_secret.

Each connection keeps the ID of the client it was made through. When client.id names another client, Team account shows "Made through another OAuth app" and the Connect team account button, and Spotlight does not refresh the connection. Connect the team account again to make it through the new client.

Refresh

WhenWhat Spotlight does
An access token has less than 5 minutes left.Refreshes it with the refresh token.
A request with auth.oauth2 is answered 401.Refreshes the token once and sends the request once more with the new one. Any other status, and a request authenticated by secrets, are not retried.
An event's lookup.request or attachments.fetch with auth.oauth2 is answered 401.Refreshes the team's token once and sends the request once more with the new one. The other requests of the same delivery use the new token.
A refresh finds that Spotlight now connects through another client than the one the connection was made through.Does not refresh. Marks the connection failed. See OAuth client.
A spec fetch with auth.oauth2 is answered 401.Refreshes the team's token once and fetches the spec once more with the new one.

One refresh of a connection runs at a time, across every control-plane instance, under a claim that lasts 30 seconds. A request answered 401 while another refresh has the claim waits for it, for up to 30 seconds, and is sent again with the new token. A refresh token the service rotates is stored. When the service does not refresh it, the connection is marked failed until it is made again. A person whose connection failed is asked to connect again the next time a tool needs it.

Client registration

When the definition has no oauth2.client, the deployment has no OAuth client for the integration, and oauth2.registration is set, Spotlight registers a client at that endpoint the first time someone in the team connects, once per team and integration. The registration is a POST of JSON with client_name Spotlight, the callback URL as the one redirect_uris entry, grant_types authorization_code and refresh_token, response_types code and token_endpoint_auth_method client_secret_post. The answer must contain a client_id; a client_secret is stored encrypted, with its client_secret_expires_at. The client is reused until the registration endpoint or the callback URL changes or the client secret expires, and is then registered again. A client without a secret sends no client_secret on token requests. When the endpoint does not answer with a client, beginning the connection answers 502 with Client registration for integration <integration> failed.

The deployment must allow calls to the registration endpoint, as to the token endpoint. See Calls out of Spotlight.

Discovery

With oauth2.discover, Spotlight finds where to connect from the MCP server named in mcp.url, following the MCP authorization specification, when a connection begins, when its code is exchanged and when it is refreshed:

  1. It sends the server an initialize request without credentials. A 401 whose WWW-Authenticate names resource_metadata points at the server's protected resource metadata (RFC 9728). Otherwise Spotlight reads /.well-known/oauth-protected-resource with the server's path after it, and then at the root.
  2. It reads the authorization server metadata (RFC 8414, then OpenID Connect discovery) of the first of the metadata's authorization_servers, or of the server's own origin when there is none.
Connection fieldComes from
authorizeauthorization_endpoint
tokentoken_endpoint
registrationregistration_endpoint, when the authorization server has one. See Client registration.
scopesoauth2.scopes when set, else the protected resource metadata's scopes_supported.
resourceoauth2.resource when set, else the protected resource metadata's resource, else mcp.url.

Discovery fails when the authorization server metadata's issuer is not the URL it was read for (RFC 8414), when its code_challenge_methods_supported does not list S256, or when the protected resource metadata names a resource that is neither mcp.url nor on its origin above its path. Then the integration does not connect, and beginning a connection answers 502 with OAuth2 endpoints for integration <integration> not found. Every request goes only to hosts that the deployment allows, and each waits at most 15 seconds. A request to another host makes beginning a connection answer 403 with the message that blocked it. What was found is cached for 10 minutes on each control plane server.

The client a connection uses is bound to the authorization server it was made with: its issuer, authorization endpoint and token endpoint.

ClientBound by
Registered at registration_endpointSpotlight stores the three with the registration. When a later discovery finds others, the next connection registers again, and exchanging a code or refreshing a token with the old client fails.
Configured in the deployment for the integrationIts configured issuer. A deployment client without an issuer, or with another one, is not used for a discovered server, and the integration does not connect: beginning a connection answers 422 with Integration <integration> has no OAuth2 client for its authorization server.

Webhook

FieldTypeDefaultDescription
shapeobjectnoneThe shape of body, for type-checking.
verifyobjectrequiredHow a delivery is verified. Exactly one of hmac, token, asymmetric or jwt. See verify.
respondobjectnoneA handshake response. when (an expression that returns bool) and body (an expression). When when is true, Spotlight returns 200 with body and does not read the delivery further.
ignoreWhenstringnoneAn expression that returns bool. When it is true, the delivery is the service echoing Spotlight's own post, and its happenings are dropped.
routeobjectnoneby (expression). Type-checked. Deliveries go to the integration's team whatever it returns.
parsestringjsonjson or form. Stored in the definition. Not used when a delivery is read.
deliverystringnoneAn expression. The delivery's id. A delivery with an id already taken is not processed again. Without it, the SHA-256 of the raw body.
eventsarray of objectsrequiredAt least one. See events.

Delivery address

On a self-hosted Spotlight, use your deployment's address in place of app.usespotlight.ai.

POST https://app.usespotlight.ai/api/webhooks/w/<workspace slug>/t/<team key>/<integration>
StatusWhen
200 with the respond.body textThe delivery is verified and respond.when is true.
204The delivery is verified and accepted. It is read afterwards.
401The signature does not verify, the signing secret is missing or cannot be read, the delivery's freshness.at cannot be read or is further from now than freshness.within, the integration has no webhook, the delivery has no raw body, or there is no such workspace, team or integration. The response does not say which.

An accepted delivery whose processing fails is retried up to 8 attempts in all, from 2 seconds apart doubling to 1 hour.

Verify

hmac:

FieldTypeDefaultDescription
algorithmstringsha256sha256, sha1 or sha512. The HMAC digest.
secretstringrequiredThe signing secret. A secret reference, secret.<NAME>.
signedstringnoneAn expression. The text that was signed. Can read body, headers and raw. Without it, the raw body.
encodingstringhexhex or base64. How the signature is written.
prefixstring""Text written before the signature, as in v0=.
headerstringnoneThe header that carries the signature. A delivery without it is rejected, and without header no delivery verifies.
freshness.atstringnoneAn expression. The delivery's time in Unix seconds. A delivery whose time cannot be read is rejected. Required with freshness.
freshness.withinstringnoneSeconds, written as 300s. A delivery further than this from now is rejected. Required with freshness.

token:

FieldTypeDefaultDescription
secretstringrequiredThe shared token. A secret reference, secret.<NAME>.
headerstringnoneThe header that carries it. Compared whole. A delivery without it is rejected, and without header no delivery verifies.

asymmetric:

FieldTypeDefaultDescription
algorithmstringrequireded25519 or rsa-sha256. The signature algorithm.
keystringrequiredThe public key: hex of the raw key for ed25519, PEM for rsa-sha256. May contain expressions.
signedstringnoneAn expression. The text that was signed. Without it, the raw body.
encodingstringhexhex or base64. How the signature is written.
headerstringnoneThe header that carries the signature. A delivery without it is rejected, and without header no delivery verifies.
freshnessobjectnoneAs for hmac.

jwt:

FieldTypeDefaultDescription
jwksstringrequiredWhere the signing keys are published.
headerstringauthorizationThe header that carries the token. A Bearer prefix is removed.
audiencestringnoneWhen set, the token's aud must contain it.
issuerstringnoneWhen set, the token's iss must equal it.

A jwt token must be signed with RS256. An expired token is rejected.

verify accepts no other way. oauth2 and secrets are rejected with verifies a delivery by hmac, token, asymmetric or jwt.

Events

webhook.events and poll.events are lists of events. Each event is read against every delivery or poll response, in order, and raises one happening when its when is true.

FieldTypeDefaultDescription
forEachstringnoneAn expression that returns a list. The event is read once for each item, which expressions see as item.
whenstringrequiredAn expression that returns bool. The event raises only when it is true. An expression that fails to evaluate counts as false.
lookup.requestobjectnoneA further request made before raising. See requests. With auth.oauth2, it carries the team's connection. When it does not succeed, the event raises without the captures.
lookup.capturemap of name to stringnoneValues read from the lookup's response. Raise expressions see each by its name. Each value is an expression. Required with lookup.request.
lookup.callstringnoneA read-only tool to call, as <integration>.<tool>, as in workersai.decide. See Lookup calls.
lookup.withobject{}The tool's inputs. Only with lookup.call. Strings may contain expressions.
raiseobjectrequiredSee raise.

A lookup names exactly one of request and call. capture goes only with request, and with only with call.

Lookup calls

An event whose lookup has call calls the tool once for each item with forEach. The tool's output is bound whole as lookup, which when and the raise expressions read, as in lookup.label == 'flaky'. A when that reads lookup is checked after the call. A when that does not read lookup is checked before the call, and the tool is called only when it is true. Webhook events and poll events both make the call, and both also send lookup.request.

One poll or delivery makes at most 20 lookups, tool calls and lookup.request requests together, at most 4 at once. When a read reaches the limit, Spotlight logs a warning and does not read the events that need another call:

ReadResult
A pollIts cursor stays where it was. The next poll reads from the same cursor and reads the rest. It skips an event it read before by the happening the event raises, the event's place among the events that raise that happening, and the item's content. An event without forEach is skipped by the content of the response it reads, so it is read again when the response changed. So a change to events that raise other happenings does not read the event again. An item whose content changed since is read again.
A webhook deliveryThe events read before the limit raise their happenings. Then the delivery fails, and is not tried again, with The delivery reached the limit of 20 lookup calls in one read, so it did not read <n> of its events.

See Outbound calls.

CaseResult
The tool answerslookup is the tool's output.
An expression in with fails, the inputs do not match the tool, the tool fails, or it does not answer within 30 secondslookup is unset. An expression that reads it fails, so when counts as false.

The tool may belong to any integration of the team. It must have readOnly and no approval, and its integration may not act as the person who started a task. For a tool of the same integration, a write that breaks a rule is rejected at lookup.call:

Rule brokenMessage
No integration of the team offers the toolnames <tool>, which no integration of the team offers
The tool is not read-onlycalls <tool>, which is not read-only. A lookup calls its tool on every event it reads
The tool has approvalcalls <tool>, which needs a person's approval before each call. A lookup cannot approve the call
Its integration acts as the requesternames <tool>, which acts as the person who started a task. A lookup acts as nobody

For a tool of another integration, the same rules are checked at the call, and a broken rule leaves lookup unset. An expression in a tool's action or output is checked as called by a lookup only when a lookup of the same integration calls that tool. There, it has inputs and connection. See Integration positions. A lookup call is in no run, so its usage is in no run's cost and not in Insights. Spotlight logs each such call as A lookup call used a model, and counts it in the metrics spotlight.lookup_calls, spotlight.lookup_call.tokens and spotlight.lookup_call.cost. A call that timed out counts in spotlight.lookup_call.timed_out, and its usage still counts if it answers later. See Metrics.

Raise

FieldTypeDefaultDescription
happeningstringrequiredThe happening's name. Begins with the integration's name.
labelstringnoneWhat a person picking a happening reads. Without it, the happening's name.
summarystringnoneHow the happening reads in a note on the task. Without it, the happening's name.
answersbooleanfalseWhether the happening carries a message to the task.
messagestringnoneAn expression. The message carried. For opens.chat, the message to the chat.
author.emailstringnoneAn expression. The email of the person who wrote the message: a member's sign-in email or an email they verified. The message on the task shows that member's avatar. With no such member, the message shows no avatar.
opensobjectnoneOpens a task, or starts a chat, when no task is found. See below.
branchstringnoneAn expression. A branch name that finds a task.
marksarray of objects[]Marks that find a task, or are kept on the task this opens.
attachmentsobjectnoneFiles attached to the task. See below.

A raise must name a branch or at least one mark with find: true; otherwise it is rejected with needs a branch or a mark. Without one, no task can be found from it. When neither evaluates to a value, reading the delivery fails.

Mark:

FieldTypeDefaultDescription
kindstringrequiredThe mark kind, integration name first.
valuestringrequiredAn expression. The mark's value. A mark whose value is empty is not kept.
findbooleantruetrue: the mark finds the task or chat the happening is about. false: the task or chat this opens keeps it, and it never finds one.

opens either opens a task on a line or starts a chat. To open a task:

FieldTypeDefaultDescription
lineRolestringrequiredThe role of the line to open on, in lowercase words joined by dashes.
stationstringnoneThe key of the station to open at. Without it, or with a key the line does not have, the line's first work station.
titlestringrequiredAn expression. The task's title. No task opens when it is empty.
descriptionstringnoneAn expression. The task's description.
assignBy.emailstringnoneAn expression. The email of the person to assign: a member's sign-in email or an email they verified. The person must be a member of the line's team. With no such member, the task is assigned to the line's defaultAssignee, or opens with no assignee when the line has none, and its questions wait for the team.

A task opens only on a line of the team whose role is lineRole, and only when the raise carries at least one mark.

To start a chat with the team's agent:

FieldTypeDefaultDescription
chat.by.emailstringrequiredAn expression. The email of the member who starts the chat: their sign-in email or an email they verified.
chat.harnessstringnoneThe harness that answers, as in codex. Without it, Spotlight's default harness.

A happening with opens.chat reaches a chat only when no task has its marks. When a chat has one of its finding marks, its message is added to that chat, and only the member who started the chat can add to it. A message that is accept or dismiss, with an optional number, decides on the chat's open proposals. Proposals are numbered from 1 in the order the agent made them, and keep their number. Without a number, the decision is on the only open proposal.

When no chat has one of the marks, a new chat starts on the integration's team, with the repositories of the team's lines, and keeps each mark of the raise once. A chat starts only for a member of the team, with a message or an attachment, on a harness Spotlight knows, and only when the team's lines run in one image. When a chat cannot start or continue, the integration's chat.refused binding is told why.

attachments:

FieldTypeDefaultDescription
eachstringrequiredAn expression that returns a list, one entry per file. Later fields see each entry as file.
namestringrequiredAn expression. The file name. An entry with no name is skipped.
typestringnoneAn expression. The content type.
sizestringnoneAn expression. The size in bytes.
fetchobjectrequiredThe request that downloads the file. With auth.oauth2, it carries the team's connection.

Poll

FieldTypeDefaultDescription
shapeobjectnoneThe shape of body, for type-checking.
everystringrequiredWhole seconds between polls, written as 60s.
requestobjectrequiredThe request made each time. Can read cursor and connection.
cursorstringnoneAn expression. The next cursor, read from the response. Can read body and cursor.
eventsarray of objectsrequiredAt least one. Read against the response, which expressions see as body.

A poll whose request fails raises nothing.

Schedule

FieldTypeDefaultDescription
cronstringrequiredA cron expression: five fields, or six with seconds first.
actionstringrequiredThe action to run. It must be defined in actions.

Actions

Action names are lowercase words joined by dashes, at most 64 characters.

FieldTypeDefaultDescription
requestobjectrequiredThe request. See Requests.
fromstringspotlightspotlight or network. spotlight: Spotlight sends the request from its own servers. network: one of the workspace's hosts sends it. See Sent from the network.
timeoutSecondsinteger301 to 60. How long Spotlight waits for a host to send the request and return the response. Only when from is network.
uploadsobjectnoneFiles that Spotlight sends before request. See Uploads.
usageobjectnoneWhat a call used of a model, read from the response. See Usage.

Usage

usage reads what the service used for one call, for a service that runs a model. Spotlight reads it from each call whose response it read, answered or failed. A failed call with usage is metered too.

FieldTypeDefaultDescription
inputTokensstringnoneAn expression that returns a whole number of 0 or more.
outputTokensstringnoneAn expression that returns a whole number of 0 or more.
coststringnoneAn expression that returns a number of 0 or more.
currencystringnoneAn ISO 4217 code, as in USD, or an expression. Required with cost, and only with it.
modelstringnoneThe model's name, at most 200 characters. May contain expressions.

usage reads at least one of inputTokens, outputTokens and cost. Its expressions read what the action's request does, and response, status and capture. A field whose expression fails, returns a wrong type or returns a value out of range is not recorded, and Spotlight logs a warning that names those fields. A call with no cost recorded counts as an unpriced call.

usage = {
  inputTokens  = "$${{ response.result.usage.input_tokens }}"
  outputTokens = "$${{ response.result.usage.output_tokens }}"
  cost         = "$${{ double(response.result.usage.input_tokens) * 0.24 / 1000000.0 }}"
  currency     = "USD"
  model        = "$${{ response.result.model }}"
}

When a tool or a hook step calls the action in a run, the run's journal gets a tool.metered entry, which reads <tool> used <model>, or <tool> used a model without model. It holds the tool, the integration, the hook when a hook step made the call, the model, the tokens and the cost. The run's tool-model cost is what its metered calls cost, and shows with its currency even when the run has no total cost. The run's total cost is what its harness cost plus its tool-model cost, only when both are known and in the same currency. The tool-model cost is not known when any metered call is unpriced, or when the calls cost in more than one currency. See Run spend.

MessageCause
reads at least one of inputTokens, outputTokens and costusage reads no count and no cost.
names the currency of cost, as in USDOn usage.currency. cost without currency.
goes only with costOn usage.currency. currency without cost.
is an ISO 4217 code, as in USDOn usage.currency. It is not three capital letters or an expression.

Uploads

uploads sends files of the task's question before the action's request. For each file, Spotlight sends prepare, then sends the file's bytes with send. After the last file, it sends complete. Then it sends ready for each file until the file is ready or attempts is reached. Then it sends request, which reads the uploaded files in uploaded.

FieldTypeDefaultDescription
eachstringrequiredAn expression that returns a list of entries of ask.attachments. Later requests see each entry as file. An entry that is not a file of the question is skipped.
prepareobjectrequiredThe request sent first for each file. See Requests. Reads file. Its capture is prepared.
sendobjectrequiredThe request that sends the file. Reads connection, file and prepared. Has no body: the body is the file's bytes, with content-type set to the file's type unless a header sets it.
completeobjectnoneThe request sent once, after the last file. Reads uploaded.
readyobjectnoneThe request that checks that the service can show a file. See Ready.

Each entry of uploaded has the file's id, name, type and size, and prepared. uploaded is empty when the question has no files, and when each lists none.

When prepare, send or complete fails, or a file is not ready, Spotlight still sends request, with uploaded empty, and the binding fails with the error of the upload. When the service answers request with a failure while uploaded has files, Spotlight sends it once more with uploaded empty. A request that gets no answer is not sent again. A file that each lists more than once is sent once.

post-question = {
  uploads = {
    each = "$${{ ask.attachments.filter(file, file.type == \"image/png\") }}"
    prepare = {
      method  = "GET"
      url     = "https://slack.com/api/files.getUploadURLExternal"
      query   = { filename = "$${{ file.name }}", length = "$${{ string(file.size) }}" }
      auth    = { secrets = ["secret.SLACK_BOT_TOKEN"] }
      capture = { url = "$${{ response.upload_url }}", id = "$${{ response.file_id }}" }
    }
    send = {
      method = "POST"
      url    = "$${{ prepared.url }}"
    }
    complete = {
      method = "POST"
      url    = "https://slack.com/api/files.completeUploadExternal"
      auth   = { secrets = ["secret.SLACK_BOT_TOKEN"] }
      body   = "$${{ {\"files\": uploaded.map(each, {\"id\": each.prepared.id, \"title\": each.name})} }}"
    }
    ready = {
      method = "GET"
      url    = "https://slack.com/api/files.info"
      query  = { file = "$${{ prepared.id }}" }
      auth   = { secrets = ["secret.SLACK_BOT_TOKEN"] }
      expect = { success = "$${{ response.ok && has(response.file.mimetype) && response.file.mimetype != \"\" }}" }
    }
  }
  request = {
    method = "POST"
    url    = "https://slack.com/api/chat.postMessage"
    auth   = { secrets = ["secret.SLACK_BOT_TOKEN"] }
    body   = "$${{ {\"channel\": target.channel, \"text\": ask.body, \"blocks\": uploaded.map(each, {\"type\": \"image\", \"slack_file\": {\"id\": each.prepared.id}, \"alt_text\": each.name})} }}"
  }
}

A definition is rejected with:

PathMessageCause
actions.<name>.uploads.send.bodyis the body of the request that sends a file. Spotlight sends the bytes of the file as the body. Please remove bodysend has a body.
actions.<name>.uploadssends files that Spotlight keeps. An action sent from the network cannot read them. Please remove from: network, or remove uploadsfrom is network.
tools.<name>.actionnames the action <action>, which uploads files. A tool has no files. Please name an action without uploadsA tool names an action with uploads.
schedule.actionnames the action <action>, which uploads files. A schedule has no files. Please name an action without uploadsThe schedule names an action with uploads.
on.<event>.<n>.actionnames the action <action>, which uploads files. A chat event has no files. Please name an action without uploadsA binding of a chat. event names an action with uploads.
on.<event>.<n>.actionnames the action <action>, which uploads files. An inbox request event has no files. Please name an action without uploadsA binding of inbox-request.opened names an action with uploads.
on.<event>.<n>.actionnames the action <action>, which uploads files. A notice event has no files. Please name an action without uploadsA binding of notice.raised names an action with uploads.
on.<event>.<n>A chat event has no task to mark and no line to route by. Please remove mark and routesA binding of a chat. event has mark or routes.
on.<event>.<n>A notice event has no task to mark and no line to route by. Please remove mark and routesA binding of notice.raised has mark or routes.

Ready

Some services process a file after the upload, and refuse a message that shows the file before that ends. Slack is one of them. ready is a request, as in Requests, sent for each file after complete. It reads connection, file and prepared. The file is ready when the request succeeds, as its expect decides. Until then, Spotlight sends it again every second. When the service answers 401 or 403, Spotlight stops at once, because that answer does not change.

FieldTypeDefaultDescription
attemptsinteger101 to 30. How many times Spotlight sends ready for a file.

A definition is rejected with:

PathMessageCause
actions.<name>.uploads.ready.attemptsis 1 to 30 attemptsattempts is less than 1 or more than 30.

Requests

A request appears in actions, uploads, poll.request, lookup.request and attachments.fetch.

FieldTypeDefaultDescription
responseobjectnoneThe shape of response, for type-checking.
methodstringPOSTGET, POST, PUT, PATCH or DELETE. The HTTP method.
urlstringrequiredThe address. May contain expressions.
querymap of name to string{}Query parameters. A parameter that evaluates to nothing is left out. Values may contain expressions.
headersmap of name to string{}Request headers. A header that evaluates to nothing is left out. Values may contain expressions.
bodystring, array or objectnoneA string is sent as it is. A body that is one expression is sent as text when the expression returns a string, and as JSON for any other value, such as a number, timestamp, bytes or duration. A map whose keys JSON writes the same, such as 1 and "1", cannot be sent. A list or object is sent as JSON, with content-type: application/json unless a header sets it. Strings inside may contain expressions.
authobjectnoneExactly one of oauth2 or secrets. See below.
expect.successstringnoneAn expression that returns bool. When set, decides whether the request succeeded.
expect.statusarray of integersnoneStatuses that count as success, when expect.success is not set.
capturemap of name to stringnoneValues read from the response. Each value is an expression.
retryobjectnonetimes (integer, default 0) and backoff (string). Stored in the definition; a request is sent once.

Without expect, a request succeeds on any 2xx status. An expression in url, query, headers or body that fails to evaluate fails the request before it is sent.

auth:

FieldTypeDefaultDescription
oauth2.connectionbooleantrueMust be true. Sends the connection's OAuth access token as Authorization: Bearer: the team's, or for a tool of a requester integration, that of the person who started the task. See Acts as.
secretsarray of stringsnoneSecret references, secret.<NAME>, at least one when set. Each secret is injected into its bound header or query parameter on requests to the hosts it is bound to. A request to any other host goes without it, and so does a redirect to another host.

auth accepts no other way, and is rejected with authenticates a request by its oauth2 connection, or by the secrets that Spotlight injects for the hosts they are bound to. See Bindings.

Every request that Spotlight sends goes only to hosts that the deployment allows, at addresses that Spotlight calls. See Calls out of Spotlight. When the deployment sets SPOTLIGHT_OUTBOUND_ALLOWED_HOSTS, a request to a host that the list does not name is blocked with Outbound call to <host> blocked. Host is not on the allowed list. When the workspace has outboundHosts, a request to a host that the workspace's list does not allow is blocked with Outbound call to <host> blocked. Host is not on the workspace's allowed list. See Workspace lists. A request to a blocked address is blocked with a message that starts with Outbound call to <host> blocked. The address or Outbound call to <host> blocked. The host resolves to. A request is also blocked with Outbound call to <url> blocked. URL is not valid., Outbound call to <host> blocked. redirected more than 5 times, or Outbound call to <host> blocked. is where an https request was redirected to over plain http, which Spotlight does not follow.

A request waits up to 5 seconds when the workspace is over its rate limit. If no request becomes free in that time, the request is not sent, and fails with calling a service: this workspace sends more than <limit> requests each second to other services.

Sent from the network

An action whose from is network is not sent by Spotlight. Spotlight queues it, and any host that reports to the workspace may claim it. That host sends it from a one-off egress container. See Calls sent from the network. The requests of poll, lookup and attachments are always sent by Spotlight. Hooks have the same choice; see from.

RuleValue
HostsThe hosts that the host's egress allow-list allows, at the addresses that egress opens. SPOTLIGHT_OUTBOUND_ALLOWED_HOSTS, Spotlight's blocked addresses and the workspace's outboundHosts do not apply.
Rate limitCounts once toward the workspace's rate limit, before Spotlight queues the action.
Schemeshttp and https. With auth.secrets, https only.
HeadersNo host header. A definition that sets one is rejected. Egress sends the request with the host of url.
authsecrets only. oauth2 is rejected.
TriesOne. The request is sent once.
TimetimeoutSeconds, from the moment Spotlight queues the action until a host returns the response. The host that claims it gets the time that is left.
RedirectsNot followed. A redirect response is the response.
Response bodyThe first 256 KiB.

A definition is rejected with:

PathMessageCause
actions.<name>.request.authcannot use an OAuth connection. An action sent from the network authenticates only with auth.secretsfrom is network, and auth has oauth2.
actions.<name>.request.urlis an http address. Egress injects secrets only into https requests. Please use an https addressfrom is network, auth has secrets, and url starts with http:.
actions.<name>.timeoutSecondsis how long Spotlight waits for a host to send the action. Only an action sent from the network has it. Please set from: network, or remove timeoutSecondstimeoutSeconds is set, and from is spotlight.
actions.<name>.timeoutSecondsis 1 to 60 secondstimeoutSeconds below 1 or above 60.
actions.<name>.request.headers.<header>is a Host header. Egress sends an action from the network to the host its URL names. Please remove the Host headerfrom is network, and headers has Host.

Spotlight reads the response as it reads the response of a request it sends: expect decides success, and capture reads from it.

Spotlight never sends a secret's value with the action. In the request that the host claims, each secret of auth.secrets is a stand-in, spotlight-egress:<NAME>, with the binding's prefix, in the header or query parameter that its binding names for the request's host. The claim carries a one-time token:

StepWhat happens
KeyThe egress that sends the action makes a key for this action alone.
RedeemEgress gives the token and its public key to Spotlight, once. Spotlight accepts it only while the host that claimed the action has it, before timeoutSeconds ends.
SealSpotlight seals the value of each secret to that key, bound to the action and the secret. The host's egress allow-list limits where the values go.
InjectEgress replaces each stand-in with the secret's value, only on the request to a host that the secret is bound to. It asks that host for an uncompressed response.
RedactEgress replaces the secret's value with its stand-in in every response header and in the body, whatever its content type, before it returns the response. A compressed body is dropped.

If egress cannot inject a secret that the action names, it sends nothing. This happens when Spotlight denies egress the secret, or when the host's egress allow-list does not allow the secret's bound host. When Spotlight queues the action, a secret that does not exist fails it with Secret <NAME> not found. Please create it first., and a secret that is not bound to the request's host fails it with Secret <NAME> is not bound to <origin>.

An action sent from the network fails with:

MessageCause
sending a request to <host> from the workspace’s network: no host of the workspace sent it within <n> secondsNo host claimed the action, sent it and returned the response within timeoutSeconds.
sending a request to <host> from the workspace’s network: the action sets a Host header, so Spotlight didn’t queue itA Host header came from a template. Spotlight did not queue the action.
sending a request to <host> from the workspace’s network: The call's Host header names another host than its URL, so egress didn't send the call. Host: <host>Egress refused a Host header that names another host than url.
sending a request to <host> from the workspace’s network: <error>The host got no response. <error> is the host's reason, such as The host's allow-list doesn't allow <host>.
sending a request to <host> from the workspace’s network: Egress couldn't redeem the call's secrets, so it didn't send the call. Error: <reason>Egress could not get the action's secrets from Spotlight, so it did not send the request.
sending a request to <host> from the workspace’s network: Egress couldn't inject secret <NAME>, so it didn't send the call.Egress could not inject a secret that the action names, so it did not send the request.
sending a request to <host> from the workspace’s network: The response was compressed, so egress couldn't redact it.The response had a Content-Encoding other than identity. Egress dropped the body.
sending a request to <host> from the workspace’s network: a host claimed it but didn’t answer within <n> secondsA host claimed the action, and did not return the response before timeoutSeconds ended.

Tools

FieldTypeDefaultDescription
actionstringrequiredThe action the tool runs. It must be defined in actions.
descriptionstringrequiredWhen an agent should use the tool. May not be empty.
approval.becausestringnoneWhen set, each use first asks a person, who is shown this text. May not be empty. The tool may not then have an input named intent.
inputsmap of name to object{}The tool's inputs.
outputstringnoneAn expression. What the tool returns. Can read response, status, capture and inputs. Without it, the capture map.
readOnlybooleanfalseThe tool reads and changes nothing in the service. A replay has the tool only when it is true and the tool has no approval. Spotlight does not check it against the action.
enabledOnMarkstringnoneA mark kind of this integration, as in sentry.issue. A run on a task that has a mark of this kind has the tool, also at a station that does not list it in tools. See Enabled on a mark.

Input:

FieldTypeDefaultDescription
typestringstringstring, number, integer or boolean. The input's type. Expressions see boolean as bool, and number and integer as dyn.
schemaobjectnoneA JSON Schema for the input, in place of type, for a list, an object or a constrained value. An input with both type and schema is rejected with takes a type, or a JSON Schema as its schema, but not both. Expressions see a string schema as string, a boolean one as bool, and any other as dyn. See Input schemas.
descriptionstringnoneShown to the agent.
requiredbooleanfalseWhether the agent must give it.
defaultstringnoneThe value when none is given. Can read task. May contain expressions.
stdinbooleanfalseThe input may come from the standard input of the tool command. At most one input per tool, and it must take text.

An input may not be named json: Spotlight reserves that name for handing a tool every input at once, and rejects the tool with tool <integration>.<tool> cannot take reserved input json. That input hands a tool every input at once.

An agent calls a tool as <integration>.<tool>. A tool with approval also takes intent from the agent, which is shown to the person and never sent; see What the agent wants. A tool whose request fails returns the integration answered <status>: <body>, with the body cut at 500 characters. See Approvals and Require approval before a tool runs.

Tools in a replay

A replay has a tool only when the tool changes nothing: the tool has readOnly = true and no approval. A tool generated from an API spec or listed by an MCP server is never read-only, so a replay does not have it. A replay has no built-in tools and no catalog tools.

A replay has these tools from its station's tools and from the marks of its past task, as the run it replays had them. It calls them as no person. A tool that needs a person's connection fails there, and no person is asked to connect. A tool reads the service as it is when the replay runs, not as it was when the past task ran.

A replay that calls a tool that changes data, as when the integration changed after the replay started, fails the call with This run may not call <tool>, which can change data or needs a person’s approval: it acts on nothing beyond its own result.

Enabled on a mark

A tool with enabledOnMark is enabled for each run on a task that has a mark of that kind. The station's tools and skills add to it; they cannot remove it. Thus an agent that works on a task that the integration opened or found can always read more about it from the service:

tools = {
  get-issue = {
    action        = "get-issue"
    description   = "Read the Sentry issue."
    enabledOnMark = "sentry.issue"
    inputs = {
      issue = { type = "string", default = "$${{ task.marks[\"sentry.issue\"] }}" }
    }
  }
}

The mark kind must start with the integration's name, else the definition is rejected with tool <integration>.<tool> can be enabled only on a mark of its own integration, whose kind starts with <integration>.. When no event and no binding of the integration marks a task with that kind, the definition gives a warning at tools.<tool>.enabledOnMark: names <kind>, but no event or binding of the integration marks a task with it.

Spotlight finds these tools again each time a task's run continues, after an answer or a message. The run gets the tools that the task's marks enable at that time, and loses the ones they no longer enable. Its agent is told which tools it gained and which it lost. Thus a run that started before the task had the mark, or before the integration had the tool, has the tool from its next turn.

A chat run has no task, so it has the tool only when its agent lists it. The station config that a run records, and that Insights compares, lists only the station's own tools, not the tools enabled on a mark.

For an integration with connection.oauth2, the answer to a tool call carries actingAs beside output: whose connection the call used, as actsAs (team or requester), personId (for a requester) and linkedAccount, the account name on the service. spotlight tools call prints only the output. See Acts as.

A tool that a station enables or a hook matches or calls cannot be removed from the definition; the update fails with 409.

Input schemas

Before a call reaches the service, Spotlight checks each input against its schema. These keywords are kept: type (one or a list of string, number, integer, boolean, object, array, null), enum, const, properties, required, additionalProperties (as a boolean), items, anyOf, oneOf, allOf (merged into one object), description, default, examples, minimum, maximum, minLength, maxLength, pattern and format. Others are dropped. pattern and format are kept for the agent to read and not checked. A schema is read 8 levels deep.

A value given as text, as a command-line flag gives it, is read as the input's type first: a number from its decimal digits (not 0x10), true or false, and a list or object from its JSON. A call whose input does not fit is rejected before anything is sent, naming where:

MessageCause
<tool> needs <input>A required input was not given.
<tool> takes <input>, and <where> <why>An input does not fit its schema, as in linear.issue-create takes input, and input.teamId is not text.

<why> is one of is not <type>, is not one of <values>, is not <value>, needs <field>, takes no <field>, is shorter than <n> characters, is longer than <n> characters, does not match <pattern>, is less than <n>, is more than <n>, is none of the shapes it may take, and is not JSON for a value that is not JSON or nests more than 64 levels.

A person who changes a call's inputs while approving it is checked against the same schemas. See Changed inputs.

API specs

openapi and graphql name an API spec: a document that lists an API's operations and what each takes. Spotlight reads it and offers one tool for each operation, beside the tools in tools. A definition has at most one of the two. See Generate tools from an API spec.

openapi = {
  url      = "https://petstore3.swagger.io/api/v3/openapi.json"
  baseUrl  = "https://petstore3.swagger.io/api/v3"
  revision = "1"
  auth     = { secrets = ["secret.PETSTORE_KEY"] }
  tools = {
    include  = ["*pet*"]
    exclude  = ["delete-*"]
    approval = { "update-pet" = false }
  }
}

openapi

FieldTypeDefaultDescription
urlstringnoneWhere the spec is read from, as JSON or YAML. Exactly one of url or document.
documentobjectnoneThe spec written out in full.
baseUrlstringnoneWhere every generated call is sent. Without it, each operation's first server, else its path's, else the spec's, with variables at their defaults and read relative to url; with no server at all, the root of url.
revisionstringnoneAny text. A change makes Spotlight read the spec again.
authobjectnoneAs a request's auth. Sent with every generated call, and with the fetch of the spec when it is on the host of baseUrl.
toolsobject{}Which tools are generated, and which ask first. See Choosing tools.

Spotlight reads OpenAPI 3.0 and 3.1. An openapi with both or neither of url and document is rejected with is read from a url, or written out in full as its document, but not both.

graphql

FieldTypeDefaultDescription
urlstringrequiredThe endpoint. Generated calls are sent to it as POST. Without document, Spotlight reads the schema by requesting it from the endpoint (introspection).
documentstringnoneThe schema in GraphQL's schema language, read in place of a request to the endpoint.
depthinteger21 to 5. How many levels of fields a generated call selects in its answer.
revisionstringnoneAny text. A change makes Spotlight read the schema again.
authobjectnoneAs a request's auth. Sent when Spotlight requests the schema, and with every generated call.
toolsobject{}See Choosing tools.

A generated call selects, at each level, every field that takes no required argument: scalar and enum fields at every level, and fields with fields of their own while depth allows. Input objects in arguments are followed 3 levels deep; deeper ones read as any object.

Choosing tools

FieldTypeDefaultDescription
includearray of strings[]Patterns. When set, only operations whose tool name matches one are offered.
excludearray of strings[]Patterns. Operations whose tool name matches one are not offered.
approvalmap of tool name to object or false{}An object with because makes that tool ask a person first, who is shown the text. false: the tool never asks.

A pattern is a tool name in lowercase letters, digits and -, where * matches any run of characters. Anything else is rejected with is a tool name in lowercase words joined by dashes, with * for any run of letters, as in *-issue*.

A tool in tools with the same name as a generated one is offered in its place. A key of approval that names no generated tool gives a warning: names <key>, but no operation of its <OpenAPI spec, GraphQL schema or MCP server> has that name.

At most 1,000 tools are generated, counted after include, exclude and the tools in tools. More is rejected at <openapi, graphql or mcp>.tools with offers <n> tools from its <OpenAPI spec, GraphQL schema or MCP server>. A station can choose between at most 1000 tools. Please name the tools to offer in <openapi, graphql or mcp>.tools.include.

Generated tools

Each OpenAPI operation, and each GraphQL query and mutation field, becomes a tool:

PartFrom
NameThe operationId, or the GraphQL field's name, in lowercase words joined by dashes: findPetsByStatus is find-pets-by-status, and issueCreate is issue-create. An operation without an operationId is named from its method and path: GET /store/inventory is get-store-inventory.
DescriptionThe operation's summary, else its description, else its method and path; for GraphQL, the field's description, else query <field> or mutation <field>. At most 1,000 characters.
InputsThe operation's path, query and header parameters, and the GraphQL field's arguments, each by its own name, as in petId or team_id, with its JSON Schema. A JSON request body is the input body.
ApprovalOpenAPI POST, PUT, PATCH and DELETE, and GraphQL mutations, ask a person first, with the reason It changes data in <name>., where <name> is the definition's name, else integration. tools.approval overrides it.
OutputFor OpenAPI, the response's JSON. For GraphQL, data.<field> of the answer; an answer with errors fails the call. An answer over 4 MB fails the call with it is larger than the 4 MB Spotlight reads from a tool.

OpenAPI schemas are followed 8 levels deep, and each operation's input schemas are cut short after 4,000 schema nodes; deeper parts read as any value. Only $refs inside the spec are followed; any other reads as any value. Spotlight sends the accept, content-type and authorization headers itself, so header parameters by those names are not inputs. An optional parameter or body a tool cannot send is left out.

Every request, written or generated, follows at most 5 redirects. Each goes only to a host that the deployment allows and never from https to http, and credentials are not sent to a host other than the request's own. A generated tool's call over the workspace's rate limit fails as in Requests.

An operation that gets no tool gives a warning at openapi or graphql, as skips <operation>. <reason>:

ReasonCause
Another operation is also called <name>An earlier operation has the same tool name. The first is kept.
It has no name that a tool can takeIts operationId, method and path, or field name give no tool name.
It needs its <in> parameter <name>, which a tool cannot sendA required cookie parameter, a required accept, content-type or authorization header, or a required parameter whose name is not letters, digits, _ and -, such as $filter.
One of its parameters cannot be readA parameter is not an object with name and in, or its $ref points nowhere.
It takes <name> twiceTwo parameters in different places share a name.
It takes a parameter called body as well as a bodyA parameter named body beside a JSON request body.
It sends a body that is not JSON. A tool cannot send such a body yetA required request body with no JSON media type.
It takes <name>, which a tool cannot takeA GraphQL argument whose name a tool input cannot have.
It takes "<name>", which a tool cannot takeAn input named json, or not letters, digits, _ and -.
It calls <host>. Spotlight injects the token of the connection only for the host of the spec or the host that baseUrl namesWith auth.oauth2 and no baseUrl, the operation's server is on another host than the spec.
It needs approval and takes intent, an input that Spotlight reserves for the agent to say what it wants to do. To offer it, switch its approval off in <openapi or graphql>.tools.approvalThe operation asks a person first and has an input named intent. With its tools.approval set to false it is offered.

Reading the spec

Spotlight reads the spec when the integration is created, and keeps what it read. It reads it again only:

  • when an update changes url, document, baseUrl, revision, depth, or whether auth is oauth2 or secrets;
  • on any update after a read that failed;
  • when the team's connection to the integration is made over OAuth.

A tool call never reads it.

The spec is fetched with GET, and a GraphQL schema with an introspection POST. Spotlight sends auth with the fetch only to the API's own host: the host of baseUrl for openapi, and of url for graphql. Without baseUrl, an OpenAPI spec is fetched without auth. With auth.oauth2, the fetch carries the team's connection, even for a requester integration. The fetch and every redirect go only to hosts that the deployment allows, as in Calls out of Spotlight. Limits and timeouts gives the size and time Spotlight allows.

A spec that cannot be read does not make the definition fail. spec.problem says why, and the same reason is a warning at <openapi or graphql>.url, or at .document when that is given. The tools of the last read that succeeded stay offered; before any such read, none are. Problems include:

ProblemCause
could not be read: <host> answered <status>The fetch did not succeed.
could not be read: <host>: <code>The host could not be reached, as in ECONNREFUSED or ENOTFOUND.
could not be read: Outbound call to <host> blocked. Host is not on the allowed list.The fetch, or a redirect, went to a host not on the allow-list.
could not be read: Outbound call to <host> blocked. The address is ... or could not be read: Outbound call to <host> blocked. The host resolves to <address>, ...The fetch, or a redirect, went to a blocked address.
could not be read: Outbound call to <host> blocked. redirected more than 5 timesToo many redirects.
could not be read: Outbound call to <host> blocked. is where an https request was redirected to over plain http, which Spotlight does not followA redirect from https to http.
is larger than the 64 MB Spotlight readsThe spec is too large.
took longer than 30 seconds to readThe fetch was too slow.
took longer than 30 seconds to make sense ofReading the operations was too slow. At most 2 specs are read at once on each control plane server; one that waits for its turn waits within the same 30 seconds.
is not JSON or YAML Spotlight can read: <error>An OpenAPI spec does not parse: as JSON when it starts with { after any leading whitespace, else as YAML with at most 100 aliases.
is not an OpenAPI specAn OpenAPI spec parses to something other than an object.
could not be made sense of: <error>Reading the operations of an OpenAPI spec or a GraphQL schema failed with an unexpected error, or needed more than the 1,024 MB of memory it is given.
is a Swagger 2 spec. Spotlight reads only OpenAPI 3. Please convert it to OpenAPI 3swagger: "2.0".
is not an OpenAPI 3 spec. An OpenAPI 3 spec says openapi: 3.0 or 3.1No openapi: 3.x.
names no server to call. Please add a baseUrl to the openapi blockNo baseUrl, no server, and no url.
names the server "<server>", which is not a web address. Please add a baseUrl to the openapi blockNo baseUrl, and the spec's server cannot be made a web address.
is not a GraphQL schema Spotlight can read: <error>The answer or document is not a GraphQL schema.

Spec

FieldTerraformTypeDescription
kindkindstringopenapi, graphql or mcp.
hashhashstring or nullThe SHA-256 of the last read that succeeded. null when none has.
readAtread_atstringWhen the spec was last read, in RFC 3339.
problemproblemstring or nullWhy the latest read failed. null when it succeeded.
toolstoolsintegerHow many of the integration's tools were generated from it.

An export writes the openapi, graphql or mcp block as part of the definition, and each secret its auth names as a reference to that spotlight_secret.

MCP servers

mcp names a remote MCP server. Spotlight lists the server's tools and offers one tool for each, beside the tools in tools, and makes every call itself. See Call a remote MCP server.

connection = {
  oauth2 = { discover = true }
}
mcp = {
  url  = "https://mcp.acme.example/mcp"
  auth = { oauth2 = { connection = true } }
  tools = {
    exclude  = ["delete-*"]
    approval = { "create-comment" = false }
  }
}

mcp

FieldTypeDefaultDescription
urlstringrequiredThe server's endpoint. Spotlight speaks MCP's streamable HTTP transport to it.
authobjectnoneAs a request's auth. Sent when Spotlight lists the tools and with every call, only to the host of url.
toolsobject{}Which tools are offered, and which ask first. See Choosing tools.

Server tools

PartFrom
NameThe tool's name in lowercase words joined by dashes: search_issues is search-issues, and createIssue is create-issue. Spotlight calls the server's tool by its own name.
DescriptionThe tool's description, else its title, else annotations.title, else Use <tool>. At most 1,000 characters, passed to agents as written.
InputsEach property of the tool's inputSchema, by its own name, with its JSON Schema. A property in required is a required input.
ApprovalNone for a tool whose annotations.readOnlyHint is true, unless destructiveHint is also true. Every other tool asks a person first, with the reason It changes data in <name>., including a tool with no annotations. tools.approval overrides it.
OutputThe result's structuredContent. Without it, a single text content, read as JSON when it is JSON and as text when not. Otherwise the whole content array.

A tool the server lists that gets no tool gives a warning at mcp, as for an API spec: skips <tool>. <reason>, where the reason is It has no name that a tool can take, It takes <name>, which a tool cannot take, Another operation is also called <name>, or a reason its input schema cannot be read for. The server's resources and prompts are not offered.

Listing the tools

Spotlight lists the tools when the integration is created, and again:

  • when an update changes url, or whether auth is oauth2;
  • on any update after a listing that failed;
  • when the team's connection to the integration is made over OAuth;
  • when the last listing is older than the deployment's SPOTLIGHT_MCP_RELIST_SECONDS, 600 by default, checked every minute. One control plane server claims each such listing, moving spec.read_at on as it does, and the integration's version does not change.

The listing carries the team's connection when auth is oauth2, even for a requester integration. A listing answered 401 refreshes the connection once and lists again with the new token, as in Refresh. A listing that fails keeps the tools of the last one that succeeded, as for a spec; see Reading the spec. A listing that succeeds without a tool the integration offered stops offering it, and the workspace's configuration changes record the change, with each tool no longer offered in details.orphanedTools.

Problems a failed listing gives in spec.problem include:

ProblemCause
could not be read: <host> answered <status>The server answered with an HTTP error, as 401 before the team is connected.
could not be read: <host> answered: <error>The server answered with an MCP error.
could not be read: <host>: <code>The server could not be reached.
could not be read: Outbound call to <host> blocked. Host is not on the allowed list.The server, or a redirect, is on a host not on the allow-list.
could not be read: Outbound call to <host> blocked. The address is ... or could not be read: Outbound call to <host> blocked. The host resolves to <address>, ...The server, or a redirect, is at a blocked address.
could not be read: Outbound call to <host> blocked. redirected more than 5 timesToo many redirects.
could not be read: Outbound call to <host> blocked. is where an https request was redirected to over plain http, which Spotlight does not followA redirect from https to http.
could not be read: <host> answered without a statusThe server's answer failed without an HTTP status.

Calling a tool

Spotlight keeps MCP sessions for each server, team, integration, kind of auth, connection owner and access token, and never shares one between owners. A session carries one call at a time; calls made at once each get a session of their own. A session unused for 5 minutes is ended at the server and closed. When the server answers 404 because it no longer has the session, Spotlight starts a new one and calls once more. Spotlight opens no stream for the server to send on outside a call: the GET stream of the streamable HTTP transport is not opened. A call answered 401 with auth.oauth2 is refreshed and retried once, as in Refresh.

Spotlight declares no client capabilities and answers no request from the server other than ping. A server that asks a question in the middle of a call (MCP elicitation) makes the call fail with using <tool>: the MCP server asked a question in the middle of the call. Spotlight does not pass such questions on to a person, so the call failed. A result marked isError fails the call with using <tool>: the MCP server answered with an error: <text>, cut at 500 characters. An answer over 4 MB fails the call with it is larger than the 4 MB Spotlight reads from a tool. A call over the workspace's rate limit waits up to 5 seconds for a free request. If none becomes free, the call is not sent, and fails with calling a service: this workspace sends more than <limit> requests each second to other services.

On

on maps a task, chat, inbox request or notice event to a list of bindings. Spotlight runs the bindings of an event in their order. A binding that fails does not stop the next one. The events are:

EventHappens when
task.openedA task is opened by a happening from outside Spotlight.
task.pull-request-openedA task's pull request is opened.
task.askedA task asks a person.
task.finishedA task reaches the end of its line, or a person moves it to a completed station.
task.failedA run of a task fails. The task stays open, and the event can happen again for the same task.
chat.startedA chat with marks starts. reply.body is "".
chat.dispatchedA run is queued for a chat with marks, for its first message or for the messages that came after the last run. reply.body is "".
chat.repliedA chat with marks has something to say: the last words of a run with its open proposals, a run that could not finish, a proposal that became a task, or a dismissed proposal.
chat.refusedA happening with opens.chat could not start or continue a chat, or could not reopen a task. reply.body says why.
chat.acknowledgedA happening with opens.chat reopened a finished task that has its marks. reply.body is "".
inbox-request.openedA request about a task first opens in the inbox: proposed memories or a station alert. Bindings do not run again when the request opens again.
notice.raisedA notice of the team that is addressed to nobody is first raised, such as a config pull request that Spotlight opened. Bindings do not run again when the notice opens again.

Binding:

FieldTypeDefaultDescription
actionstringrequiredThe action to run. It must be defined in actions.
tomap of name to string{}Values the action reads in target. Can read task and ask for a task event, chat and reply for a chat event, task and request for an inbox request event, and notice for a notice event. Each value is an expression.
routesmap of name to string{}Keyed by line key. When to gives no channel, the value for the task's line is used as target.channel. A binding of a chat or notice event cannot have routes.
markarray of objects[]Marks kept on the task after the action succeeds. Can read response and capture. find is not read here. A binding of a chat or notice event cannot have mark. A later binding of the same event does not see these marks.

A binding runs only when target contains a channel or a thread. Otherwise nothing is sent.

on = {
  "task.finished" = [
    {
      action = "react"
      to = {
        channel = "$${{ task.marks[\"slack.channel\"] }}"
        message = "$${{ task.marks[\"slack.message\"] }}"
        emoji   = "$${{ \"white_check_mark\" }}"
      }
    },
    {
      action = "post-notice"
      to = {
        channel = "$${{ task.marks[\"slack.channel\"] }}"
        thread  = "$${{ task.marks[\"slack.thread_ts\"] }}"
        text    = "$${{ \"The task “\" + task.title + \"” is complete.\" }}"
      }
    },
  ]
}

Secrets in expressions

No expression may read a secret. An expression containing secret. or secret[ is rejected with reads a secret's value. No expression may read a secret. Please name the secret in auth.secrets, and Spotlight injects it for the hosts it is bound to.

Secret references are not checked against the workspace's secrets when the definition is written. A request that uses a missing secret fails with Secret <NAME> not found. Please create it first.

Errors and warnings

A definition that does not match the schema, an expression that does not parse, and a broken rule above are errors: the write fails with 422 and each problem is listed at its path, as in webhook.events[0].raise.happening. An expression that parses but does not type-check is a warning: the definition is kept, and the warning is returned in warnings. See Type-checking.

On this page