Skip to main content

AttackIQ Platform API

⚠️ Beta - Under active development. APIs subject to change. Feedback: rajesh.sharma@attackiq.com | Access: Request invite to AttackIQ GitHub.

Tools for interacting with the AttackIQ Platform API:

  • Python SDK (aiq-platform-api) - Async library for Python applications
  • CLI (aiq) - Command-line interface

Python SDK

Install from PyPI:

pip install aiq-platform-api

Usage

import asyncio
from aiq_platform_api import AttackIQClient, Scenarios, Assets

async def main():
    async with AttackIQClient(
        "https://your-platform.attackiq.com",
        "your-api-token"
    ) as client:
        # Search scenarios
        result = await Scenarios.search_scenarios(client, query="powershell", limit=10)
        print(f"Found {result['count']} scenarios")

        # List assets
        async for asset in Assets.get_assets(client, limit=5):
            print(asset["hostname"])

asyncio.run(main())

Automatic HTTP 429 Handling

When an SDK-managed request receives HTTP 429, the SDK retries with bounded exponential backoff and full jitter:

  • Each request has at most five total attempts and a 60-second retry budget, including requests and waits. No new attempt starts after the budget expires. Each pagination page receives its own budget.
  • Each asynchronous wait is capped at 15 seconds. A valid Retry-After (seconds or an HTTP date) sets the minimum wait, up to that cap. Missing, malformed, or negative values use jitter alone.
  • A retry logs a warning with the request method, path, delay, and attempt number. Queries, headers, and payloads are omitted from these warnings. Only a final failed call logs an error.

If a retry succeeds, the original call or async for continues normally. This applies to reads and streaming downloads, as well as POST, PUT, PATCH, and DELETE: the platform rejects throttled requests before mutation. Mutating requests are not replayed after ambiguous network failures or HTTP 502, 503, or 504 responses. GET retries for those server errors share the same attempt and time budget as HTTP 429 retries. Downloads close throttled responses before waiting, without reading their error bodies.

Assessment preparation and creation reuse each scenario's details within the call. A later call fetches fresh details. Loading scenario defaults for an atomic assessment uses at most five concurrent requests.

The HTTPX timeout still applies to each network attempt. An attempt already in flight can finish after the retry budget expires. Use asyncio.timeout() around the complete operation when a strict end-to-end deadline is required, or disable automatic GET rate-limit waiting as shown below.

Iterate over every result

Use the normal client and keep processing objects with async for. Pass limit=None to follow every results page:

import asyncio
import logging

from aiq_platform_api import Assessments, AttackIQClient

logger = logging.getLogger(__name__)

async def main():
    async with AttackIQClient(platform_url, api_token) as client:
        async for result in Assessments.get_results_by_run_id(
            client,
            run_id,
            assessment_version,
            limit=None,
        ):
            logger.info(f"Assessment result: {result}")

asyncio.run(main())

Replace the logging statement with the customer's object-processing logic. The same iteration pattern applies to other paginated SDK reads. The copyable version is in examples/read_rate_limit_handling.py

When a 429 is still raised

The raised httpx.HTTPStatusError retains the response and its Retry-After header. A paginated iterator may already have yielded earlier objects when a terminal 429 occurs. Logging is harmless; side-effecting processing should be idempotent. Code that publishes a complete dataset should stage the objects and commit only after iteration finishes.

Worker and scheduler integrations can disable automatic GET rate-limit waiting and handle the first 429 themselves (this option also covers downloads; mutations still retry platform 429 responses):

import httpx

async with AttackIQClient(
    platform_url,
    api_token,
    retry_rate_limited_gets=False,
) as client:
    try:
        async for result in Assessments.get_results_by_run_id(
            client,
            run_id,
            assessment_version,
            limit=None,
        ):
            logger.info(f"Assessment result: {result}")
    except httpx.HTTPStatusError as error:
        if error.response.status_code != 429:
            raise
        retry_after = error.response.headers.get("Retry-After")
        logger.warning(f"Rate limited; schedule a new collection using Retry-After={retry_after}")
        raise

