Skip to content

Flow IP report API

This page describes the implementation contract for Castles Flow 26.09.0-unified.16. Verify the installed version before using explicit bounds. The existing source and destination reports accept a shared, fixed interval through from and to; requests using only minutes retain their previous behavior.

GET /api/v1/reports/source/{ip} selects records where the IPv4 address is the source. GET /api/v1/reports/destination/{ip} selects records where it is the destination. Source and destination refer to record endpoints, not measured ingress and egress on a switch port.

Use the installation’s HTTPS origin and existing human session cookie with reports.read. Password and optional passkey sessions use the same permission model, checked on each request. A machine API key is not supported here. The address selects traffic within the current installation; it need not be part of a managed object. There is no tenant selector or managed-object scope parameter.

The path value ip and optional agent_ip must each be one IPv4 address, without CIDR notation. Repeated known query parameters and malformed unsigned integers fail query decoding with HTTP 400. The existing query decoder ignores unknown fields; use only the documented fields.

Field Meaning
from; to Both are required for explicit mode. Unsigned Unix seconds in UTC; both divisible by 300.
agent_ip Optional exact exporter/agent IPv4 filter, applied to all five result sections.
minutes Legacy relative duration; default 60, clamped to 1–10080. Cannot be combined with either explicit bound.

Explicit bounds must satisfy 0 ≤ from < to ≤ 4294967295, to ≤ floor(server_now / 300) × 300 and to - from ≤ 604800. Both bounds must be multiples of 300 seconds, so the minimum duration is five minutes and the maximum is seven days. The currently open five-minute interval is excluded. Missing one bound, mixed minutes and bounds, reversed or equal bounds, misalignment, a future end or an overlong interval returns HTTP 400 before any storage query.

All five queries use the same [from,to) predicate: the start is included and the end excluded. Successful explicit responses echo numeric from and to; minutes equals (to - from) / 60. Bounds describe the selection, not completeness of stored data.

With neither bound, the existing relative mode remains: minutes defaults to 60 and is clamped to 1–10080. Its selection is strictly later than the storage clock minus that many minutes and has no explicit upper bound. It does not echo from or to. The fixed-window addition does not change the existing fields or relative-mode response shape.

HTTP 200 returns one JSON object without a data wrapper. totals is an array containing one aggregate row under normal storage behavior, including when no rows match. counter below means a nonnegative UInt64 quantity: the standard storage JSON format represents it as a decimal string, as in these examples. The API passes through the storage JSON representation rather than normalizing counter types. Clients should preserve decimal strings, accept safe integer numbers where supplied, and avoid converting a large string to JavaScript Number.

Field Type Meaning
src_ip / dst_ip string Selected IPv4 address; only the matching endpoint’s field is returned.
from; to integer Explicit requests only: accepted UTC Unix-second bounds.
minutes integer Explicit duration divided by 60, or the accepted legacy relative duration.
totals[].bytes; totals[].packets counter Weighted byte and packet amounts for the selected scope.
totals[].samples counter Number of contributing stored sample records.
totals[].routers counter Distinct contributing exporter/agent addresses, not router inventory count.
timeline array Populated five-minute buckets in ascending timestamp order. Missing buckets are omitted.
timeline[].ts integer Bucket start in UTC Unix seconds.
timeline[].bytes; timeline[].packets counter Weighted amounts in that bucket.
top_dst_ports array Up to 20 destination ports, ordered by bytes descending.
top_dst_ports[].dst_port integer Destination port, 0–65535.
top_dst_ports[].bytes; top_dst_ports[].packets; top_dst_ports[].samples counter Weighted amounts and stored sample count for this port.
Endpoint Additional fields
Source totals[].unique_dst: distinct destination count (counter). top_dst_ips: at most 20 rows with dst_ip (IPv4 string), bytes, packets, samples (counters), ordered by bytes descending. protocols: observed protocol rows with proto (integer 0–255), bytes, packets (counters), ordered by bytes descending.
Destination totals[].unique_src: distinct source count (counter). top_src_ips: at most 20 rows with src_ip (IPv4 string), bytes, packets, samples (counters), ordered by bytes descending. tcp_flags: at most 16 observed TCP mask combinations with tcp_flags (integer 0–255), packets, samples (counters), ordered by packets descending.

Byte and packet amounts already include each stored record’s sampling factor once, or the equivalent stored aggregate. Do not multiply them by sampling again. They are amounts, not bps or pps rates. samples is not a packet count. The endpoints return no sampling-provenance flag, completeness indicator, p95 value or billing result; they do not establish trustworthy coverage from nonzero counters.

