Skip to content

Flow dashboard API

This contract applies to Castles Flow 26.09.0-unified.13. GET /api/v1/stats/dashboard reads stored IPv4 traffic for the current installation. Call it on the installation’s HTTPS origin with the existing human session cookie, and that session needs dashboard.read. Password sessions and optional passkey sessions carry the same permissions. There is no tenant selector, and machine API keys are not accepted.

Send either range_seconds or both from and to. With no time parameters, the server uses a relative 86400-second window. Its actual bounds are captured when the snapshot is calculated, so they may be earlier than the request time. Bounds are Unix seconds. They are not milliseconds or ISO date strings. The interval includes from and excludes to, and future bounds are rejected. The server also rejects unknown query fields and any typed parameter that is malformed or repeated. Every supplied filter is an exact match. Filters combine with AND and apply to every result section.

Field Meaning
range_seconds Relative duration: integer 300–86400; default 86400. Cannot be combined with from/to.
from; to Both required for an absolute interval: unsigned integers, 0 ≤ from < to ≤ 4294967295, to no later than current UTC time, duration 1–86400 seconds.
src_ip; dst_ip One IPv4 address each; IPv6 and CIDR prefixes are not accepted.
proto IP protocol number, integer 0–255.
src_port; dst_port Port numbers, integers 0–65535.

The server keeps completed snapshots separately for each installation. For relative requests, the key is the duration plus every supplied filter. For absolute requests, it is the exact from, to and filters. A request with no duration and a request with range_seconds=86400 use the same key. Authentication and dashboard.read are checked on every request, including cache hits.

A snapshot younger than 60 seconds is returned immediately. From 60 seconds up to (but not including) 180, the server may return the existing snapshot while one recalculation runs in the background. At 180 seconds the snapshot stops being served, and the request either waits for a new calculation or returns an error. A failed calculation never replaces a successful snapshot. After repeated failures, the server waits five seconds before retrying. A snapshot’s age counts from the moment calculation begins, so query time is included. window and generated_at always describe that original calculation. Clients must not replace them with the current time.

The unfiltered 24-hour snapshot is prepared at startup and refreshed in the background about once a minute. A first request that arrives during preparation waits for that same calculation. New filters and periods can still require a storage read. Server memory holds at most 32 entries and 8 MiB of completed response bodies. Eviction or a process restart can force a recalculation. Oversized responses are returned but not retained. Regardless of server-side caching, Cache-Control: no-store prevents storage in browsers and intermediaries.

Response header Meaning
X-Dashboard-Cache HIT: ready snapshot; MISS: newly calculated; STALE: previous snapshot during refresh or its retry delay; COALESCED: waited for the calculation already in progress for this key.
X-Dashboard-Cache-Age Whole seconds since the returned snapshot calculation began, measured by the server’s monotonic clock.

For unfiltered periods longer than six hours, the server fixes the input dataset first and calculates every response section from it. Complete storage intervals come from prepared aggregates. Boundary intervals keep the exact requested timestamps. Records that arrive after the input is fixed appear in a later snapshot. Shorter periods and filtered requests still read the stored records.

HTTP 200 returns one JSON object with Cache-Control: no-store. There is no data wrapper and no pagination. Every listed response field is present. Only absent filter members are omitted. In the tables, uint means an unsigned JSON integer. decimal is a decimal string that represents an integer from 0 through 340282366920938463463374607431768211455. rate is a finite nonnegative JSON number. For exact arithmetic, keep decimal strings as strings or use BigInt. Converting them to a JavaScript Number can lose precision.

