Skip to content

Flow alert workspace and source CSV API

Implementation contract for Castles Flow 26.09.0-unified.15-workspace.1.

These read-only endpoints extend saved Castles Flow alert reports. Verify their availability on the installed release. The interface calls them alerts, but the API path and stored identity are still attacks and incident_id. Detection, protection actions and measured traffic are separate kinds of evidence. The workspace returns the detector transitions that were recorded and reports protection status as unknown.

GET /api/v1/detection/attacks/{id}/workspace returns the chronology, a chart window and whether source export is available. GET /api/v1/detection/attacks/{id}/sources.csv downloads the observed source IPv4 addresses.

Both need the installation’s HTTPS origin, an existing human session cookie and dashboard.read. Password sessions and optional passkey sessions go through identical authorization. Client X-API-Key credentials are not supported. The session is checked on every request. There is no new tenant selector and no per-object role model: dashboard.read grants the installation’s alert-read access.

id selects an existing saved report. An ID longer than 128 bytes or containing control characters gets 400. A missing report gets 404. Newly recorded alerts use UUIDs, and CSV export requires one. The server takes the target prefixes, vector, object ID and times from the saved report, so neither a current edit of the object nor a caller-supplied IP can widen that saved scope. A canonical host must have one IPv4 /32. A network uses its saved union of 1–256 valid IPv4 prefixes, and overlapping prefixes are selected as one union. From 26.09.0-unified.43, a carpet (detection_kind: carpet) uses its object’s saved prefixes the same way a network does.

Workspace accepts context_seconds and step_seconds. context_seconds is an unsigned integer: 0, 300 or 900, default 300. step_seconds is optional and takes 5, 30 or 60. If it is omitted, the server picks 30 when the expected exporters report a sampling rate above 1 in the chart window, and 5 otherwise. Unknown fields, duplicates, malformed values and any other values return 400. There is no paging, no arbitrary time interval, and no target, vector, country or ASN filter. step_seconds exists in releases after 26.09.0-unified.45. Earlier releases reject it with 400.

Let start be the saved start. Let finish be the saved end if it is positive, otherwise the last observed time, clamped to server time. The chart covers the first min(finish - start, 300) seconds plus the chosen context on each side. Its start is rounded down to the step. Its end is rounded up and capped at the beginning of the current step bucket. Only completed buckets are selected, with at most 421 positions at a 5-second step. Because rounding goes outward, the window can gain almost a full step even with zero context. Changing context or step does not change report totals or the CSV interval.

Counters are stored per 5 seconds. A wider step sums the packets and bits of its 5-second parts and divides by the step duration. That keeps bps and pps as per-second rates, in the same units as the saved thresholds and baselines. Collection for a 5-second part is confirmed when every expected exporter has stored records in it and none of them has unknown sampling. Expected exporters are the installation’s enabled active routers, the same inventory canonical detection uses. Unlisted senders never confirm collection. A step bucket is confirmed only when all its parts are. A confirmed bucket with no target records is 0. An unconfirmed one stays null. Observed target records are always returned, and under partial coverage they are lower bounds. The exporter inventory is read at request time and is not saved with the report.

Vector aggregate history must start within the preceding 24 hours. The tcp and amplification fallback histories use stored records and require the whole requested start within seven days. profiled_in uses the total-traffic vector. History becomes unavailable on expiry, an unsupported vector, unavailable scope or a query failure. Even then, the endpoint still returns the saved chronology if it can read it.

For a carpet, history shows the saved misuse vector toward all saved object prefixes. The CSV covers all traffic to them, not just the hosts counted in the carpet. history.threshold_bps and history.threshold_pps hold the carpet trigger, and baselines are null. Host counts and targets live in the saved report field carpet (Flow IP reports). events[].state does not include them.

HTTP 200 returns a single object with no wrapper. Times are UTC Unix seconds. Rates are nonnegative bps/pps. Absent observations and unknown sampling are null, never zero. The successful variant returns every field shown here. Unavailable variants omit fields as specified.