The timeline uses stored five-minute aggregates. Totals and ranked sections use stored records for durations up to one hour, and five-minute aggregates for longer durations. Destination TCP masks always use stored TCP records. These representations can differ in availability, retention and update delay. A blank timeline can therefore coexist with available totals. The five queries run independently, and a shared interval does not provide an atomic storage snapshot.

TCP masks are grouped as combinations, not independent flag memberships. A value of 18 means SYN plus ACK; one row is not split between two flag groups. Rankings have no pagination or remainder group, and ties have unspecified order. In explicit mode the timeline has at most 2016 possible five-minute positions, with only populated positions returned.

Each storage request uses the existing 15-second client timeout. These endpoints introduce no additional per-query row, byte, memory or concurrency budget. Configured storage limits can still reject a query. A failed query returns an error; successful zero counters or empty arrays do not certify full traffic capture.

These requests run after sign-in on the installation. They use fictional documentation addresses and an aligned one-hour interval. Responses illustrate the implemented fields using fictional records; they do not claim that this historical interval contains data on an actual installation.

async function readReport(path) {
const response = await fetch(path, { credentials: 'same-origin' });
const raw = await response.text();
const contentType = response.headers.get('content-type') || '';
if (!response.ok) throw new Error(raw || `HTTP ${response.status}`);
if (!contentType.includes('application/json') || !raw) {
throw new Error('Invalid report response');
}
return JSON.parse(raw);
}
const query = new URLSearchParams({
from: '1700000100',
to: '1700003700',
agent_ip: '203.0.113.1'
});
const source = await readReport(`/api/v1/reports/source/192.0.2.10?${query}`);
const destination = await readReport(`/api/v1/reports/destination/198.51.100.10?${query}`);

Complete source response:

{
"src_ip": "192.0.2.10",
"minutes": 60,
"from": 1700000100,
"to": 1700003700,
"totals": [
{
"bytes": "192000",
"packets": "1920",
"samples": "30",
"unique_dst": "2",
"routers": "1"
}
],
"timeline": [
{
"ts": 1700000100,
"bytes": "64000",
"packets": "640"
},
{
"ts": 1700000400,
"bytes": "128000",
"packets": "1280"
}
],
"top_dst_ips": [
{
"dst_ip": "198.51.100.10",
"bytes": "128000",
"packets": "1280",
"samples": "20"
},
{
"dst_ip": "198.51.100.20",
"bytes": "64000",
"packets": "640",
"samples": "10"
}
],
"top_dst_ports": [
{
"dst_port": 443,
"bytes": "128000",
"packets": "1280",
"samples": "20"
},
{
"dst_port": 53,
"bytes": "64000",
"packets": "640",
"samples": "10"
}
],
"protocols": [
{
"proto": 6,
"bytes": "128000",
"packets": "1280"
},
{
"proto": 17,
"bytes": "64000",
"packets": "640"
}
]
}

Complete destination response:

{
"dst_ip": "198.51.100.10",
"minutes": 60,
"from": 1700000100,
"to": 1700003700,
"totals": [
{
"bytes": "192000",
"packets": "1920",
"samples": "30",
"unique_src": "2",
"routers": "1"
}
],
"timeline": [
{
"ts": 1700000100,
"bytes": "64000",
"packets": "640"
},
{
"ts": 1700000400,
"bytes": "128000",
"packets": "1280"
}
],
"top_src_ips": [
{
"src_ip": "192.0.2.10",
"bytes": "128000",
"packets": "1280",
"samples": "20"
},
{
"src_ip": "192.0.2.20",
"bytes": "64000",
"packets": "640",
"samples": "10"
}
],
"top_dst_ports": [
{
"dst_port": 443,
"bytes": "192000",
"packets": "1920",
"samples": "30"
}
],
"tcp_flags": [
{
"tcp_flags": 2,
"packets": "1280",
"samples": "20"
},
{
"tcp_flags": 18,
"packets": "640",
"samples": "10"
}
]
}

A successful empty source result retains a single zero aggregate in totals and empty breakdowns:

{
"src_ip": "192.0.2.10",
"minutes": 60,
"from": 1700000100,
"to": 1700003700,
"totals": [
{
"bytes": "0",
"packets": "0",
"samples": "0",
"unique_dst": "0",
"routers": "0"
}
],
"timeline": [],
"top_dst_ips": [],
"top_dst_ports": [],
"protocols": []
}

The legacy request GET /api/v1/reports/source/192.0.2.10?minutes=60&agent_ip=203.0.113.1 has the source schema above with minutes: 60 and without the from and to members. It uses a moving period and is not guaranteed to select the records in the fixed example.