Field Type / value Meaning
schema_version; generated_at 1; uint Schema version and UTC generation time in seconds.
window.from; window.to; window.range_seconds uint Captured interval and its duration in seconds.
window.step_seconds 5 / 10 / 30 / 60 / 300 Nominal bucket width in seconds.
window.interval; window.timezone "[from,to)"; "UTC" Inclusive start, exclusive end; timestamps remain UTC.
filters object Only the five supplied filters, with their request types.
scope object Opaque scope identifiers, listed below.
coverage.complete null Completeness is not established; always null.
coverage.first_sample_at; coverage.last_sample_at uint / null First and last stored sample timestamps; null when no rows match.
coverage.sample_rows; coverage.unknown_sampling_rows uint Matching stored row count and rows with unknown or zero sampling.
coverage.populated_buckets; coverage.empty_buckets uint Buckets with at least one row, and buckets with none.
totals.estimated_bytes; totals.estimated_packets decimal / null Weighted total bytes and packets; null for empty history or unknown sampling.
totals.avg_bps; totals.avg_pps rate / null Requested-window averages, in bits/s and packets/s.
totals.peak_bps; totals.peak_pps rate / null Maximum observed bucket rates, in bits/s and packets/s.
totals.unique_src_ips; totals.unique_dst_ips uint Exact distinct source and destination IPv4 counts; zero for empty history.
timeseries array Contiguous bucket array covering the requested interval.
timeseries[].timestamp; timeseries[].from; timeseries[].to uint timestamp equals from; bucket bounds use seconds and [from,to).
timeseries[].sample_rows; timeseries[].unknown_sampling_rows uint Stored row counts within this bucket.
timeseries[].estimated_bytes; timeseries[].estimated_packets decimal / null Weighted bucket amounts, or null when empty or sampling is unknown.
timeseries[].bps; timeseries[].pps rate / null Bucket rates over to minus from seconds, or null.
breakdowns object All eleven named sections below; no section is omitted.
Field Type / value
scope.averaging_basis "stored_samples_over_requested_window"
scope.bucket_alignment "epoch"
scope.enrichment "current_local_geoip"
scope.enrichment_ip_limit 2000000
scope.ip_version 4
scope.packet_size "stored_record_size_or_average"
scope.peak_basis "maximum_observed_bucket_rate"
scope.source "flow_samples"
scope.tcp_flags "record_flag_membership"
scope.timestamp_basis "stored_record_timestamp"
scope.traffic_basis "stored_record_counters_times_stored_sampling_rate_once"

Each stored record contributes its byte and packet counters, multiplied once by its stored sampling rate. The response already includes that weight, so do not multiply it again. Average rates divide weighted totals by the whole requested window, including gaps. Peak rates are the highest observed bucket rate, with the first and last buckets clipped to the requested bounds. They are not an instantaneous line-rate measurement.

The server uses the first step from 5, 10, 30, 60 and 300 seconds where ceil(range_seconds / step) is at most 360. Buckets align to UTC epoch multiples and are clipped at both ends, so a misaligned interval can have 361 buckets. Empty buckets stay in the array with null amounts and rates. A known measured zero stays numeric zero. If any matching record has unknown sampling, totals and all breakdowns are unavailable. Individual buckets whose sampling is fully known can still have values. coverage.complete is always null, because sample timestamps and populated buckets do not prove that traffic capture was complete.

The section keys are src_ips, dst_ips, src_asns, dst_asns, src_countries, dst_countries, protocols, src_ports, dst_ports, packet_sizes and tcp_flags. Source and destination describe the endpoints of a record. They do not establish whether traffic is network ingress or egress.

Field Type / value Meaning
status string available, empty or unavailable.
reason string / null null, sampling_unknown, geoip_unavailable or enrichment_ip_limit.
total_groups uint / null Full distinct group count when available; null for empty or unavailable sections.
items array Result items; empty for empty or unavailable sections.
items[].key; items[].label string Stable group identifier and display label; API labels are not localized.
items[].estimated_bytes; items[].estimated_packets decimal Exact weighted group byte and packet amounts.
items[].rank_bytes; items[].rank_packets uint 1–10 / null Separate byte and packet ranks 1–10; null outside that metric’s top ten.

IP, port, ASN and country sections return the union of the ten highest byte totals and the ten highest packet totals, so each section has at most 20 items. There is no paging and no remainder group. To rank by a metric, use its rank field. Items are returned in string-key order, and ties sort by ascending string key. Protocols, packet-size classes and TCP flags include every observed group, and protocol ranks beyond ten are null. Totals and unique-IP counts cover all matching records, including groups that are not in the returned ranking.

ASN and country groups come from the current local lookup databases. Before ranking, the server looks up every distinct address in the selected direction. These are current assignments, not historical ones. The server enriches up to 2000000 distinct IPv4 addresses per direction. If a direction exceeds that limit, only its ASN and country sections become unavailable, with enrichment_ip_limit. IP rankings and exact unique counts stay available. A missing lookup database gives geoip_unavailable. A single failed lookup is counted under key unknown with label Unknown. Empty history returns empty sections.

