Connect an API
When. The station reads or writes at a tenant: its catalogue, its slots, its orders. Every tool of a station is an operation of an API declared here.
Steps
- Name the API and give its spec (
openapi_url) and its address (base_url): a public address (a domain name). A local or private address is refused at the check. - List the operations it uses, and only those, under
operations, each by itsoperationIdas the spec writes it, withaccess: read(changes nothing at the tenant) oraccess: write(changes something: only a confirmed submit calls it). - Choose the authentication (
auth.type):none: a public API;api_key:key_name(the header or parameter that carries the key),key_location(headerorquery) andkey_env;bearer:token_env(sent asAuthorization: Bearer …);basic:username_envandpassword_env.
- Grant every operation to a profile (
profiles): everything is closed by default. See Decide who may do what. - Check the config, then publish. If the API reads a key, save it on the station's key page
(the
key-pageskill of the Convoy station gives its link), then confirm the same publication again.
The example
connect-an-api.yaml
# Connect an API: its OpenAPI, its address, the operations the station may reach, and its key —
# the config names the variable, the value is saved on the station's key page, never here.
# Replace api.example.com by the API.
station:
id: shop-catalogue
name: Shop Catalogue
global:
language: en
currency: EUR
locale: en-GB
domain:
domain_type: retail
entity_name: product
entity_name_plural: products
voice:
tone: friendly
persona: "a shop assistant who knows the catalogue"
rules:
- "Never invent a product or a price: everything comes from the tool."
apis:
- name: shop
openapi_url: https://api.example.com/openapi.json # the spec Core reads the operations from
base_url: https://api.example.com # where the calls go: a public address
operations: # an allowlist: nothing else is reachable
- {id: searchProducts, access: read} # declared, never guessed from the verb
auth:
type: api_key
key_name: X-API-Key # the header the API reads the key from
key_location: header
key_env: SHOP_API_KEY # a NAME: the value goes on the key page
profiles: # everything is closed until granted
everyone:
when: "true"
grants: [shop.searchProducts]
skills:
- name: products
cognitive:
objective: "answer about the shop's products: what exists, its price, whether it is in stock"
params:
q: {type: text, set_by: [llm]} # the person's words, given by the model
invoke:
method: searchProducts
args: {q: "$params.q"}
The pitfalls
- The key is never in the config.
key_envnames a variable; its value is pasted on the key page, never in the file nor in the conversation. Akey:ortoken:written inauthis refused (unknown key). - A variable named with no value saved refuses the publication, naming the variable: the station is registered without starting. Save the key, then publish again.
- A known production key (
sk_live_,rk_live_) is refused: stations run on test accounts. - The key goes to its hosts only. It is saved with the hosts of the
base_urls that read it; a config that movesbase_urlto another host is refused. accessis declared, never guessed from the HTTP verb: a search is often a POST. Awriteoperation in a skill'sinvokeis refused ("a write is reserved"); so is a submit through areadoperation (it would file nothing).- An operation missing from
operationscannot be reached, even if the spec describes it. Do not list a write that nothing uses. - An operation no profile is granted is refused at load: it would be refused to everyone.
- An argument the operation requires that the skill does not send refuses the station: declare
it in
paramsand send it throughinvoke.args.
What Core says, and the fix
Each sentence below is Core's own, as it answers today (a test keeps them true):
- "names capability 'searchProduct', which does not exist" — fix: write the
operationIdexactly as the spec does (searchProducts), and list it underoperations. - "and no profile is granted it — closed by default, it would be refused to everyone" — fix:
add
<api>.<operationId>to a profile'sgrants. - "auth.key: Extra inputs are not permitted" — fix: never a key in the config:
key_envnames it, its value goes on the key page.
Reference: Sources, Your APIs' keys.