The report handlers return status-only errors with an empty body. Session and query-decoding failures return plain text. No JSON error code is defined for these report handlers. Read the status first and handle empty bodies; do not call response.json() unconditionally.

HTTP Body Meaning
400 empty Invalid IPv4 address/filter, incomplete or mixed time selection, unaligned bounds, reversed interval, future end, out-of-range timestamp or duration over seven days.
400 plain text Malformed or repeated typed query parameters.
401 authentication required / session expired or revoked Missing, expired or revoked human session.
403 permission denied Disabled account or absent reports.read permission.
500 empty The server clock cannot be represented as a nonnegative Unix timestamp.
502 empty A report storage request failed, timed out, exceeded a configured limit or returned an undecodable JSON body.
503 empty Flow storage is not configured for querying.
503 authentication service unavailable / invalid authentication response The current session could not be verified.

GET /api/v1/reports/source/192.0.2.10?from=1700000100 returns HTTP 400 with an empty body after successful session authorization: the matching to is missing. No storage query is sent.

Castles Flow product documentation.

On installations running 26.09.0-unified.15-detection.1 with the new detector enabled, incident reports include the optional fields below. Existing historical reports may omit them.

Use the existing human session and dashboard.read on the installation origin. These endpoints have no tenant selector. GET /api/v1/detection/attacks returns a JSON array and X-Total-Count; mo_id optionally selects one object, limit defaults to 100 and is clamped to 1–10000, and offset defaults to 0 and is clamped at zero. Sorting is by start_time descending, without a stable tie order. List rankings contain at most 20 entries each. GET /api/v1/detection/attacks/{id} returns one full report; new detector rankings contain at most 100 entries each. Authentication failures return 401, denied permissions 403, malformed parameters 400, a missing detail 404, and a storage failure 500.

A host report has one exact IPv4 /32; network reports retain their configured prefix union, including nested hosts. Do not sum overlapping host and network volumes. Only phase active or clearing together with freshness fresh describes a currently confirmed incident. Data older than 90 seconds or an unavailable writer makes freshness unknown; this does not close an incident. status mitigated is a compatibility value for a closed event and does not prove traffic filtering. Candidates are object states and do not create incident reports before confirmation.

Times are Unix seconds in UTC; display them in the selected timezone. end_time: 0 means no recorded close. Rates use packets per second and bits per second; totals use packets and bytes with sampling included once. Preserve integer precision. revision increases within an incident; scope and policy revisions are opaque identifiers. Baselines and report analytics may be null, which must not be rendered as zero. The original trigger values remain fixed while peaks and totals update.

coverage.status is pending, complete, partial or unavailable. Available analytical lists use the saved target scope and [from,to) interval, capped at the first five minutes. Their scope is all traffic to the saved targets, so they are not a count of proven hostile packets. Partial coverage records the interval or unavailable geography. Counters for countries and ASNs are null if geography cannot be computed completely; rankings are independent and not derived from the displayed top IPs. Existing deployments may still return legacy reports with different analytical coverage.