Protocol keys are decimal protocol numbers. TCP, UDP and ICMP use those names as labels, and other protocols are labeled IP protocol N. Port keys are decimal port numbers. ASN keys are decimal ASNs or unknown, and country keys are country codes or unknown. Packet-size keys are unknown (stored size 0), tiny (1–63 B), small (64–127 B), medium (128–255 B), big (256–511 B), large (512–1023 B), huge (1024–1518 B) and jumbo (>1518 B). They classify the stored size or average size of a record. They do not form a packet-size histogram. TCP flags show membership of FIN, SYN, RST, PSH, ACK, URG, ECE and CWR in TCP records. One record can count toward several flags, so flag amounts can overlap. Records with no flags set, and records with a non-TCP protocol, do not create flag items.

Each API process runs one analytics calculation at a time. Requests with the same cache key share that calculation, and ready snapshots stay available while other scans run. If the scan slot is busy, a request for a different key with no usable snapshot gets 429. The time window is limited to 24 hours. Time limits are 12 seconds for input preparation, 30 seconds for query execution and 40 seconds for the result stream. The whole calculation has a 45-second deadline. Read limits apply to whichever stored representation is selected, including prepared aggregates:

  • Storage read: 50000000 rows and 4294967296 bytes.
  • Grouping: 4200000 groups and 1073741824 bytes of memory.
  • Aggregate result: 4010000 rows and 1073741824 bytes.

If a limit is exceeded or storage fails, the request is rejected. The API never returns a silently truncated snapshot as a success. Shorten the interval or add filters before retrying. Page size and bucket width cannot be configured by the client.

Run this request after you sign in to the installation. The response assembler produced the full response below from fictional records. The example uses a historical one-second interval so the output is deterministic, and the generation timestamp comes from a captured test clock. Local lookup databases are not available in this fixture.

const response = await fetch('/api/v1/stats/dashboard?from=1700000000&to=1700000001', {
credentials: 'same-origin'
});
const contentType = response.headers.get('content-type') || '';
const result = contentType.includes('application/json')
? await response.json()
: { error: await response.text() };
if (!response.ok) throw new Error(result.error || String(response.status));
const snapshot = {
data: result,
cache: response.headers.get('X-Dashboard-Cache'),
ageSeconds: Number(response.headers.get('X-Dashboard-Cache-Age'))
};
{
"breakdowns": {
"dst_asns": {
"items": [],
"reason": "geoip_unavailable",
"status": "unavailable",
"total_groups": null
},
"dst_countries": {
"items": [],
"reason": "geoip_unavailable",
"status": "unavailable",
"total_groups": null
},
"dst_ips": {
"items": [
{
"estimated_bytes": "6400",
"estimated_packets": "64",
"key": "198.51.100.2",
"label": "198.51.100.2",
"rank_bytes": 1,
"rank_packets": 1
}
],
"reason": null,
"status": "available",
"total_groups": 1
},
"dst_ports": {
"items": [
{
"estimated_bytes": "6400",
"estimated_packets": "64",
"key": "53",
"label": "53",
"rank_bytes": 1,
"rank_packets": 1
}
],
"reason": null,
"status": "available",
"total_groups": 1
},
"packet_sizes": {
"items": [
{
"estimated_bytes": "6400",
"estimated_packets": "64",
"key": "small",
"label": "64–127 B",
"rank_bytes": 1,
"rank_packets": 1
}
],
"reason": null,
"status": "available",
"total_groups": 1
},
"protocols": {
"items": [
{
"estimated_bytes": "6400",
"estimated_packets": "64",
"key": "6",
"label": "TCP",
"rank_bytes": 1,
"rank_packets": 1
}
],
"reason": null,
"status": "available",
"total_groups": 1
},
"src_asns": {
"items": [],
"reason": "geoip_unavailable",
"status": "unavailable",
"total_groups": null
},
"src_countries": {
"items": [],
"reason": "geoip_unavailable",
"status": "unavailable",
"total_groups": null
},
"src_ips": {
"items": [
{
"estimated_bytes": "6400",
"estimated_packets": "64",
"key": "192.0.2.1",
"label": "192.0.2.1",
"rank_bytes": 1,
"rank_packets": 1
}
],
"reason": null,
"status": "available",
"total_groups": 1
},
"src_ports": {
"items": [
{
"estimated_bytes": "6400",
"estimated_packets": "64",
"key": "443",
"label": "443",
"rank_bytes": 1,
"rank_packets": 1
}
],
"reason": null,
"status": "available",
"total_groups": 1
},
"tcp_flags": {
"items": [],
"reason": null,
"status": "empty",
"total_groups": null
}
},
"coverage": {
"complete": null,
"empty_buckets": 0,
"first_sample_at": 1700000000,
"last_sample_at": 1700000000,
"populated_buckets": 1,
"sample_rows": 1,
"unknown_sampling_rows": 0
},
"filters": {},
"generated_at": 1700000101,
"schema_version": 1,
"scope": {
"averaging_basis": "stored_samples_over_requested_window",
"bucket_alignment": "epoch",
"enrichment": "current_local_geoip",
"enrichment_ip_limit": 2000000,
"ip_version": 4,
"packet_size": "stored_record_size_or_average",
"peak_basis": "maximum_observed_bucket_rate",
"source": "flow_samples",
"tcp_flags": "record_flag_membership",
"timestamp_basis": "stored_record_timestamp",
"traffic_basis": "stored_record_counters_times_stored_sampling_rate_once"
},
"timeseries": [
{
"bps": 51200.0,
"estimated_bytes": "6400",
"estimated_packets": "64",
"from": 1700000000,
"pps": 64.0,
"sample_rows": 1,
"timestamp": 1700000000,
"to": 1700000001,
"unknown_sampling_rows": 0
}
],
"totals": {
"avg_bps": 51200.0,
"avg_pps": 64.0,
"estimated_bytes": "6400",
"estimated_packets": "64",
"peak_bps": 51200.0,
"peak_pps": 64.0,
"unique_dst_ips": 1,
"unique_src_ips": 1
},
"window": {
"from": 1700000000,
"interval": "[from,to)",
"range_seconds": 1,
"step_seconds": 5,
"timezone": "UTC",
"to": 1700000001
}
}