Field Type and meaning
incident_id string, the saved report ID.
timeline.events Array of at most 1000 latest stored transitions for this exact alert and object. Sorted by sequence ascending.
timeline.status complete if the stored event result fits the limit; partial if older events were omitted; unavailable for a legacy report. It does not certify traffic coverage.
timeline.limit/order/window 1000, sequence_ascending, latest_events. A legacy timeline has events: [], status: unavailable, reason: legacy_incident, limit: 1000 and omits order/window.
events[].event_id/incident_id Stable stored string IDs; sequence belongs to this alert, and gaps in sequence are possible.
events[].timestamp/sequence Nonnegative integer time and sequence.
events[].kind/actor/outcome detection, detector, recorded. These do not confirm a protection action.
events[].event/reason Stored strings. Current lifecycle events are open, reopen, close, escalate; reason explains the recorded transition.
events[].state Snapshot with phase, freshness (strings), pps, bps, threshold_pps, threshold_bps (numbers), baseline_pps, baseline_bps (nullable numbers).
history.rows Dense ascending array of {timestamp,bps,pps,coverage}. coverage is complete (every expected exporter delivered records in every 5-second part), partial (some did), none (none did) or unverified (no valid exporter inventory or coverage read). Rates are 0 only in complete buckets without target records; other missing positions keep both rates null. Unavailable history returns an empty array.
history.from/to/step_seconds Integer chart bounds and the applied step (5, 30 or 60); omitted when history cannot be queried.
history.steps/step_default/sampling_rate [5,30,60]; the step chosen without step_seconds; the highest sampling rate of the expected exporters in the window, or null when unknown. Omitted when history cannot be queried.
history.scope/vector Scope saved_target_vector; vector is the saved supported detector vector. Vector is omitted when unavailable.
history.threshold_bps/threshold_pps/baseline_bps/baseline_pps Saved numeric or nullable reference values, not newly inferred baselines; omitted in an unavailable result.
history.coverage complete when every bucket is confirmed, otherwise partial or unavailable. See reasons below.
history.coverage.buckets_present/buckets_expected Nonnegative counts; present counts rows with a rate, including confirmed zeros. Omitted if query unavailable.
history.coverage.buckets_covered/exporters_expected Number of complete rows and size of the expected exporter inventory; null when coverage is unverified. Omitted if query unavailable.
history.coverage.incident_interval_partial True if the recorded alert duration extends past its first 300 seconds; independent of missing buckets. Omitted if query unavailable.
sources Available: status: available, integer from/to, scope: all_traffic_to_saved_targets, boolean interval_partial, export_limit: 100000. This validates saved metadata, not current record availability.
sources unavailable status: unavailable, from: null, to: null, same scope/limit and reason: saved_source_interval_unavailable; no interval_partial.
protection Exactly {status: unknown, reason: no_linked_actions}. There is no inferred BGP request, announcement, removal or filtering result.

History coverage has these reasons. expected_exporters_observed means every bucket is confirmed. expected_exporters_partially_observed means rates exist but not every bucket is confirmed. observed_buckets_exporter_coverage_unverified means coverage could not be read but target records exist. no_observed_buckets means no row has a rate. scoped_history_unavailable, query_busy and saved_scope_unavailable mean the chart cannot be produced. A sparse or unknown history does not close an alert. A detector close is not evidence of traffic filtering. An empty or bounded transition log does not prove that no protection actions happened elsewhere.

All workspace history and CSV requests share one scan slot per API process. A scan gets one storage thread, at most 2,000,000 read rows, 128 MiB of query memory, a six-second query limit and an eight-second HTTP timeout. The history response budget is 256 KiB. CSV query results get 4 MiB. When the slot is saturated, history returns HTTP 200 with query_busy and CSV returns 429. Saved chronology can stay available after history or raw records expire. The exporter coverage read uses the same slot and limits, except it may read up to 60,000,000 rows, and it reads only the time, exporter and sampling columns. If that read fails, history comes back with unverified rows.

Run these after signing in with the required permission. All IDs, addresses and observations below are fictional. The first response shows an active alert with ten seconds of observations and context_seconds=0.

const id = 'a2b3c4d5-1111-4222-8333-123456789abc';
async function readJson(path) {
const response = await fetch(path, { credentials: 'same-origin' });
const text = await response.text();
if (!response.ok) throw new Error(`HTTP ${response.status}: ${text}`);
return JSON.parse(text);
}
const report = await readJson(`/api/v1/detection/attacks/${id}`);
const workspace = await readJson(
`/api/v1/detection/attacks/${id}/workspace?context_seconds=0`
);
{
"incident_id": "a2b3c4d5-1111-4222-8333-123456789abc",
"timeline": {
"events": [
{
"event_id": "a2b3c4d5-1111-4222-8333-123456789abc:1",
"incident_id": "a2b3c4d5-1111-4222-8333-123456789abc",
"timestamp": 1700000100,
"sequence": 1,
"kind": "detection",
"event": "open",
"reason": "threshold_confirmed",
"actor": "detector",
"outcome": "recorded",
"state": {
"phase": "active",
"freshness": "fresh",
"pps": 1000,
"bps": 800000,
"threshold_pps": 500,
"threshold_bps": 0,
"baseline_pps": null,
"baseline_bps": null
}
}
],
"status": "complete",
"limit": 1000,
"order": "sequence_ascending",
"window": "latest_events"
},
"history": {
"rows": [
{
"timestamp": 1700000100,
"bps": 800000.0,
"pps": 1000.0,
"coverage": "complete"
},
{
"timestamp": 1700000105,
"bps": null,
"pps": null,
"coverage": "none"
}
],
"from": 1700000100,
"to": 1700000110,
"step_seconds": 5,
"steps": [5, 30, 60],
"step_default": 5,
"sampling_rate": 1,
"scope": "saved_target_vector",
"vector": "udp",
"threshold_bps": 0,
"threshold_pps": 500,
"baseline_bps": null,
"baseline_pps": null,
"coverage": {
"status": "partial",
"reason": "expected_exporters_partially_observed",
"buckets_present": 1,
"buckets_expected": 2,
"buckets_covered": 1,
"exporters_expected": 1,
"incident_interval_partial": false
}
},
"sources": {
"status": "available",
"from": 1700000100,
"to": 1700000110,
"scope": "all_traffic_to_saved_targets",
"interval_partial": false,
"export_limit": 100000
},
"protection": {
"status": "unknown",
"reason": "no_linked_actions"
}
}