const response = await fetch('/api/v1/detection/attacks?mo_id=7&limit=50&offset=0', {
credentials: 'same-origin'
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const reports = await response.json();
const total = response.headers.get('X-Total-Count');
[
{
"id": "a2b3c4d5-1111-4222-8333-123456789abc",
"mo_id": 7,
"mo_name": "Example host",
"target_prefixes": [
"192.0.2.7/32"
],
"start_time": 1700000100,
"end_time": 0,
"status": "active",
"attack_type": "udp",
"attack_target": "192.0.2.7/32",
"trigger_metric": "udp pps",
"trigger_value": 500,
"trigger_threshold": 200,
"peak_pps": 500,
"peak_bps": 10000,
"total_packets": 2500,
"total_bytes": 6250,
"detection_source": "canonical",
"detection_kind": "host",
"phase": "active",
"freshness": "fresh",
"reason": "threshold_confirmed",
"last_observed_at": 1700000105,
"revision": 1,
"baseline_pps": null,
"baseline_bps": null,
"threshold_pps": 200,
"threshold_bps": 0,
"scope_revision": "example-scope",
"config_revision": "example-policy",
"classification": "medium",
"is_fast": false,
"top_src_ips": [],
"top_dst_ips": [],
"top_src_ports": [],
"top_dst_ports": [],
"top_countries": [],
"top_asns": [],
"unique_src_ips": null,
"unique_dst_ips": null,
"unique_src_ports": null,
"unique_dst_ports": null,
"unique_countries": null,
"unique_asns": null,
"protocol_dist": null,
"pkt_size_dist": null,
"coverage": {
"status": "pending",
"from": 1700000100,
"to": 1700000105
}
}
]

Carpet reports are available from 26.09.0-unified.43. Membership and suppression rules below describe 26.09.0-unified.44.

A carpet is one incident for many hosts of one managed object under the same misuse type. A host of the object is a member when its rate exceeds host_percent % of its own host trigger in at least one enabled dimension, pps or bps. A five-second bucket counts toward the carpet when at least min_hosts hosts are members in the same dimension; otherwise it contributes zero. The carpet trigger is min_hosts × (host_percent % of the host trigger) and its high threshold is min_hosts × the host high threshold, per dimension. The compared rate is the sum of the member hosts. The carpet follows the object lifecycle, including open_percent and min_samples, and has no fast flood. Global detection builds no carpets.

While a carpet is active or clearing, a host of the same object and misuse type opens its own incident only by fast flood or when its average over the open window is above max(high, 2 × threshold); other new host incidents are suppressed. Host incidents opened before the carpet stay open and close by their own lifecycle. During a carpet episode the hosts of that misuse type do not learn smartmode baselines and the object network baseline is not learned.

Field Carpet value
detection_kind carpet.
target_prefixes; attack_target Saved IPv4 prefixes of the object; attack_target joins them with , .
attack_type; trigger_metric Misuse type; <misuse> pps or <misuse> bps.
threshold_pps; threshold_bps Carpet trigger; 0 for a dimension without a host trigger.
trigger_value; peak_*; total_* Sum of member hosts.
baseline_pps; baseline_bps Always null.
is_fast Always false.
carpet Object below; present only when detection_kind is carpet. List and detail return it unchanged.
carpet.hosts Integer: member hosts in the latest bucket. A closed carpet usually has 0.
carpet.peak_hosts Integer: largest member count of the incident.
carpet.top Array of at most 20 strongest member hosts of the incident, ordered by pps, then bps descending, then address.
carpet.top[].ip IPv4 host address.
carpet.top[].pps; carpet.top[].bps Integers: highest five-second rate of this host for the misuse type during the incident.

Carpet-specific fields of one fictional report; other fields follow the example above, and carpet.top is shortened to two entries:

{
"mo_id": 7,
"mo_name": "Example network",
"target_prefixes": [
"192.0.2.0/24"
],
"attack_type": "udp",
"attack_target": "192.0.2.0/24",
"trigger_metric": "udp pps",
"trigger_value": 1200000,
"trigger_threshold": 250000,
"detection_kind": "carpet",
"threshold_pps": 250000,
"threshold_bps": 0,
"baseline_pps": null,
"baseline_bps": null,
"is_fast": false,
"carpet": {
"hosts": 40,
"peak_hosts": 42,
"top": [
{
"ip": "192.0.2.17",
"pps": 36000,
"bps": 144000000
},
{
"ip": "192.0.2.42",
"pps": 34000,
"bps": 136000000
}
]
}
}

GET /api/v1/detection/mo, GET /api/v1/detection/mo/{id}, POST /api/v1/detection/mo and PUT /api/v1/detection/mo/{id} carry the optional thresholds.carpet and thresholds.lifecycle objects. Reading requires managed_objects.read, writing managed_objects.write. PUT replaces the whole thresholds object: send the stored fields with the changed ones. Absent or null objects and absent keys take the defaults below. Both stay object settings when a detection set is linked. The detector receives carpet for managed objects only; PUT /api/v1/detection/defaults validates it but global detection ignores it. lifecycle also applies to the global defaults.

Field Type Default Range and meaning
carpet.enabled boolean true Carpet detection of the object.
carpet.min_hosts integer 10 2–4096. Members in one dimension needed for a bucket.
carpet.host_percent integer 50 1–100. Per-host floor in percent of the host trigger.
lifecycle.open_percent integer 70 1–100. Share of open-window buckets over the trigger.
lifecycle.min_samples integer 25 0–100000. Flow samples (packets divided by the sampling rate) required behind the open window and behind a fast flood hold; 0 disables the check. Applies to host, network and carpet incidents.

An unknown key in carpet or lifecycle, a wrong type or a value out of range returns HTTP 400 with a plain-text message, and nothing is saved.

const stored = await (await fetch('/api/v1/detection/mo/7', { credentials: 'same-origin' })).json();
const response = await fetch('/api/v1/detection/mo/7', {
method: 'PUT',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: stored.name,
parent_id: stored.parent_id,
cidrs: stored.cidrs,
enabled: stored.enabled,
profile: stored.profile,
thresholds: {
...stored.thresholds,
carpet: { enabled: true, min_hosts: 20, host_percent: 50 },
lifecycle: { ...stored.thresholds.lifecycle, min_samples: 25 }
}
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);