A relative request with all five filters returns the same schema:

const query = new URLSearchParams({
range_seconds: '86400',
src_ip: '192.0.2.1',
dst_ip: '198.51.100.2',
proto: '6',
src_port: '443',
dst_port: '53'
});
const response = await fetch(`/api/v1/stats/dashboard?${query}`, {
credentials: 'same-origin'
});
const contentType = response.headers.get('content-type') || '';
const result = contentType.includes('application/json')
? await response.json()
: { error: await response.text() };
if (!response.ok) throw new Error(result.error || String(response.status));
const snapshot = {
data: result,
cache: response.headers.get('X-Dashboard-Cache'),
ageSeconds: Number(response.headers.get('X-Dashboard-Cache-Age'))
};

Handler errors use JSON {“error”:“code”}. Authentication and query decoding errors are plain text, so check Content-Type before parsing. An error response never contains a partial successful snapshot. The stable contract is the HTTP status plus the documented handler codes. Decoder text can vary.

HTTP Type / value Meaning
400 JSON · invalid_range_seconds Relative duration outside 300–86400.
400 JSON · invalid_time_window Conflicting, missing, reversed, future or overlong absolute bounds.
400 text/plain Unknown fields, malformed IPv4 or unsigned integer values, duplicate fields.
401 text/plain · authentication required; session expired or revoked Missing cookie, expired session or revoked session.
403 text/plain · permission denied Disabled account or absent dashboard.read permission.
429 JSON · dashboard_busy A different snapshot is being calculated and no usable cached response exists for this query; retry later.
502 JSON · dashboard_query_failed; dashboard_result_limit; dashboard_invalid_result Storage query failed or timed out, result limit exceeded, or invalid/incomplete aggregate result.
503 JSON · clock_unavailable; history_unavailable Clock or history unavailable.
503 text/plain · authentication service unavailable; invalid authentication response Authentication service unavailable or invalid authentication response.

Castles Flow product documentation.

Available from 26.09.0-unified.15-system.1 on installations that have host monitoring configured. GET /api/v1/system/status returns the current installation’s host resources, service states and housekeeping result. Call it on the installation’s HTTPS origin with an existing human session that has settings.read. Password sessions and optional passkey sessions go through the same server authorization. The endpoint has no tenant selector and does not accept machine API keys. It takes no request body, has no pagination and supports no query parameters. It only reads a snapshot. It does not start cleanup or change configuration.

The monitoring producer takes a sample about every 30 seconds. HTTP 200 includes Cache-Control: no-store. observed_at is the original measurement time in UTC Unix seconds, and age_seconds is how old that measurement is when the response is sent. freshness is fresh up to and including 120 seconds, then stale. Clients must keep aging any values they retain and must show failures explicitly. A successful response does not mean every field is available. The response contains no historical time series.

