> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aiaxoniq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Command line and A2A

> Use the assistant without the dashboard: the oiq command line, and an Agent2Agent (A2A) endpoint other agents can call — both as you, with a personal access token.

Two ways to use aiAxonIQ headlessly, as yourself:

* **`oiq`**, a command line for asking the assistant, calling its tools, and
  reading incidents and logs from a terminal or a script.
* **An Agent2Agent (A2A) endpoint**, so another agent can hand the assistant a
  question, follow the investigation and read the cited answer.

Both act **as the person whose token they hold**: your role, your data access,
your organization's assistant switch and your daily AI allowance apply exactly
as they do in the dashboard. A token never does more than you can.

> [!WARNING]
>
> **The assistant needs a language model.** Without one configured for your
> deployment, a question ends as failed with the reason, as it does in the
> dashboard — see [AI Assistant and Investigate](https://docs.aiaxoniq.com/guides/ai/assistant.md).

## Create a token for the assistant

Under **Settings → Access tokens**, create a token, choose **Choose scopes**, and
tick **Use the AI assistant** (`assistant:run`). It is never part of the
**Read only** or **Read & write** presets, because asking the assistant spends
your daily AI allowance. Add `telemetry:read` and `alerts:read` too if you will
use `oiq logs search` and `oiq incidents list`.

| What you call | Scope the token needs |
| :- | :- |
| `oiq ask`, the A2A endpoint | `assistant:run` |
| `oiq tools list`, `oiq tools call` | `assistant:run` |
| `oiq incidents list` | `alerts:read` |
| `oiq logs search` | `telemetry:read` |

Your role must also read traces, logs and metrics, as for the assistant in the
dashboard. A member limited to their team's services is refused, because an
investigation reads across every service.

What a token cannot do, whatever its scopes: approve a tool call the assistant
wants to make, undo a change, or share an investigation. Those stay with you,
signed in. An investigation waiting for an approval reports that it is waiting.

## The `oiq` command line

`oiq` is a single Go program with no dependencies outside the standard library.
Build it from the repository:

```bash theme={null}
cd services/api-go
GOWORK=off go build -o oiq ./cmd/oiq
```

Sign in once. The token is read from `OIQ_TOKEN` (or pasted on standard input)
and saved, with the URL, in `$XDG_CONFIG_HOME/oiq/config.json` (by default
`~/.config/oiq/config.json`), readable only by you. `oiq` never prints the token.

```bash theme={null}
OIQ_TOKEN=oiqpat_... oiq login --url https://app.example.com
```

`OIQ_URL` and `OIQ_TOKEN` override the saved values, which suits CI.

### Ask the assistant

```bash theme={null}
oiq ask "Which services reported errors in the last hour?"
```

The investigation's steps print to standard error as they happen; the answer,
the trust verdict and the evidence each citation (`[E1]`, `[E2]`…) refers to
print to standard output, followed by the conversation (`context`) and task ids.

| Flag | What it does |
| :- | :- |
| `--mode` | The investigation mode: `general` (default), `incident`, `slo`, `metric`, `trace`, `log`, `deployment`, `error`, `security` |
| `--context <id>` | Ask a follow-up in the same conversation |
| `--task <id>` | Answer the question an investigation is waiting on |
| `--json` | Print the final task as JSON instead, with no step narration |

### The assistant's tools

The read-only tools the assistant itself uses, called directly:

```bash theme={null}
oiq tools list
oiq tools call get_service_health --arg service=checkout
```

`--arg key=value` repeats; a value that is valid JSON (a number, `true`, an
array) is sent as that, anything else as text. The result is printed as JSON.

### Incidents and logs

```bash theme={null}
oiq incidents list --limit 3
oiq logs search error --from now-24h --limit 3
```

`incidents list` takes `--status`, `--severity` and `--limit`; `logs search`
takes `--service`, `--from`, `--to` and `--limit` (at most 200). Every command
takes `--json` for the API's own response.

### Exit codes

| Code | Meaning |
| :- | :- |
| `0` | Success |
| `1` | Usage: a missing argument, an unknown flag, or arguments the server refused |
| `2` | Authentication or authorization: no token, an expired or revoked one, a missing scope, or a role that cannot do it |
| `3` | Anything else: the server failed, the assistant is switched off or out of allowance, or the investigation failed |

## The A2A endpoint

The assistant speaks the [Agent2Agent protocol](https://a2a-protocol.org/v1.0.0/specification/),
version **1.0**, over its JSON-RPC 2.0 binding.

| | |
| :- | :- |
| Agent Card | `GET /.well-known/agent-card.json` — public |
| JSON-RPC endpoint | `POST /api/a2a` |
| Authentication | `Authorization: Bearer <personal access token>` with `assistant:run` |

```bash theme={null}
curl -s https://app.example.com/.well-known/agent-card.json
```

The card names three skills — investigate an incident, answer a question over
telemetry, and query telemetry in plain language — and the endpoint.

### Methods

| Method | What it does |
| :- | :- |
| `SendMessage` | Starts an investigation, or — with the message's `taskId` — answers the question one is waiting on. With a `contextId`, continues that conversation. Waits for the answer unless `configuration.returnImmediately` is `true`; a long investigation is returned still working, to be read with `GetTask`. |
| `SendStreamingMessage` | The same, answered as Server-Sent Events: the task, then a status update per step, then the answer artifact and the final status. |
| `GetTask` | The task's state, its answer and up to 50 history messages (`historyLength`, default 20). |
| `CancelTask` | Stops a running investigation. A finished one answers `-32002`. |
| `SubscribeToTask` | Resumes a task's stream; send `Last-Event-ID` to continue after the last step you saw. |

Put the investigation mode in the request's `metadata.mode`. A message's
`messageId` is its idempotency key: sending the same one again returns the same
task rather than starting a second investigation.

```bash theme={null}
curl -s -X POST https://app.example.com/api/a2a \
  -H "Authorization: Bearer $OIQ_TOKEN" -H 'Content-Type: application/json' -H 'A2A-Version: 1.0' \
  -d '{"jsonrpc":"2.0","id":"r1","method":"GetTask","params":{"id":"<task id>","historyLength":2}}'
```

**The answer** is one artifact, `answer`, with two parts: the answer as Markdown
text, and a JSON data part with its `citations`, the trust `verdict` and
`confidence`, the `evidence` the citations refer to and the `rootCause`.

**States.** An investigation that asks you a question is
`TASK_STATE_INPUT_REQUIRED`, with the question in the status message — answer it
with `SendMessage` naming the `taskId`. One waiting for a person to approve a tool
call is `TASK_STATE_AUTH_REQUIRED`: approve it in the dashboard; it cannot be
approved over this endpoint.

**Errors** use the JSON-RPC envelope with HTTP 200: `-32700` parse error, `-32600`
invalid request, `-32601` unknown method, `-32602` invalid parameters, `-32001`
task not found, `-32002` task not cancelable, `-32003` push notifications (not
supported), `-32004` unsupported operation, `-32005` a non-text part, and
`-32009` an `A2A-Version` other than 1.0. When the product refuses — the assistant
is switched off, your allowance is spent, too many investigations are running —
the code is `-32000`, with the product's message and its HTTP status in `data`.
A task you may not read, including one from another organization or a
colleague's private investigation, answers exactly as one that does not exist.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.