|
| 1 | +# CodeAnt application APIs from the CLI |
| 2 | + |
| 3 | +The CLI uses the same authenticated CodeAnt API and organization/provider context as the web app. Sign in once, discover the connections available to that token, then use a first-class command or the generic API request command. |
| 4 | + |
| 5 | +```bash |
| 6 | +codeant login |
| 7 | +codeant scans orgs |
| 8 | +``` |
| 9 | + |
| 10 | +`CODEANT_API_TOKEN` and `CODEANT_API_URL` can be used instead of the saved login for agents, CI, and self-hosted installations. |
| 11 | + |
| 12 | +## Hotlist findings |
| 13 | + |
| 14 | +Hotlist commands use the same organization-wide snapshot, ranking, filters, stable finding IDs, and cursor pagination as the app. |
| 15 | + |
| 16 | +```bash |
| 17 | +# First page; org/service are auto-selected when unambiguous |
| 18 | +codeant hotlist list |
| 19 | + |
| 20 | +# Highest-priority production findings for one authenticated connection |
| 21 | +codeant hotlist list \ |
| 22 | + --org CodeAnt-AI \ |
| 23 | + --service github \ |
| 24 | + --severity critical,high \ |
| 25 | + --validation exploit_confirmed \ |
| 26 | + --limit 50 |
| 27 | + |
| 28 | +# Fetch every SCA finding across the organization |
| 29 | +codeant hotlist list --org CodeAnt-AI --service github --type SCA --all |
| 30 | + |
| 31 | +# Continue a page using next_cursor from the previous response |
| 32 | +codeant hotlist list --org CodeAnt-AI --service github --cursor '<cursor>' |
| 33 | + |
| 34 | +# Fetch exactly one finding using the stable ID shown in the app |
| 35 | +codeant hotlist get 0123456789abcdef0123456789abcdef \ |
| 36 | + --org CodeAnt-AI \ |
| 37 | + --service github |
| 38 | +``` |
| 39 | + |
| 40 | +Supported `hotlist list` filters: |
| 41 | + |
| 42 | +| Option | Values | |
| 43 | +|---|---| |
| 44 | +| `--search` | title, repository/account, path, package, CVE, or check ID | |
| 45 | +| `--type` | `AI Exploitation`, `SCA`, `SAST`, `Secrets`, `IaC`, `Infrastructure` | |
| 46 | +| `--location` | repository full names or cloud accounts | |
| 47 | +| `--severity` | `critical`, `high`, `medium`, `low`, `unknown` | |
| 48 | +| `--ticket-status` | `created`, `not_created` | |
| 49 | +| `--compliance` | framework keys such as `soc2` | |
| 50 | +| `--validation` | `exploit_confirmed` | |
| 51 | + |
| 52 | +Comma-separated values are accepted. The default page size is 30 and the maximum is 100. `--all` follows every cursor. If the first organization snapshot is still being built, the command waits up to 60 seconds; change that with `--max-wait <seconds>`. |
| 53 | + |
| 54 | +For self-hosted GitHub, GitLab, Bitbucket, or Azure DevOps, the CLI normally discovers the provider base URL from the authenticated connection. Use `--provider-base-url` only to override it. |
| 55 | + |
| 56 | +## Any app API |
| 57 | + |
| 58 | +Use the generic request command when a first-class command does not exist yet: |
| 59 | + |
| 60 | +```bash |
| 61 | +codeant api request GET /some/read/endpoint --query '{"page":1}' |
| 62 | + |
| 63 | +codeant api request POST /some/app/endpoint \ |
| 64 | + --body '{"org":"CodeAnt-AI","service":"github"}' |
| 65 | + |
| 66 | +codeant api request PATCH /some/app/endpoint \ |
| 67 | + --body-file ./request.json \ |
| 68 | + --header 'If-Match: revision-123' |
| 69 | +``` |
| 70 | + |
| 71 | +The output is JSON: |
| 72 | + |
| 73 | +```json |
| 74 | +{ |
| 75 | + "ok": true, |
| 76 | + "status": 200, |
| 77 | + "data": {} |
| 78 | +} |
| 79 | +``` |
| 80 | + |
| 81 | +Security properties: |
| 82 | + |
| 83 | +- The path must start with `/` and is always resolved against the configured CodeAnt API host. Absolute and protocol-relative URLs are rejected, so the bearer token cannot be forwarded to another host. |
| 84 | +- Authentication is supplied from `CODEANT_API_TOKEN` or the token saved by `codeant login`. |
| 85 | +- `Authorization`, `Cookie`, `Host`, and `Content-Length` headers cannot be overridden. |
| 86 | +- The backend remains authoritative for account access, organization membership, RBAC, and endpoint authorization. |
| 87 | + |
| 88 | +The generic command can call write endpoints. Review the method, path, and body before running it. |
| 89 | + |
| 90 | +## Agent and MCP access |
| 91 | + |
| 92 | +Run `codeant mcp` or install the CodeAnt MCP bundle. Agents receive dedicated read-only tools: |
| 93 | + |
| 94 | +- `codeant_hotlist_list` — filter and page through organization-wide findings. |
| 95 | +- `codeant_hotlist_get` — fetch one finding by stable ID. |
| 96 | +- `codeant_api_get` — authenticated GET access for newly-added read APIs. |
| 97 | + |
| 98 | +Set `CODEANT_READ_ONLY=0` to opt in to write tools, including `codeant_api_request` for POST/PUT/PATCH/DELETE. Read-only mode is the default. The MCP server never opens a browser during startup; the agent must explicitly call `codeant_login` when no token is configured. |
| 99 | + |
| 100 | +## Troubleshooting |
| 101 | + |
| 102 | +| Error | Resolution | |
| 103 | +|---|---| |
| 104 | +| No matching organization | Run `codeant scans orgs`, then pass its exact `organizationName` and `service`. | |
| 105 | +| Multiple organizations match | Pass both `--org` and `--service`. | |
| 106 | +| Access denied (403) | Run `codeant logout`, then `codeant login`, or replace `CODEANT_API_TOKEN`. | |
| 107 | +| Hotlist is still building | Retry, or increase `--max-wait`. | |
| 108 | +| Finding not found | Refresh the app/Hotlist and copy the current stable finding ID and tenant context. | |
0 commit comments