Every field shown in the example is present. Integer timestamps, byte counts and counters are nonnegative JSON integers. Percentages are finite numbers from 0 to 100. An unavailable optional measurement is null, never a manufactured zero.

  • schema_version: integer 1; scope: host; uptime_seconds: host uptime in seconds.
  • cpu: object or null. usage_percent is utilization between two host samples, excluding idle and I/O wait. It stays null until a valid pair of samples exists. logical_cpus is a positive integer. load_average holds three nonnegative numbers for 1, 5 and 15 minutes. These are queue/load values, not percentages.
  • memory: object or null. total_bytes, available_bytes, used_bytes, swap_total_bytes and swap_used_bytes are byte counts. Used memory is total minus available. Available memory includes the operating system’s estimate of reclaimable memory. usage_percent is used divided by total times 100.
  • disks: zero or one object. An empty array means disk data is unavailable. The current disk has id: root and mount_point: /. total_bytes = used_bytes + available_bytes + reserved_bytes, and available space excludes the filesystem reservation. usage_percent is used divided by total times 100. warning_below_bytes and critical_below_bytes are thresholds for available bytes. state is critical below the critical threshold, warning below the warning threshold and ok otherwise. The installed policy sets the warning threshold to the greater of 10 GiB or 15%, and the critical threshold to the greater of 2 GiB or 5%.
  • services: up to six unique entries, each with id and state. IDs are collector, detection, api, clickhouse, postgresql and frontend. States are running, healthy, starting, stopped, failed and unknown. healthy reflects an available container health check. running only confirms that a process or container is running. Missing or unknown service data is not evidence of health.
  • housekeeping: object or null. state is ok, running, failed, disabled, overdue or unknown. overdue means the last completed run is more than 32 hours old. last_finished_at and next_run_at are Unix seconds or null. log_retention_days is an integer from 1 to 3650, or null. archive_count, removed_file_bytes and retired_artifact_count count what the last completed cleanup did, or are null. The file byte count excludes database-partition and journal cleanup. It also does not measure the net change in the filesystem’s free space. The next timestamp is a timer estimate, not a guaranteed start time.

The example uses fictional measurements. The browser sends its existing session cookie, so the code contains no credentials.

const response = await fetch('/api/v1/system/status', {
credentials: 'same-origin',
headers: { Accept: 'application/json' }
});
if (!response.ok) throw new Error(`System status: ${response.status}`);
const status = await response.json();
{
"schema_version": 1,
"observed_at": 1789992000,
"scope": "host",
"uptime_seconds": 321987,
"cpu": {
"usage_percent": 18.4,
"logical_cpus": 4,
"load_average": [
0.25,
0.72,
0.46
]
},
"memory": {
"total_bytes": 8589934592,
"available_bytes": 5368709120,
"used_bytes": 3221225472,
"usage_percent": 37.5,
"swap_total_bytes": 0,
"swap_used_bytes": 0
},
"disks": [
{
"id": "root",
"mount_point": "/",
"total_bytes": 137438953472,
"used_bytes": 70866960384,
"available_bytes": 64424509440,
"reserved_bytes": 2147483648,
"usage_percent": 51.56,
"warning_below_bytes": 20615843020,
"critical_below_bytes": 6871947673,
"state": "ok"
}
],
"services": [
{
"id": "collector",
"state": "running"
},
{
"id": "detection",
"state": "running"
},
{
"id": "api",
"state": "running"
},
{
"id": "clickhouse",
"state": "running"
},
{
"id": "postgresql",
"state": "running"
},
{
"id": "frontend",
"state": "running"
}
],
"housekeeping": {
"state": "ok",
"last_finished_at": 1789988400,
"next_run_at": 1790074800,
"log_retention_days": 14,
"archive_count": 3,
"removed_file_bytes": 104857600,
"retired_artifact_count": 0
},
"age_seconds": 3,
"freshness": "fresh"
}

HTTP 401 means there is no valid human session. HTTP 403 means settings.read is denied. HTTP 503 returns {"error":"system_status_not_configured"} when monitoring is not configured. It returns {"error":"system_status_unavailable"} when the snapshot cannot be read or validated. A snapshot that is stale but valid still returns HTTP 200 with freshness: stale. A missing snapshot never produces a zero-valued response that looks healthy.