Schedule another run no earlier than a valid returned Retry-After delay; use bounded jittered backoff if the header is absent or invalid. If throttling is frequent, provide the timestamp and the response's x-aiq-id to AttackIQ Support so the tenant policy and request pattern can be reviewed. Never include API tokens or cookies.


Configuration

Both the SDK and CLI require these environment variables:

export ATTACKIQ_PLATFORM_URL="https://your-platform.attackiq.com"
export ATTACKIQ_PLATFORM_API_TOKEN="your-api-token"

Or create a .env file in your working directory (auto-loaded).


TLS Verification (on-prem / self-signed certificates)

On-prem servers often present self-signed or non-standards-compliant certificates. Both the CLI and SDK can skip verification or trust a custom CA bundle.

Caveat: the error x509: certificate is not standards compliant is a strict certificate-parse rejection, not an untrusted-CA error. Only skipping verification (--insecure / verify=False) fixes it — a custom CA bundle (--cacert / verify="<path>") will not.

Shared environment variables (read by both the CLI and the SDK):

export ATTACKIQ_PLATFORM_INSECURE=true            # skip TLS verification (insecure)
export ATTACKIQ_PLATFORM_CA_BUNDLE=/path/ca.pem   # verify against a custom CA bundle (PEM)

ATTACKIQ_PLATFORM_INSECURE accepts 1, true, yes, or on (case-insensitive). When both vars are set, insecure wins. Disabling verification emits a visible warning.

CLI

aiq assets list -k                       # or --insecure; skip verification
aiq assets list --cacert /path/ca.pem    # verify against a custom CA bundle

A flag overrides the matching env var (e.g. --insecure=false keeps verification on even when ATTACKIQ_PLATFORM_INSECURE=true).

Python SDK

AttackIQClient(url, token, verify=False)           # skip verification (insecure)
AttackIQClient(url, token, verify="/path/ca.pem")  # verify against a custom CA bundle

When verify is omitted it falls back to the ATTACKIQ_PLATFORM_INSECURE / ATTACKIQ_PLATFORM_CA_BUNDLE env vars; an explicit argument always wins.


CLI

Linux / macOS

GITHUB_TOKEN="your_token" sh -c 'curl -fsSL -H "Authorization: token $GITHUB_TOKEN" \
  https://raw.githubusercontent.com/AttackIQ/aiq-platform-api/main/install.sh | sh'

Add to PATH (first time only):

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc  # or ~/.bashrc

Auto-detects OS/arch, installs to ~/.local/bin (no sudo).

Windows (Native)

PowerShell installer:

$env:GITHUB_TOKEN = "your_token"
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/AttackIQ/aiq-platform-api/main/install.ps1" -Headers @{Authorization="token $env:GITHUB_TOKEN"} -OutFile "$env:TEMP\install.ps1"
powershell -ExecutionPolicy Bypass -File "$env:TEMP\install.ps1"

Installs to %LOCALAPPDATA%\Programs\aiq and adds to PATH automatically.

Usage

# List available commands
aiq --help

# List assessments
aiq assessments list

# Search assets
aiq assets search --query "hostname"

# Get scenario details
aiq scenarios get --scenario-id "abc123"

Shell Completion

The CLI supports shell completion for bash, zsh, fish, and PowerShell.

Bash

Current session:

source <(aiq completion bash)

Permanent installation:

# Linux
aiq completion bash | sudo tee /etc/bash_completion.d/aiq

# macOS
aiq completion bash > $(brew --prefix)/etc/bash_completion.d/aiq

Zsh

Current session:

source <(aiq completion zsh)

Permanent installation:

# Add to ~/.zshrc
echo "source <(aiq completion zsh)" >> ~/.zshrc

# Or install to completions directory
aiq completion zsh > "${fpath[1]}/_aiq"

Fish

Permanent installation:

aiq completion fish | source

# Or save to completions directory
aiq completion fish > ~/.config/fish/completions/aiq.fish

PowerShell

Current session:

aiq completion powershell | Out-String | Invoke-Expression

Permanent installation: Add the following to your PowerShell profile:

aiq completion powershell | Out-String | Invoke-Expression

Cross-surface assessment planning

The Python SDK and Go CLI provide additive planning and creation APIs. Existing create_atomic_assessment and aiq assessments create-atomic remain available.