Complete response for a saved legacy report without canonical scope:

{
"incident_id": "a2b3c4d5-1111-4222-8333-123456789abc",
"timeline": {
"events": [],
"status": "unavailable",
"reason": "legacy_incident",
"limit": 1000
},
"history": {
"rows": [],
"scope": "saved_target_vector",
"coverage": {
"status": "unavailable",
"reason": "saved_scope_unavailable"
}
},
"sources": {
"status": "unavailable",
"from": null,
"to": null,
"scope": "all_traffic_to_saved_targets",
"reason": "saved_source_interval_unavailable",
"export_limit": 100000
},
"protection": {
"status": "unknown",
"reason": "no_linked_actions"
}
}

CSV takes no query parameters. Anything supplied is ignored and cannot change scope or time. The export selects every observed source IPv4 address from stored records addressed to the saved targets during the report’s exact [coverage.from,coverage.to) interval. The report must be canonical, with coverage status complete or partial, scope all_traffic_to_saved_targets, a start equal to the alert start, and a duration no longer than the first 300 seconds. Its end cannot exceed the saved finish. The interval start must be within seven days of server time.

This is all traffic to the targets. It is not limited to the triggering vector, and it is not a list of proven attackers. Sampling cannot recover addresses that were never observed. Export does not depend on the displayed top 100 IPs or on browser country/ASN/IP filters, and the server does not add addresses from context or other objects.

Successful output is UTF-8 with a BOM and CRLF line endings: a single source_ip column, unique IPv4 values sorted numerically, at most 100,000 addresses. The server buffers and validates the body before the download succeeds. Excess size, unavailable or expired data and malformed results return an error, never a partial file. If no source records remain, the server returns 503 rather than an empty successful file.

X-Source-Count counts the exported addresses. The coverage headers carry the exact Unix-second bounds. X-Source-Coverage-Partial: true means the saved source interval ends before the alert’s saved finish. It does not mean the address list was truncated, and it does not vouch for traffic completeness. In that case the filename gets -partial-interval appended. X-Source-Scope is all_traffic_to_saved_targets. Even a complete saved interval can have incomplete observation or unavailable geography.

Using the same saved ID:

