Integrations

External tasks API

An outside platform can ask GAOS for work without signing in to the back office: a pull-request review, unit tests for a merged pull request, an e2e automation, or an e2e run. GAOS plans the card on the product's pull-request lane, starts the agent when the product allows it, and the platform polls the card until it is done (D-099). This page is also a markdown download.

Placeholders

The host is gaos.example.org, the product p-2, the repository acme/backend and the client plat-a. The token is written $GAOS_TOKEN; keep the real one in a file only your server can read.

What it is for

A platform that already knows about a pull request — a task manager, a CI job, a chat bot — can hand the work to GAOS and follow it. Four kinds of work:

kindWhat GAOS doesWorked by
pr-reviewReviews an open pull request and posts the review as a comment.the PR reviewer agent
unit-testWrites unit tests for a merged pull request.the unit-test agent
automation-createAsks the QA tool to write the e2e automation a pull request names.the QA tool
automation-runAsks the QA tool to run one automated case, or every one (*).the QA tool

A card for a pull request is the same card Brain Town's event would plan: same key, same title, same labels plus source:api. If it already exists, the API answers that card instead of planning a second one.

Since v0.64.0 a card the API plans also carries source:api, last in labels, so the board can filter the cards a client created (Where a card came from). A card the API adopts from Brain Town keeps its labels unchanged. Match a label by membership, never by position.

Ask the operator for a client

A client is a name, a token and a list of products, set up by the GAOS operator. Ask for a client with the tasks capability on your products; the operator gives you the client name and the token. A client with only tasks cannot use the inbox routes, and one with only inbox cannot use these. Every call sends the token as a bearer:

bash
export GAOS=https://gaos.example.org/api/v1
export GAOS_TOKEN="$(cat ~/.config/plat-a/gaos.token)"

Create a PR review

bash
curl -sS -X POST "$GAOS/products/p-2/tasks" \
  -H "Authorization: Bearer $GAOS_TOKEN" -H "Content-Type: application/json" \
  -d '{"kind":"pr-review","externalId":"plat-4711","pr":"acme/backend#42","review":"auto","dispatch":true}'

The route is POST /api/v1/products/{id}/tasks. The body is read strictly (at most 16 KiB; an unknown field is refused):

FieldRule
kindpr-review, unit-test, automation-create or automation-run.
externalIdRequired: your own id for the request, 1 to 64 of letters, digits, . _ -, starting with a letter or digit. Sending it again returns the same card.
prowner/repo#n. Required for pr-review, unit-test and automation-create; refused for automation-run. The repository must be one of the product's.
reviewauto (default) or manual; pr-review only. manual labels the card for a person, and it is never dispatched.
caseCodeRequired for automation-run: * or a case code such as TC-OUTREG-004.
dispatchDefault true: start the agent. It matters for pr-review and unit-test only.

The answer is 201 for a new card, or 200 with "created":false for a card that already existed — one you asked for before, or one Brain Town planned for the same pull request. Adopting an existing card changes nothing on it: not its label, not whether it starts.

json
{"taskId":"wf-pr-p-2-acme-backend-42-pr-reviewer","created":true,"status":"PENDING","column":"backlog",
 "labels":["pr-review:auto","source:api"],"dispatch":"auto"}

Poll it

bash
curl -sS "$GAOS/products/p-2/tasks/wf-pr-p-2-acme-backend-42-pr-reviewer" -H "Authorization: Bearer $GAOS_TOKEN"
curl -sS "$GAOS/products/p-2/tasks?externalId=plat-4711" -H "Authorization: Bearer $GAOS_TOKEN"

The routes are GET /api/v1/products/{id}/tasks/{taskId} and GET /api/v1/products/{id}/tasks?externalId=. Both answer the object above plus updatedAt (unix seconds) and reason: held (a person must take over), blocked, failed, or empty. You see only the cards you asked for; any other id is 404. A card moves on its own as the agent works: Backlog, Ready, Working, then Review or Done.

The other kinds

bash
# unit tests for a merged pull request
curl -sS -X POST "$GAOS/products/p-2/tasks" -H "Authorization: Bearer $GAOS_TOKEN" -H "Content-Type: application/json" \
  -d '{"kind":"unit-test","externalId":"plat-4712","pr":"acme/backend#42"}'
# the e2e automation a pull request names (its "QA-case:" line)
curl -sS -X POST "$GAOS/products/p-2/tasks" -H "Authorization: Bearer $GAOS_TOKEN" -H "Content-Type: application/json" \
  -d '{"kind":"automation-create","externalId":"plat-4713","pr":"acme/backend#42"}'
# run one automated case
curl -sS -X POST "$GAOS/products/p-2/tasks" -H "Authorization: Bearer $GAOS_TOKEN" -H "Content-Type: application/json" \
  -d '{"kind":"automation-run","externalId":"plat-4714","caseCode":"TC-OUTREG-004"}'
# cancel that run
curl -sS -X POST "$GAOS/products/p-2/tasks/wf-pr-p-2-qa-run-1/cancel" -H "Authorization: Bearer $GAOS_TOKEN"

A pr-review needs an open pull request, a unit-test a merged one. Drafts, forks and pull requests by people outside the repository are refused. Cancel, POST /api/v1/products/{id}/tasks/{taskId}/cancel, works only on an automation-run card you created; a card for a pull request belongs to the operator.

What dispatch answers

CardRunner onRunner manual, product listed for autorunRunner manual, not listed
agent kind, dispatch trueschedulerautooperator
agent kind, dispatch falsescheduleroperatoroperator
review: manualmanual-reviewmanual-reviewmanual-review
automation-*qa-toolqa-toolqa-tool

scheduler: GAOS's scheduler starts it. auto: GAOS starts it within about 15 seconds. operator: it waits in Ready for a person. qa-tool: the QA tool runs it. With the runner off, every request answers 409 runner-off.

Errors

Every error is {"error":"<code>","reason":"<sentence>"}.

StatusCodeWhen
401unauthorizedNo bearer token, or an unknown one.
403forbiddenThe token has no tasks capability, or it is the admin token on a create or a cancel.
404not-foundA product outside your list, or a card you did not ask for.
409runner-offGAOS runs nothing at the moment.
409externalId-reusedThe same externalId with a different body.
409too-many-refsEight clients already follow this card.
409skippedA draft, a fork, a stranger's pull request, a review on one not open, or unit tests on one not merged.
409capYou already have the most open cards allowed.
409daily-capYou created the most cards allowed today (UTC).
409run-in-flightThe product already has an e2e run open.
422invalid-kind, invalid-field, repo-not-ownedThe body breaks a rule above.
429write-in-flightYour previous write has not finished; retry after the Retry-After seconds.
503api-disabled, github-off, qa-offThe API, GitHub or the QA tool is not configured on this GAOS.

Limits

Troubleshooting