The CI use case is one question: did the content change we just shipped make our brand harder to find in AI answers? The answer is a step that prints machine-readable output and exits non-zero when a number crosses a line. This page is the complete recipe, with the reasoning for each line, so you can adapt it without breaking the guarantees.
What you need
- An organization key with
scans:read,scans:writeandreports:read, created in the dashboard or with a plainwam auth loginon your machine, stored as a CI secret namedWAM_TOKEN. Not an account-wide key: a secret that every job and collaborator can read should reach exactly one organization. Nothing on the server can enforce that; it is a rule for whoever creates the secret. - The organization and workspace slugs, either as environment variables or in a committed
wam.json. - A threshold: the score below which the job should fail. Run a few scans first and pick a line below the noise. A scan of 24 answers has a wide confidence interval, and a threshold inside it will fail for no reason.
- Credits. A scan costs
prompts x modelscredits (24 on Single Brand, which grants 48 a month). A weekly schedule on Single Brand spends the whole allowance; a daily one needs a bigger plan. The estimate step below fails early and free when the balance is short.
GitHub Actions
# .github/workflows/ai-visibility.yml
name: AI visibility
on:
schedule:
# Weekly, Monday 07:00 UTC. See the cost note above before making this more frequent.
- cron: "0 7 * * 1"
workflow_dispatch:
# Prevents two scheduled runs overlapping. The API would 409 anyway, but this is cheaper.
concurrency:
group: ai-visibility
cancel-in-progress: false
jobs:
scan:
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: read
env:
WAM_TOKEN: ${{ secrets.WAM_TOKEN }}
WAM_ORG: acme
WAM_WORKSPACE: acme-main
steps:
- uses: actions/setup-node@v7
with:
node-version: 22
# Fail early and cheaply if the balance cannot cover a scan. Costs nothing.
- name: Check the balance
run: npx --yes @whereamimentioned/cli@0.1 scan estimate --json
- name: Run the scan
id: scan
run: |
npx --yes @whereamimentioned/cli@0.1 scan run \
--wait --yes \
--fail-under 55 \
--timeout 2400 \
--json | tee scan.ndjson
tail -n 1 scan.ndjson > scan-result.json
- name: Fetch the full report
if: always() && steps.scan.outcome != 'skipped'
run: npx --yes @whereamimentioned/cli@0.1 report get --json -o report.json
- uses: actions/upload-artifact@v4
if: always()
with:
name: ai-visibility
path: |
scan.ndjson
report.json
Why each line is there
@0.1pins the minor. While the package is0.x, a breaking change to the output lands in the minor, so@0would protect nothing and@latestwould protect less. Move the pins to@1on the day1.0.0ships.--yesis mandatory. The CLI detects CI and will not prompt. Without--yes,scan runexits 2 and starts nothing, so no workflow spends credits by accident. The cost is still printed first, so it is in the log whether or not anyone confirmed.- The estimate step runs first and exits 4 when the balance is short, before anything is charged. It also puts the price in the log.
--fail-under 55compares the resulting AI visibility score and exits 7 when it is below. It implies--wait. Put yours on the flag or inwam.jsonasfailUnder.--timeout 2400is below the job'stimeout-minutes. On timeout the CLI exits 1 with the scan id, and the scan keeps running on the server, so the next run (or the report step) still finds it.--json | teekeeps the whole NDJSON stream as an artifact and the last line, the result object, as a one-line summary.- The report step runs
if: always(), so a failed threshold still leaves the full report in the artifact for the person who investigates. - A retried step does not start a second scan. The CLI derives the
Idempotency-Keyfrom the organization, the workspace, the UTC date andGITHUB_RUN_ID, so re-running a failed job follows the scan that already exists instead of paying for another.
Reading the result
The last line of scan.ndjson is the result object:
{"type":"result","id":"3f9c1e42-...","status":"done","creditsSpent":24,"balance":24,"score":61,"presenceRate":0.42,"sov":0.18,"brandCitationShare":0.05,"perModel":[{"model":"GPT-5.5","score":70}],"durationMs":184213}
Earlier lines are {"type":"progress", ...} objects with the scan status as the API returned it. If the run fails while streaming, the last line is {"type":"error", "ok": false, "error": {...}, "exitCode": n} instead.
Exit codes the job can end with, from scan run:
| Exit | Meaning | What to do |
|---|---|---|
| 0 | Scan done, score at or above the threshold. | Nothing. |
| 7 | Scan done, score below the threshold. | Open report.json; the per-model block and wam scan evidence --mentioned false show where the brand disappeared. |
| 4 | Not enough credits (from the estimate step). | Top up or change plan at the billing page the message prints. |
| 2 | --yes missing, or no workspace or organization resolved. |
Check the env block or wam.json. |
| 3 | The key was revoked, expired, lacks a scope, or the plan lapsed. | Create a new key, or check billing. |
| 5 | Rate limited: a key may start 3 scans per hour. | Two workflows share a key, or a manual run collided with the schedule. |
| 6 | The scan itself failed. | The message carries the scan id and the error; the dashboard shows the same. |
| 8 | A scan was already running and --no-follow was passed. |
Not used in the recipe above; the default follows the running scan. |
| 1 | Timeout, network failure or a server error. | The scan id is in the output; the report step still fetches the latest completed report. |
The full table is on the CLI overview.
GitLab CI
ai-visibility:
image: node:22
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == "web"
timeout: 45m
variables:
WAM_ORG: acme
WAM_WORKSPACE: acme-main
script:
- npx --yes @whereamimentioned/cli@0.1 scan estimate --json
- npx --yes @whereamimentioned/cli@0.1 scan run --wait --yes --fail-under 55 --timeout 2400 --json | tee scan.ndjson
after_script:
- npx --yes @whereamimentioned/cli@0.1 report get --json -o report.json || true
artifacts:
when: always
paths: [scan.ndjson, report.json]
Set WAM_TOKEN as a masked, protected CI variable. The idempotency key is derived from CI_PIPELINE_ID, which is the id that survives a retry (a retried job gets a new CI_JOB_ID inside the same pipeline), so retrying the job follows the original scan.
Any other runner
The CLI needs nothing but Node 20.19 or newer, three environment variables and --yes:
export WAM_TOKEN=... # from your secret store
export WAM_ORG=acme
export WAM_WORKSPACE=acme-main
npx --yes @whereamimentioned/cli@0.1 scan estimate --json
npx --yes @whereamimentioned/cli@0.1 scan run --wait --yes --fail-under 55 --timeout 2400 --json
If your runner sets none of GITHUB_RUN_ID, CI_PIPELINE_ID or CI_JOB_ID, the derived idempotency key falls back to a random value per invocation, so a retry would start a second scan. Pass your own with --idempotency-key built from something stable, such as the pipeline id your system does expose plus the date:
npx --yes @whereamimentioned/cli@0.1 scan run --wait --yes --fail-under 55 \
--idempotency-key "ci:${MY_PIPELINE_ID}:$(date -u +%F)"
The key must be 1 to 128 characters from A-Z a-z 0-9 _ . : -.
Using wam.json instead of variables
Commit this next to the workflow and drop WAM_ORG, WAM_WORKSPACE and --fail-under:
{
"$schema": "https://whereamimentioned.com/schema/wam.config.json",
"org": "acme",
"workspace": "acme-main",
"failUnder": 55
}
The CLI finds it by walking up from the working directory. The token still comes from WAM_TOKEN; the file has no field for it and refuses one.
Gating a deploy
A scan takes minutes and spends credits, so it does not belong in the pull-request path. The pattern that works is a scheduled scan plus a cheap gate on the latest finished report in the deploy job:
npx --yes @whereamimentioned/cli@0.1 report get --json --fail-under 55
report get reads the latest completed scan, spends nothing, and exits 7 below the threshold. It never starts a scan.
Things the CLI will not do in CI, on purpose
- Retry a scan. There is no
--retryand no automatic re-run. Every scan is started by exactly one explicit command. - Choose a bigger or smaller scan. Mode and repetitions are the plan's; there is no flag.
- Buy credits. Exit 4 prints the billing page and stops.
- Prompt. In CI the CLI is non-interactive; anything that would need an answer exits 2.
- Print the token. Not under
--debug, not in an error.