const response = await fetch(`/api/v1/detection/attacks/${id}/sources.csv`, {
credentials: 'same-origin'
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
const sourceCount = response.headers.get('X-Source-Count');
const from = response.headers.get('X-Source-Coverage-From');
const to = response.headers.get('X-Source-Coverage-To');
const intervalPartial = response.headers.get('X-Source-Coverage-Partial') === 'true';
const csvBlob = await response.blob();

Example headers and body. The displayed body leaves out the invisible BOM, and the line breaks shown are encoded as CRLF:

HTTP/1.1 200 OK
Content-Type: text/csv; charset=utf-8
Content-Disposition: attachment; filename="sources-a2b3c4d5-1111-4222-8333-123456789abc-1700000100-1700000110.csv"
Cache-Control: no-store
X-Content-Type-Options: nosniff
X-Source-Count: 2
X-Source-Coverage-From: 1700000100
X-Source-Coverage-To: 1700000110
X-Source-Coverage-Partial: false
X-Source-Scope: all_traffic_to_saved_targets
source_ip
198.51.100.10
203.0.113.20

The existing list/detail report contract is described in Flow IP reports. New enrichments add coverage.report_schema: 2. Older reports may lack these fields, and closed historical reports are not backfilled automatically. Do not fill absent fields with zeros or geography.

Analytics cover the saved source interval and all traffic to its targets, independent of vector history. source_summary.packets and .bytes are nonnegative, sample-weighted UInt64 JSON numbers. .avg_packet_size is bytes/packets, or null at zero packets. These are amounts, not rates. Do not apply any additional sampling factor. Integers beyond JavaScript’s safe range need precision-preserving parsing.

top_src_ips[] and top_dst_ips[] keep ip, packets, bytes, country, asn and add asn_number (integer) and asn_name (string). Unknown geography is country: Unknown, asn_number: 0, asn_name: Unknown, asn: "". top_countries[] has name, packets, bytes; top_asns[] has asn (integer), name, packets, bytes. These are independent rankings over the whole scope, not sums of the displayed IP table.

tcp_flags_dist[] holds {flags,packets,bytes} for observed TCP flag combinations only, up to 256 rows. Flags are a bitmask, not independent memberships: 18 is SYN+ACK. With no TCP observations the array is empty. Port and IP rankings stay capped at 100 rows in detail and 20 in the list. Country and ASN rankings need both local geography datasets and no more than 20,000 observed sources. Otherwise the rankings are empty and the unique country/ASN counts are null. Individual unresolved lookups can still appear as Unknown even when geo_complete is true.

The enriched coverage also has from, to, scope, reason, geo_complete (boolean) and sample_records (integer). Status is partial for a first-five-minute interval or unavailable geography. Otherwise it is complete, and that describes this stored report calculation, not full exporter capture. Unknown sampling or missing records can make enrichment unavailable. Below is the complete set of changed analytics fields for one fictional report. Unchanged report identity and lifecycle fields are described on the linked page.

{
"source_summary": {
"packets": 5000,
"bytes": 500000,
"avg_packet_size": 100.0
},
"top_src_ips": [
{
"ip": "198.51.100.10",
"packets": 3000,
"bytes": 300000,
"country": "Unknown",
"asn_number": 0,
"asn_name": "Unknown",
"asn": ""
},
{
"ip": "203.0.113.20",
"packets": 2000,
"bytes": 200000,
"country": "Unknown",
"asn_number": 0,
"asn_name": "Unknown",
"asn": ""
}
],
"top_dst_ips": [
{
"ip": "192.0.2.7",
"packets": 5000,
"bytes": 500000,
"country": "Unknown",
"asn_number": 0,
"asn_name": "Unknown",
"asn": ""
}
],
"top_countries": [
{
"name": "Unknown",
"packets": 5000,
"bytes": 500000
}
],
"top_asns": [
{
"asn": 0,
"name": "Unknown",
"packets": 5000,
"bytes": 500000
}
],
"tcp_flags_dist": [],
"coverage": {
"status": "complete",
"from": 1700000100,
"to": 1700000110,
"reason": "saved_scope_observed",
"scope": "all_traffic_to_saved_targets",
"geo_complete": true,
"sample_records": 50,
"report_schema": 2
}
}

Available from 26.09.0-unified.18. Earlier workspace endpoints remain compatible.

The saved report may include an optional string coverage.source_status set to expired when its entire validated source interval falls outside the seven-day raw-record retention window. A missing marker does not guarantee that source records are available. The field belongs to the saved report’s coverage, not the workspace’s history.coverage.

A temporary enrichment failure keeps previously successful analytics and their original coverage. Expiry keeps them too and only adds coverage.source_status. A saved complete or partial status stays as it was, along with its original reason, bounds and quality fields. If no successful analytics were saved, expiry sets coverage.status: unavailable and coverage.reason: source_expired together with the marker. source_expired does not replace the reason on a successful report.

Once a report is marked expired, the source-enrichment job is not retried, not even after later detector lifecycle updates. The marker does not close the alert, does not confirm a protection action and does not make expired records available for CSV export.

These fragments show only the coverage status fields; other saved report fields are left out. For the successful example above, expiry adds the marker and keeps the reason:

{
"coverage": {
"status": "complete",
"reason": "saved_scope_observed",
"source_status": "expired"
}
}

If no successful analytics were saved:

{
"coverage": {
"status": "unavailable",
"reason": "source_expired",
"source_status": "expired"
}
}

Handlers and authentication/query rejection return an HTTP status with plain text. There is no stable JSON error envelope, so check the status before parsing JSON. A workspace 200 can still contain unavailable subsections.

HTTP Workspace CSV
400 Invalid ID, query decoding, unknown parameter, unsupported context or step. Invalid ID.
401 Missing, expired or revoked human session. This includes disabled accounts. Same.
403 Missing dashboard.read. Same.
404 Saved report not found. Same.
422 Not used by this handler. Canonical scope missing; source interval pending, invalid or expired; invalid canonical UUID; more than 100000 addresses.
429 History uses 200 with query_busy. Shared scan slot busy; retry later. No Retry-After header is supplied.
500 Infrastructure authentication errors may propagate. Export header construction failure; infrastructure errors may propagate.
503 Saved report or chronology storage unavailable. Saved report storage/query/result unavailable, response budget exceeded, invalid source result or no remaining records.

Observed Flow accounting and P95.