Integrations
Webhooks and external clients
How any external platform connects to GAOS: register it as a client with its own token, let it put questions in the operator's inbox and read or give the answer, and — for the QA tools — receive every decision by webhook. Then three tutorials: the QA tools, ai-manager, and a new client such as a mobile app.
Placeholders
Hosts are gaos.example.org (GAOS), qa.example.org (the QA tools) and
aim.example.org (ai-manager). A token is written gaos_<32+ random characters>, which
GAOS itself refuses, so an example can never be pasted into production. Mint a real one with
printf 'gaos_%s\n' "$(openssl rand -hex 16)" and keep it in a file only you can read.
Register a client
A client is configuration and a token file, not code. GAOS reads the file named by
GAOS_API_CLIENTS_FILE once at boot: one client per line, five fields separated by spaces plus an
optional sixth, and # starts a comment.
# name kind origin token file products
mobile-app mobile app.example.org /run/secrets/api-client-mobile-app p-8,p-9
chat-bot bot - /run/secrets/api-client-chat-bot p-8
| Field | Rule |
|---|---|
name | 2 to 32 of a-z 0-9 -, starting with a letter; unique. Reserved: qa-tools, back-office, admin, gaos, qa-tool, operator. Items belong to the name, so a name is never reused for someone else. |
kind | the same alphabet; gaos and qa-tool are reserved. It is what an answer's source.kind says. |
origin | the client's registered host name (optionally :port), or -. Recorded on every answer it gives; it may not be the QA tool's origin or the deployment's back-office label. |
token file | a regular file, mode 600, holding one gaos_ token of 32 or more letters and digits. A file group or others can read is refused. |
products | comma-separated GAOS product ids, or -. A client holding inbox may not list a product the QA token reaches. |
caps (optional) | a comma list over inbox and tasks; absent means inbox, so a five-field line keeps its meaning. inbox reaches the inbox routes below; tasks reaches the external tasks API. An unknown word skips the line. A tasks-only client may share a product with the QA token (v0.61.0, D-099). |
A bad line is skipped and logged by number and reason, never by token: api: clients file line 3: the
token file is unreadable, empty, malformed or readable by others (skipped). A line whose token equals a
built-in token or another client's is skipped by name: api: clients file: mobile-app: its token equals a
built-in token (skipped). The boot line counts what was admitted: api: enabled (admin=true qa=true
qa-products=1 clients=2). A client reaches only the three inbox routes of its own products; any other route
is 403.
Ask, poll and answer
Three calls. The full field rules and every status code are in the QA sync API reference; this is the shape.
# header-file holds one line: Authorization: Bearer gaos_<32+ random characters> # ask: 201 for a new item, 200 for the same externalId again (nothing written) curl -sS -X POST -H @header-file -H "Content-Type: application/json" \ https://gaos.example.org/api/v1/products/p-8/inbox \ -d '{"externalId":"order-17:refund","question":"Refund order 17 in full?","expiresInHours":48}' # poll: status is open, answered or expired; source says who answered curl -sS -H @header-file https://gaos.example.org/api/v1/products/p-8/inbox/order-17:refund # answer your own item: 200, or 409 / 410 with the item of record curl -sS -X POST -H @header-file -H "Content-Type: application/json" \ https://gaos.example.org/api/v1/products/p-8/inbox/order-17:refund/answer \ -d '{"choice":1,"actor":{"username":"field-agent-4"}}'
Poll gently: a GET a minute is plenty, and an item cannot change after it is answered or expired. The first
answer wins wherever it came from; on 409 or 410 adopt the item in the body.
The answer webhook
When the operator answers one of the QA tool's items, or it expires, GAOS tells the QA tools. Only the QA tools receive it today; a registered client polls (a per-client webhook is not built).
| Value | |
|---|---|
| URL | POST {GAOS_QA_URL}/api/v1/gaos/inbox-answer |
| Headers | Authorization: Bearer <the outbound token, GAOS_QA_TOKEN_FILE>, Content-Type: application/json, Accept: application/json |
| Body | {"externalId","productId","status":"answered|expired","choice":1-4|0,"optionLabel","text","answeredAt"} — choice 4 is the operator's own words, 0 an expiry; answeredAt is unix seconds, the deadline when expired |
| Success | any 2xx; the body is not read. A redirect is refused. |
| Timeout | 15 s per call |
| Retries | 5 attempts: the first within 10 s, then after 30 s, 2 min, 10 min and 1 h; then gave-up |
| Durability | each attempt is an event, so a restart resumes exactly the work left |
Idempotency. Key the receiver on productId + externalId. A retry after a
2xx that GAOS never saw re-sends the same body, and the QA tool's own answer is also sent, so the same decision may
arrive twice or before the 200 of its answer call. After gave-up the item stays readable by
GET, which is the fallback.
The URL rule. GAOS_QA_URL is a base address with no credentials, query or fragment;
https, or plain http only to a loopback or tunnel (10.10.0.0/24) address; never the host of GAOS's
own gateway or database. Anything else leaves the outbound off and logs why.
Verify it
- The back office: the Integrations view shows the API's state, which built-in tokens are set, every registered client, the outbound host, the last webhook delivery and how many wait.
- The boot log:
api: enabled (…)andqa sync: outbound to https://qa.example.org, orqa sync: outbound is off (GAOS_QA_URL is not set). - Health:
GET /api/healthznames the adapter and the runner mode. - A round trip: ask with curl, answer in the back office, then GET the item.
Troubleshooting
| Symptom | Cause |
|---|---|
401 on every call | the token is not one GAOS loaded: wrong file, a typo, or the line was skipped (read the boot log) |
503 on every call | no token at all is configured, or two built-in tokens are equal and the API is disabled |
403 | a client on a non-inbox route, or the admin token answering an item |
404 on an item | a product the token does not reach, or another client's item |
409 id-taken | another client already uses that externalId; choose another |
| No webhook arrives | GAOS_QA_URL or the outbound token is unset or refused; the Integrations view says why. Deliveries wait and are sent once it is configured. |
Last delivery reads retry or gave-up | the QA tools answered non-2xx or could not be reached; the reason is on the line |
| A client is missing from the view | its line was skipped; the boot log says which and why |
Tutorials
Three tokens, three purposes, all different. GAOS holds each in a file, mode 600; the QA tools hold the matching value in their environment.
| Purpose | GAOS (file) | QA tools (env) |
|---|---|---|
| The QA tools call GAOS | GAOS_API_QA_TOKEN_FILE | GAOS_API_TOKEN |
| GAOS calls the QA tools (sync and webhook) | GAOS_QA_TOKEN_FILE | GAOS_INBOUND_TOKEN |
| Seeding and catalog import, by an operator | GAOS_API_ADMIN_TOKEN_FILE | not used |
- Seed the product:
deploy/seed/seed.sh --dir <seed dir> --base <api url>. It prints the product id. - Mint the three tokens into their files on the GAOS host, mode 600.
- Set
GAOS_API_QA_PRODUCTSto the product id,GAOS_QA_URLto the QA tools' base (https://qa.example.org, or the tunnel address), andGAOS_QA_ORIGINto their public host name (qa.example.org) — recorded on every answer they give. Redeploy GAOS. - On the QA tools:
GAOS_API_URL=https://gaos.example.org/api/v1, the two tokens above, then turn the product's GAOS integration on with the GAOS product id. - Verify in the back office's Integrations view, then on the product's QA tab.
ai-manager runs every model turn; GAOS needs two credentials and two switches.
- The chat login: a JSON file
{"login_id":"…","secret_key":"…"}, mode 600, named byGAOS_AIM_CHAT_AUTH_FILE. - The admin key: a file holding only the key, named by
GAOS_AIM_ADMIN_KEY_FILE. Without it, workspace provisioning, Blueprint sync and conversation prune fail. GAOS_AIM_URL=https://aim.example.organdGAOS_MODEL_MODE=aimanager. At boot GAOS asksGET /v1/providersand refuses to start unlessclaudeis available.GAOS_RUNNER=manual: only a card the operator moves on the board runs;onlets the scheduler dispatch every ready task; unset is off.- Publish and sync a product's Blueprint: the first sync provisions its workspace
(
gaos-<tenant>-<product>). - Verify: the Integrations view shows the gateway host, the boot provider check and the last turn.
Every call and status is in the ai-manager REST reference.
A mobile app that asks a supervisor to approve a refund, and shows the decision.
- Mint a token:
printf 'gaos_%s\n' "$(openssl rand -hex 16)" > deploy/stacks/prod.api-client-mobile-app, thenchmod 600it. - Add a line to the clients file:
mobile-app mobile app.example.org /run/secrets/api-client-mobile-app p-8. - Mount the clients file and the token file read-only into the dashboard, set
GAOS_API_CLIENTS_FILE, restart, and read the boot line:clients=counts it. - From the app's backend, ask (curl above), then poll the item until
statusisansweredorexpired. - To let the app's user answer instead, call the answer route with their handle as
actor.username.
Keep the token on a server you control, never in the app binary: anyone holding it can ask and answer as the client.