# Read-only preflight: discovers compatible active agents when asset IDs are omitted.
aiq assessments prepare --scenario-id SCENARIO_ID

# Read-only coordinated plan; supplied asset IDs form the candidate inventory.
aiq assessments plan-cross-surface --scenario-id WINDOWS_SCENARIO,LINUX_SCENARIO --asset-id WINDOWS_AGENT,LINUX_AGENT

# Create one surface/method group, preserving its planned targets.
aiq assessments create --name "Validation" --scenario-id SCENARIO_ID --asset-id AGENT_ID --target-attack-surface endpoint --test-method atomic

All three commands return JSON. prepare and plan-cross-surface exit nonzero when preflight fails. --scenario-configurations configs.json supplies an object mapping scenario IDs to their model_json overrides; --asset-tag-id supplies required asset tags. prepare and create also accept --use-hosted-agent. Explicit targets are validated rather than replaced. The planner covers every scenario's supported runtime/platform and minimum target count; unsupported connector or unspecified non-endpoint runtimes fail before creation.

For each valid group, pass its scenario IDs, surface, method, selected agent IDs and hosted flag to create, then use the existing run and status commands. Planning does not execute assessments. Live validation is available through aiq test plan-cross-surface --scenario-id SCENARIO_ID [--asset-id AGENT_ID].

Contributing

We welcome feedback and contributions! For detailed contribution guidelines, please see CONTRIBUTING.md.

Quick ways to contribute:

  • Open issues for bugs or feature requests
  • Submit pull requests
  • Provide feedback on the API design

License

MIT License - See LICENSE file for details

Metadata

Release files for aiq-platform-api 1.0.78

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiq-platform-api 1.0.78
File Size Uploaded
aiq_platform_api-1.0.78.tar.gz 122.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiq-platform-api 1.0.78
File Interpreter ABI Platform
aiq_platform_api-1.0.78-py3-none-any.whl Python 3 none any Details

Total release size: 251.3 kB

Release files / aiq_platform_api-1.0.78.tar.gz

Download URL aiq_platform_api-1.0.78.tar.gz
Size 122.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c4e88e50dbfff2ddeccf6ea8d643e1ac7297d335b3bb5f893f186151352ba1d6
BLAKE2b-256 checksum
How to use checksums
d4eea44f94128cdaf7b0a8d6adabf79ba72618deb55dd7c1d819a745334de0dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / aiq_platform_api-1.0.78-py3-none-any.whl

Download URL aiq_platform_api-1.0.78-py3-none-any.whl
Size 129.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71ea1aefb8a2fa9481d2c3399cadfd41d68a1d3170973bc3b35105eee49bdd8c
BLAKE2b-256 checksum
How to use checksums
f7acee6b54e7c9967a31f4bb81642acc0a786fe7cca459bb3c0afe7f0b76eba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

1.0.78 This release

2 release files

1.0.77

2 release files

1.0.70

2 release files

1.0.69

2 release files

1.0.68

2 release files

1.0.67

2 release files

1.0.66

2 release files

1.0.65

2 release files

1.0.60

2 release files

1.0.59

2 release files

1.0.53

2 release files

1.0.52

2 release files

1.0.51

2 release files

1.0.50

2 release files

1.0.49

2 release files

1.0.48

2 release files

1.0.44

2 release files

1.0.43

2 release files

1.0.42

2 release files

1.0.41

2 release files

1.0.40

2 release files

1.0.39

2 release files

1.0.38

2 release files

1.0.37

2 release files

1.0.36

2 release files

1.0.35

2 release files

1.0.34

2 release files

1.0.33

2 release files

1.0.32

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.27

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.42

2 release files

0.2.41

2 release files

0.2.40

2 release files

0.2.39

2 release files

0.2.38

2 release files

0.2.37

2 release files

0.2.36

2 release files

0.2.35

2 release files

0.2.34

2 release files

0.2.33

2 release files

0.2.32

2 release files

0.2.31

2 release files

0.2.30

2 release files

0.2.29

2 release files

0.2.28

2 release files

0.2.26

2 release files

0.2.25

2 release files

0.2.18

2 release files

0.2.17

2 release files

0.2.16

2 release files

0.2.15

2 release files

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page