Flow API New in 7.2

Complete reference for the Flow (anti-DDoS) environment API: follow traffic in real time, attack events, collector health and BGP routing, and manage mitigations, prefixes, lists and maintenance windows through external integration. There are 36 operations: 21 read and 15 write.

Overview

The Flow API exposes the entire Flow environment to external systems. It covers two broad uses:

  • Follow: live traffic per exporter and interface, top talkers, collector health, attack events, baseline anomalies, BGP routing alerts, active mitigations and settings.
  • Manage: trigger and remove mitigations (surgical FlowSpec or RTBH blackhole), resolve events and anomalies, mark false positives, register monitored prefixes, maintain the mitigation whitelist and the detection allowlist, enable and disable detection rules and exporters, and open or close maintenance windows.

Typical use cases: feed your own NOC dashboard (Grafana or similar) with Flow metrics, integrate DDoS alerts into ticketing systems, automate mitigation from external tools and silence detection during scheduled change windows via script.

Prerequisites

RequirementDetail
Plan with Flow Premium Flow+The Flow environment exists in the Premium Flow (1 exporter), Gold Flow (up to 4) and ENTERPRISE (unlimited) plans. Without a configured Flow environment, responses come back empty and collector_online stays false.
API key with Flow permissionWhen creating or editing the key in Settings, Integrations tab, API Management card, check the Flow Access permission in the Access Permissions section. See Create an API key.
Active Flow environmentCollector running, exporters registered and, to mitigate, mitigation BGP peers configured and active.
NetworkHTTPS access to the client's Ravi server.

A key with Flow Access has read and write over everything in the module: it can trigger a blackhole for any IP and disable detection rules. Treat it as a high-privilege credential: create a dedicated key per integration, fill in the Description (optional) field and do not check other unnecessary permissions.

The Flow API does not register exporters, detection rules or BGP peers. Those are created only through the interface, in the Flow environment. Through the API you can list them and enable or disable them (exporter_toggle and detection_toggle).


Call format

All operations use the single public API endpoint, with action=flow. GET and POST are accepted on every operation; prefer POST on write operations and whenever you want to keep the token out of access logs.

base URL
https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=OPERATION_NAME
ParameterTypeRequiredDescription
tokenstringyes32-character API key with the Flow Access permission.
actionstringyesAlways flow for this module.
operationstringyesThe desired operation (reference in the sections below).

The Flow module uses the standard envelope on 100% of its operations:

  • Success: {"status":"success","data":{...}} with HTTP 200.
  • Error: {"status":"error","message":"..."} with HTTP code 400, 401, 403, 404 or 500. Error messages are in English.

Errors common to all operations

HTTPmessageCause
400Token not provided / Action not providedMissing token or action.
401Invalid tokenNonexistent, wrong or revoked key.
403Access denied for flowKey without the Flow Access permission.
400Please provide a valid operationMissing operation.
400Invalid Flow operationUnknown operation.
500Database connection errorDatabase unavailable right when the connection opens.
500Database errorDatabase write failure. Returned by the write operations (event_resolve, anomaly_resolve, prefix_add, prefix_del, detection_toggle, whitelist_add, whitelist_del, allowlist_add, allowlist_del, exporter_toggle, maintenance_add, maintenance_end). Do not confuse it with Database connection error.

Concepts used in this reference

  • Collector: daemon that receives NetFlow/IPFIX/sFlow, detects attacks and speaks BGP to mitigate. The API does not speak BGP directly: mitigation commands are queued and the collector processes them within 1 second. The collector is considered online when the real-time snapshot is less than 30 seconds old.
  • Event: detected attack. Status: ativo, mitigando, resolvido. Severity: info, warning, critical. Each event carries a vector (precise classification: ampl_dns, syn_flood, carpet_bombing...) that guides the surgical FlowSpec mitigation.
  • Anomaly: deviation from the seasonal baseline, not necessarily an attack. Status: ativa or resolvida.
  • FlowSpec vs. RTBH: FlowSpec drops only the vector's traffic (e.g., UDP with source port 53); RTBH (blackhole) drops all traffic to the IP, a more drastic measure.
  • Mitigation whitelist: prefixes protected from automatic mitigation. It does not block manual or API mitigation.
  • Detection allowlist: anti false-positive exceptions, sources and destinations that detection should ignore.

Monitoring operations

The 21 read operations. The examples below use GET for brevity; POST also works. Dates and times follow the Ravi server's time zone, in YYYY-MM-DD HH:MM:SS format.

GET/api/api.php?action=flow&operation=overview

General summary of the environment: joins the live snapshot with database counters. Ideal for a Flow status light on an external dashboard. No parameters. Fields in data: collector_online, collector_version, snapshot_age_sec, flows_per_sec, total_in_bps/total_out_bps (sum of all exporters, in bits/s), exporters_total/exporters_active, prefixes_monitored, events_active (status ativo + mitigando), events_mitigating, anomalies_active, mitigations_active, bgp_alerts_open and bgp_rib ({ativa, v4, v6, built_at} or null).

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=overview"

{"status":"success","data":{"collector_online":true,"collector_version":"1.9.0",
 "snapshot_age_sec":3,"flows_per_sec":4210,"total_in_bps":3812345678,
 "total_out_bps":1523456789,"exporters_total":2,"exporters_active":2,
 "prefixes_monitored":14,"events_active":1,"events_mitigating":0,
 "anomalies_active":0,"mitigations_active":0,"bgp_alerts_open":0,
 "bgp_rib":{"ativa":true,"v4":1080342,"v6":210577,"built_at":1751540000}}}
GET/api/api.php?action=flow&operation=live

Real time per exporter and interface, plus top talkers. No parameters. Response: ts, collector_online, flows_per_sec, total_in_bps, total_out_bps, top (global top talkers, same format as the top operation) and exporters[]. Each exporter carries id, nome, total_in_bps, total_out_bps, top (that exporter only) and interfaces[] with if_index, nome, in_bps, out_bps, in_pps, out_pps and cap_bps (capacity; 0 = unknown).

Registered and active exporters that do not appear in the snapshot enter the list with sem_fluxo: true and zeroed rates: a sign that the router has stopped exporting flows.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=live"

{"status":"success","data":{"ts":1751540123,"collector_online":true,
 "flows_per_sec":4210,"total_in_bps":3812345678,"total_out_bps":1523456789,
 "top":{...},"exporters":[{"id":1,"nome":"NE8000 Borda","total_in_bps":3600000000,
  "total_out_bps":1400000000,"top":{...},"interfaces":[
   {"if_index":5,"nome":"100GE0/1/0 Transito","in_bps":3100000000,
    "out_bps":1200000000,"in_pps":410000,"out_pps":220000,"cap_bps":100000000000}]}]}}
GET/api/api.php?action=flow&operation=top

Top talkers from the live snapshot, top 10 per dimension, aggregated globally.

ParameterTypeRequiredDescription
dimensionstringnoFilters one dimension: src_ip, dst_ip, src_port, dst_port, proto, src_asn, dst_asn, nexthop, peer, src_upstream, dst_upstream, src_pais, dst_pais. Without it, returns all.

bytes and packets are accumulated within the collector's current 60-second bucket, not an instantaneous rate. For per-interface rates, use the live operation.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=top&dimension=dst_ip"

{"status":"success","data":{"dimension":"dst_ip","top":[
 {"valor":"203.0.113.10","bytes":812345678,"packets":654321}]}}
GET/api/api.php?action=flow&operation=health

Health of the collector, the database and the host. No parameters. Response: collector_online, snapshot_age_sec, fps, pps (sum of packets/s across interfaces), a health block with cumulative counters since the collector started (uptime_seg, pkts_recebidos, registros, drops_canal, drops_kernel, rss_mb, heap_mb, goroutines, rib_rotas, rib_mem_mb), rollup_lag_sec (historical write lag) and tables[]/tables_mb_total (size of the Flow tables in the database, useful to watch retention and disk).

Symptoms: drops_canal or drops_kernel growing indicate a saturated collector (CPU or flow volume); a high rollup_lag_sec indicates a slow database.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=health"

{"status":"success","data":{"collector_online":true,"snapshot_age_sec":2,
 "fps":4210,"pps":830000,"health":{"uptime_seg":864000,"pkts_recebidos":901234567,
 "registros":812345678,"drops_canal":0,"drops_kernel":0,"rss_mb":812,"heap_mb":540,
 "goroutines":64,"rib_rotas":1290919,"rib_mem_mb":310},"rollup_lag_sec":4,
 "tables":[{"name":"flow_amostras","rows":7100000,"mb":2210}],"tables_mb_total":3480}}
GET/api/api.php?action=flow&operation=exporters

Lists the registered exporters. No parameters. Items in data.exporters[]: id, nome, ip, modelo, versao (export protocol), sampling_rate, asn, descricao, ativo (0/1), status, motivo (text of the last problem) and datasinc.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=exporters"

{"status":"success","data":{"exporters":[{"id":1,"nome":"NE8000 Borda",
 "ip":"192.0.2.1","modelo":"Huawei NE8000","versao":"ipfix","sampling_rate":1000,
 "asn":64511,"descricao":"Transito","ativo":1,"status":"ok","motivo":null,
 "datasinc":"2026-07-03 10:00:00"}]}}
GET/api/api.php?action=flow&operation=interfaces

Known interfaces of the exporters.

ParameterTypeRequiredDescription
exporter_idintegernoFilters by exporter; without it, lists all.
example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=interfaces&exporter_id=1"

{"status":"success","data":{"interfaces":[{"id":10,"exportador_id":1,"if_index":5,
 "if_name":"100GE0/1/0","if_alias":"Transito","if_speed":100000000000,"monitorar":1}]}}
GET/api/api.php?action=flow&operation=prefixes

Monitored prefixes: the provider's (or clients') blocks that detection watches. No parameters. Items: id, cidr, nome, cliente, ativo, created_at.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=prefixes"

{"status":"success","data":{"prefixes":[{"id":3,"cidr":"203.0.113.0/24",
 "nome":"Bloco clientes","cliente":"","ativo":1,"created_at":"2026-06-01 09:00:00"}]}}
GET/api/api.php?action=flow&operation=events

Attack events, ordered by descending id.

ParameterTypeRequiredDescription
statusstringnoativo, mitigando, resolvido or the shortcut ativos (= ativo + mitigando).
severitystringnoinfo, warning or critical.
exporter_idintegernoFilters by exporter.
since_idintegernoOnly events with id greater than the value: use for incremental polling, keeping the last id seen.
limitintegernoDefault 100, maximum 1000.

Fields of each event: id, exportador_id, deteccao_id (the rule that triggered), tipo (signature: udp_flood, syn_flood, icmp_flood, amplification, dns_query_flood, generic_pps, generic_bps, volumetrico...), vetor (precise classification: ampl_dns, ampl_ntp, ampl_ssdp, ampl_memcached, ampl_chargen, ampl_cldap, ampl_snmp, ampl_netbios, udp_flood, tcp_flood, syn_flood, ack_flood, rst_flood, icmp_flood, dns_query_flood, frag, carpet_bombing, multi_vetor...), direcao (entrada/saida), dst_count, carpet (1 = carpet bombing), src_ip, dst_ip (IP, or CIDR in a carpet), dst_porta, proto, peak_pps, peak_bps, total_bytes, total_packets, severidade, status, mitigado (0/1), inicio, fim.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=events&status=ativos&severity=critical"

{"status":"success","data":{"events":[{"id":812,"exportador_id":1,"deteccao_id":4,
 "tipo":"amplification","vetor":"ampl_dns","direcao":"entrada","dst_count":1,"carpet":0,
 "src_ip":"198.51.100.53","dst_ip":"203.0.113.10","dst_porta":0,"proto":17,
 "peak_pps":920000,"peak_bps":7800000000,"severidade":"critical","status":"ativo",
 "mitigado":0,"inicio":"2026-07-03 10:12:04","fim":null}]}}
GET/api/api.php?action=flow&operation=event

Detail of an event with the anatomy of the attack.

ParameterTypeRequiredDescription
idintegeryesEvent id.

Response: event (all the event's fields) plus sources[] with the top attack sources (up to 200, ordered by packets): src_ip, src_asn, packets, pais, cidade. On outbound events, sources carries the external destinations hit. Errors: 400 Please provide a valid event id; 404 Event not found.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=event&id=812"

{"status":"success","data":{"event":{"id":812,"vetor":"ampl_dns", ...},
 "sources":[{"src_ip":"198.51.100.53","src_asn":64500,"packets":812345,
  "pais":"US","cidade":"Ashburn"}]}}
GET/api/api.php?action=flow&operation=anomalies

Seasonal baseline anomalies (traffic deviations, not necessarily attacks).

ParameterTypeRequiredDescription
statusstringnoativa or resolvida; without it, lists all (up to 500).

Items: id, tipo, ref1, ref2, direcao, label, baseline_bps (expected), atual_bps (measured), sigma (standard deviations), severidade, status, inicio, fim.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=anomalies&status=ativa"

{"status":"success","data":{"anomalies":[{"id":45,"tipo":"interface","label":"Transito in",
 "direcao":"entrada","baseline_bps":2100000000,"atual_bps":3900000000,"sigma":4.2,
 "severidade":"warning","status":"ativa","inicio":"2026-07-03 09:40:00","fim":null}]}}
GET/api/api.php?action=flow&operation=detections

Configured detection rules. No parameters. Items: id, nome, escopo (IP, prefix or interface), escopo_id, direcao, assinatura, limiar_pps, limiar_bps, janela_seg, severidade, auto_mitigar (0/1, a rule that can mitigate on its own), acao_mitig, rate_value, ativo.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=detections"

{"status":"success","data":{"detections":[{"id":3,"nome":"Flood UDP prefixos",
 "escopo":"prefixo","escopo_id":0,"direcao":"entrada","assinatura":"udp_flood",
 "limiar_pps":200000,"limiar_bps":0,"janela_seg":30,"severidade":"critical",
 "auto_mitigar":0,"acao_mitig":"discard","rate_value":0,"ativo":1}]}}
GET/api/api.php?action=flow&operation=mitigations

FlowSpec/RTBH mitigation rules.

ParameterTypeRequiredDescription
statusstringnoactive (default), withdrawn or expired; any other value lists all (up to 500).

Items: id, evento_id (null on manual ones), peer_id, tipo (flowspec/rtbh), match_json (announced FlowSpec match), dst_ip, acao (discard/ratelimit), rate_value, origem (auto/manual), status, announced_at, expires_at (null = no automatic expiration).

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=mitigations"

{"status":"success","data":{"mitigations":[{"id":21,"evento_id":null,"peer_id":1,
 "tipo":"flowspec","match_json":"{\"dst\":\"203.0.113.10/32\",\"proto\":17,\"sport\":53}",
 "dst_ip":"203.0.113.10","acao":"discard","rate_value":0,"origem":"manual",
 "status":"active","announced_at":"2026-07-03 10:13:00","expires_at":null}]}}
GET/api/api.php?action=flow&operation=whitelist

Prefixes protected from automatic mitigation. No parameters. Items: id, cidr, nome, ativo, created_at.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=whitelist"

{"status":"success","data":{"whitelist":[{"id":2,"cidr":"198.51.100.0/24",
 "nome":"Infra DNS","ativo":1,"created_at":"2026-06-10 08:00:00"}]}}
GET/api/api.php?action=flow&operation=allowlist

Detection exceptions (anti false-positive). No parameters. Items: id, escopo (src_asn, src_prefixo, dst_ip, dst_prefixo), valor, motivo, origem (manual/auto), expira_em, ativo, created_at.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=allowlist"

{"status":"success","data":{"allowlist":[{"id":7,"escopo":"src_asn","valor":"15169",
 "motivo":"CDN conhecida","origem":"manual","expira_em":null,"ativo":1,
 "created_at":"2026-06-15 14:00:00"}]}}
GET/api/api.php?action=flow&operation=peers

BGP peers. No parameters. Two lists in the response:

  • mitigation_peers[] (FlowSpec/RTBH announcement): id, nome, neighbor_ip, our_asn, peer_asn, flowspec_capable (0/1; without that capability, mitigation falls back to RTBH on that peer), rtbh_community, rtbh_next_hop, ativo, status.
  • route_peers[] (route collection for enrichment): id, nome, neighbor_ip, our_asn, peer_asn, descricao, relacao, multihop, ativo, status, prefixos_v4, prefixos_v6, datasinc.
example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=peers"

{"status":"success","data":{"mitigation_peers":[{"id":1,"nome":"Borda 1",
 "neighbor_ip":"192.0.2.1","our_asn":65001,"peer_asn":64511,"flowspec_capable":1,
 "rtbh_community":"64511:666","rtbh_next_hop":"192.0.2.254","ativo":1,
 "status":"established"}],"route_peers":[...]}}
GET/api/api.php?action=flow&operation=bgp

BGP/RIB enrichment and routing alerts (possible route hijack). No parameters. Response: collection_active, rib ({ativa, v4, v6, built_at}), route_peers[] (summary) and alerts[] with up to 200 items: id, tipo (origin_change, subprefix...), prefixo, origem_ant, origem_nova, detalhe, status (aberto...), detectado_em, visto_em.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=bgp"

{"status":"success","data":{"collection_active":true,
 "rib":{"ativa":true,"v4":1080342,"v6":210577,"built_at":1751540000},
 "route_peers":[...],"alerts":[{"id":9,"tipo":"origin_change","prefixo":"203.0.113.0/24",
 "origem_ant":"64511","origem_nova":"64500","detalhe":"...","status":"aberto",
 "detectado_em":"2026-07-03 08:00:00","visto_em":"2026-07-03 10:10:00"}]}}
GET/api/api.php?action=flow&operation=templates

Cataloged FlowSpec templates. No parameters. Items: id, nome, protocol, sport, dport, tcpflags, fragment, plen_op, plen, acao, rate_value. Applying a template is done through the interface; via the API, mitigation is done by vector (the mitigate operation).

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=templates"

{"status":"success","data":{"templates":[{"id":1,"nome":"Amplificacao DNS",
 "protocol":"17","sport":"53","dport":"","tcpflags":"","fragment":"",
 "plen_op":"","plen":"","acao":"discard","rate_value":0}]}}
GET/api/api.php?action=flow&operation=communities

BGP communities cataloged for reading during enrichment. No parameters. Items: id, community, nome, classificacao, descricao, ativo.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=communities"

{"status":"success","data":{"communities":[{"id":1,"community":"64511:100",
 "nome":"Clientes","classificacao":"customer","descricao":"","ativo":1}]}}
GET/api/api.php?action=flow&operation=holidays

Holidays for the seasonal baseline. On a holiday, the baseline uses a dedicated holiday day profile to avoid a false anomaly. No parameters. Items: id, data, nome, nacional, ativo.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=holidays"

{"status":"success","data":{"holidays":[{"id":12,"data":"2026-09-07",
 "nome":"Independencia do Brasil","nacional":1,"ativo":1}]}}
GET/api/api.php?action=flow&operation=maintenance

Maintenance windows (periods with detection and alerts silenced). No parameters. Up to 200 items, most recent first: id, inicio, fim (null if undefined), indefinida (0/1), escopo (global/exportador), exportador_id, motivo, criado_por (API when created from here), ativa, criado_em.

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=maintenance"

{"status":"success","data":{"maintenance":[{"id":7,"inicio":"2026-07-03 22:00:00",
 "fim":"2026-07-04 02:00:00","indefinida":0,"escopo":"exportador","exportador_id":1,
 "motivo":"Troca de uplink","criado_por":"API","ativa":1,
 "criado_em":"2026-07-03 10:00:00"}]}}
GET/api/api.php?action=flow&operation=settings

Flow settings, read only (there is no settings write operation in the API). No parameters. Response: settings (key and value map) and raw[] (with updated_at). Typical keys, which vary per installation: alerta_severidade_min, bgp_coleta_ativa, collector_addr, explorer_sampling, dados_historicos, retencao_rollup_dias, anomalia_alerta_sigma, postmortem_auto, threat_ativo, auto_minhas_redes, forecast_cache, mitig_ttl_seg (TTL of automatic mitigations, in seconds).

example
curl "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=settings"

{"status":"success","data":{"settings":{"alerta_severidade_min":"warning",
 "mitig_ttl_seg":"1800","bgp_coleta_ativa":"1"},"raw":[...]}}

Management operations

The 15 write operations. Prefer POST on all of them. Mitigation operations are queued for the collector, which processes them within 1 second; the queued:true response means "command accepted", not "BGP announcement made".

POST/api/api.php?action=flow&operation=mitigate

Triggers a mitigation for a destination: surgical FlowSpec built from the attack vector, or RTBH blackhole.

ParameterTypeRequiredDescription
dststringyesIP (203.0.113.10) or CIDR (203.0.113.0/24, for carpet bombing).
modostringnovetor (default, surgical FlowSpec) or rtbh (full blackhole of the destination).
vetorstringnoAttack vector used to build the FlowSpec (list in the events operation). E.g.: ampl_dns drops UDP with source port 53; syn_flood filters TCP with the S flag; frag filters fragments. Empty or unknown: broad match by proto/port.
protointegernoIP protocol number (17=UDP, 6=TCP...), used in the generic vectors and in the carpet.
portintegernoDestination port, used in udp_flood, tcp_flood and generic.
acaostringnodiscard (default) or ratelimit.
rateintegernoLimit in bps when acao=ratelimit.
event_idintegernoLinks to the event: it moves to the mitigando status and mitigado=1. The mitigation rule itself is stored without a link to the event; to withdraw it later, use mitigate_clear with dst.
grupo_idintegernoAnnouncement group (subset of peers); 0 or absent announces to all peers.

With modo=rtbh all traffic to the destination is dropped, including legitimate traffic: the IP stays offline until a mitigate_clear. Peers without FlowSpec capability apply RTBH even in modo=vetor (per-peer fallback). The mitigation whitelist does not block mitigate: it only protects against automatic mitigation.

Mitigations via the API (origem=manual) do not expire by TTL: expires_at stays null and the rule remains until an explicit mitigate_clear. And if no BGP peer is active, the mitigation fails silently: the API returns no error. Always confirm with operation=mitigations (a rule with origem:"manual", status:"active" should appear) about 2 seconds later.

Errors: 400 Invalid dst (use IP or CIDR); 500 Failed to enqueue mitigation command.

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=mitigate" -d "dst=203.0.113.10" -d "modo=vetor" \
  -d "vetor=ampl_dns" -d "event_id=812"

{"status":"success","data":{"queued":true,"modo":"vetor","dst":"203.0.113.10"}}
POST/api/api.php?action=flow&operation=mitigate_clear

Removes active mitigations (withdraws the BGP announcement). Also queued for the collector.

ParameterTypeRequiredDescription
event_idintegerone of the twoWithdraws the rules linked to the event (created by automatic mitigation) and clears its mitigado. Rules triggered by the API mitigate are not linked to the event: to withdraw them, use dst.
dststringone of the twoWithdraws all active rules for the destination (IP or CIDR).

If you send both parameters, the collector uses only event_id and ignores dst. To clear a standalone destination, send only dst.

Errors: 400 Provide event_id and/or dst; 500 Failed to enqueue clear command.

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=mitigate_clear" -d "dst=203.0.113.10"

{"status":"success","data":{"queued":true}}
POST/api/api.php?action=flow&operation=event_resolve

Marks an event as resolved (status=resolvido and fim = now). It does not remove mitigations: if any exist, use mitigate_clear before or after.

ParameterTypeRequiredDescription
idintegeryesEvent id.
example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=event_resolve" -d "id=812"

{"status":"success","data":{"id":812,"status":"resolvido"}}
POST/api/api.php?action=flow&operation=event_false_positive

Marks an event as a false positive: it resolves the event (with mitigado=0) and, if the target is a plain IP (not a CIDR), automatically adds that IP to the allowlist with dst_ip scope. Detection then starts ignoring that destination. The exception it creates is recorded with auto origin, which lets you tell it apart from manual entries when querying operation=allowlist.

ParameterTypeRequiredDescription
idintegeryesEvent id.

When the event target was a CIDR (carpet bombing), the response carries allowlist_added:null; in that case, consider using allowlist_add with dst_prefixo scope. Errors: 400 Please provide a valid event id; 404 Event not found.

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=event_false_positive" -d "id=812"

{"status":"success","data":{"id":812,"status":"resolvido","allowlist_added":"203.0.113.10"}}
POST/api/api.php?action=flow&operation=anomaly_resolve

Marks a baseline anomaly as resolved.

ParameterTypeRequiredDescription
idintegeryesAnomaly id.
example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=anomaly_resolve" -d "id=45"

{"status":"success","data":{"id":45,"status":"resolvida"}}
POST/api/api.php?action=flow&operation=prefix_add

Adds a monitored prefix. It is an upsert: if the CIDR already exists, it updates the name and client and reactivates the record.

ParameterTypeRequiredDescription
cidrstringyesCIDR or plain IP (IPv4 or IPv6).
nomestringnoBlock label.
clientestringnoName of the client that owns the block.

Error: 400 Invalid CIDR/IP.

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=prefix_add" -d "cidr=203.0.113.0/24" -d "nome=Bloco clientes"

{"status":"success","data":{"cidr":"203.0.113.0/24"}}
POST/api/api.php?action=flow&operation=prefix_del

Removes a monitored prefix. Idempotent: it responds deleted:true even if nothing matched.

ParameterTypeRequiredDescription
idintegerone of the twoPrefix id.
cidrstringone of the twoExact CIDR.

Error: 400 Provide id or cidr.

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=prefix_del" -d "cidr=203.0.113.0/24"

{"status":"success","data":{"deleted":true}}
POST/api/api.php?action=flow&operation=detection_toggle

Enables or disables a detection rule. Use operation=detections to discover the ids.

ParameterTypeRequiredDescription
idintegeryesRule id.
ativointegeryes0 or 1.

Errors: 400 Please provide a valid detection id / Provide ativo=0|1.

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=detection_toggle" -d "id=3" -d "ativo=0"

{"status":"success","data":{"id":3,"ativo":0}}
POST/api/api.php?action=flow&operation=whitelist_add

Protects a prefix from automatic mitigation (upsert; reactivates if it already exists). Typical use: critical infrastructure blocks, such as DNS and gateways, that must never take an automatic blackhole. It does not prevent manual or API mitigation.

ParameterTypeRequiredDescription
cidrstringyesCIDR or IP.
nomestringnoLabel.

Error: 400 Invalid CIDR/IP when cidr is neither a valid IP nor a valid CIDR (IPv4 or IPv6).

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=whitelist_add" -d "cidr=198.51.100.0/24" -d "nome=Infra DNS"

{"status":"success","data":{"cidr":"198.51.100.0/24"}}
POST/api/api.php?action=flow&operation=whitelist_del

Removes a prefix from the mitigation whitelist. Idempotent (deleted:true even without a match).

ParameterTypeRequiredDescription
idintegerone of the twoRecord id.
cidrstringone of the twoExact CIDR.
example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=whitelist_del" -d "cidr=198.51.100.0/24"

{"status":"success","data":{"deleted":true}}
POST/api/api.php?action=flow&operation=allowlist_add

Adds a detection exception (anti false-positive). Upsert with origem=manual.

ParameterTypeRequiredDescription
escopostringyessrc_asn, src_prefixo, dst_ip or dst_prefixo.
valorstringyesASN, prefix or IP according to the scope.
motivostringnoFree text, for auditing.

Errors: 400 Invalid escopo (src_asn|src_prefixo|dst_ip|dst_prefixo) / Provide valor.

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=allowlist_add" -d "escopo=src_asn" -d "valor=15169" -d "motivo=CDN conhecida"

{"status":"success","data":{"escopo":"src_asn","valor":"15169"}}
POST/api/api.php?action=flow&operation=allowlist_del

Removes a detection exception. It accepts only the id (it does not remove by value). Idempotent.

ParameterTypeRequiredDescription
idintegeryesException id (see allowlist).
example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=allowlist_del" -d "id=7"

{"status":"success","data":{"deleted":true}}
POST/api/api.php?action=flow&operation=exporter_toggle

Enables or disables an exporter. Disabling makes the collector ignore that router's flows; it does not change the equipment's configuration.

ParameterTypeRequiredDescription
idintegeryesExporter id.
ativointegeryes0 or 1.
example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=exporter_toggle" -d "id=1" -d "ativo=0"

{"status":"success","data":{"id":1,"ativo":0}}
POST/api/api.php?action=flow&operation=maintenance_add

Creates a maintenance window. During the window, detection and alerts for the scope are silenced. The window is recorded with criado_por=API and ativa=1.

ParameterTypeRequiredDescription
iniciodatetimenoYYYY-MM-DD HH:MM:SS; empty = now.
fimdatetimeconditionalRequired if indefinida is not 1.
indefinidaintegerno1 = no end (until closed manually); ignores fim.
escopostringnoglobal (default) or exportador.
exportador_idintegerconditionalNeeded when escopo=exportador.
motivostringnoText shown in the interface.

A window with indefinida=1 silences detection until someone closes it with maintenance_end. Do not forget open windows: the environment stays blind to attacks in the silenced scope.

Error: 400 Provide fim or set indefinida=1.

example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=maintenance_add" -d "fim=2026-07-04 02:00:00" \
  -d "escopo=exportador" -d "exportador_id=1" -d "motivo=Troca de uplink"

{"status":"success","data":{"created":true}}
POST/api/api.php?action=flow&operation=maintenance_end

Closes a maintenance window. Detection and alerts return to normal in the scope.

ParameterTypeRequiredDescription
idintegeryesWindow id (see maintenance).
example
curl -X POST "https://YOUR-RAVI/api/api.php" -d "token=KEY" -d "action=flow" \
  -d "operation=maintenance_end" -d "id=7"

{"status":"success","data":{"id":7,"ativa":0}}

Practical examples

Monitor attack events (incremental polling)

Query events with since_id, keeping the highest id already processed. This way no event is duplicated or lost, even with irregular intervals.

# new events since id 812, active/mitigating only
curl -s -X POST "https://YOUR-RAVI/api/api.php" \
  -d "token=KEY" -d "action=flow" -d "operation=events" \
  -d "status=ativos" -d "since_id=812"
<?php
$base = 'https://YOUR-RAVI/api/api.php';
$ultimoId = 812; // persist between runs
$resp = file_get_contents($base . '?' . http_build_query([
    'token' => 'KEY', 'action' => 'flow', 'operation' => 'events',
    'status' => 'ativos', 'since_id' => $ultimoId,
]));
$json = json_decode($resp, true);
if (($json['status'] ?? '') === 'success') {
    foreach ($json['data']['events'] as $ev) {
        printf("Event %d %s on %s (%s)\n",
            $ev['id'], $ev['vetor'], $ev['dst_ip'], $ev['severidade']);
        $ultimoId = max($ultimoId, $ev['id']);
    }
}
import requests

BASE = "https://YOUR-RAVI/api/api.php"
ultimo_id = 812  # persist between runs
r = requests.post(BASE, data={
    "token": "KEY", "action": "flow", "operation": "events",
    "status": "ativos", "since_id": ultimo_id,
}, timeout=15)
j = r.json()
if j.get("status") == "success":
    for ev in j["data"]["events"]:
        print(f"Event {ev['id']} {ev['vetor']} on {ev['dst_ip']} ({ev['severidade']})")
        ultimo_id = max(ultimo_id, ev["id"])

Mitigate an attack and confirm the rule

The recommended flow: trigger the mitigation by vector linked to the event, wait about 2 seconds and confirm in mitigations that the rule became active.

# 1) trigger surgical FlowSpec for DNS amplification
curl -s -X POST "https://YOUR-RAVI/api/api.php" \
  -d "token=KEY" -d "action=flow" -d "operation=mitigate" \
  -d "dst=203.0.113.10" -d "modo=vetor" -d "vetor=ampl_dns" -d "event_id=812"

# 2) ~2 s later, confirm the active rule
curl -s "https://YOUR-RAVI/api/api.php?token=KEY&action=flow&operation=mitigations"

# 3) when the attack ends, withdraw the announcement (via API it does not expire on its own)
curl -s -X POST "https://YOUR-RAVI/api/api.php" \
  -d "token=KEY" -d "action=flow" -d "operation=mitigate_clear" -d "dst=203.0.113.10"
<?php
function flow(array $params): array {
    $params += ['token' => 'KEY', 'action' => 'flow'];
    $ctx = stream_context_create(['http' => [
        'method' => 'POST',
        'header' => 'Content-Type: application/x-www-form-urlencoded',
        'content' => http_build_query($params),
    ]]);
    return json_decode(file_get_contents('https://YOUR-RAVI/api/api.php', false, $ctx), true);
}

$r = flow(['operation' => 'mitigate', 'dst' => '203.0.113.10',
           'modo' => 'vetor', 'vetor' => 'ampl_dns', 'event_id' => 812]);
if (($r['data']['queued'] ?? false) !== true) { exit("failed\n"); }

sleep(2); // wait for the collector to process the queue
$m = flow(['operation' => 'mitigations']);
foreach ($m['data']['mitigations'] as $regra) {
    if ($regra['dst_ip'] === '203.0.113.10' && $regra['status'] === 'active') {
        echo "Mitigation active (id {$regra['id']})\n";
    }
}
import time, requests

BASE = "https://YOUR-RAVI/api/api.php"

def flow(**params):
    params.update(token="KEY", action="flow")
    return requests.post(BASE, data=params, timeout=15).json()

r = flow(operation="mitigate", dst="203.0.113.10",
         modo="vetor", vetor="ampl_dns", event_id=812)
assert r["data"]["queued"] is True

time.sleep(2)  # wait for the collector to process the queue
m = flow(operation="mitigations")
ativa = [x for x in m["data"]["mitigations"]
         if x["dst_ip"] == "203.0.113.10" and x["status"] == "active"]
print("Mitigation active" if ativa else "Rule did not appear: check BGP peers")

# when the attack ends:
flow(operation="mitigate_clear", dst="203.0.113.10")

Silence detection during a change window

terminal
# open a 2h window for exporter 1
curl -s -X POST "https://YOUR-RAVI/api/api.php" \
  -d "token=KEY" -d "action=flow" -d "operation=maintenance_add" \
  -d "fim=2026-07-04 02:00:00" -d "escopo=exportador" -d "exportador_id=1" \
  -d "motivo=Janela de mudanca programada"

# if it ends earlier, close it from the list (operation=maintenance to find the id)
curl -s -X POST "https://YOUR-RAVI/api/api.php" \
  -d "token=KEY" -d "action=flow" -d "operation=maintenance_end" -d "id=7"

Polling best practices: overview, live and top read a lightweight collector snapshot and are cheap; 5 to 10 second intervals already keep pace with the collector. For events, always use since_id. Listing limits: events up to 1000 per call; anomalies and mitigations up to 500; BGP alerts and maintenance up to 200; event sources up to 200.


Troubleshooting

SymptomLikely cause and what to do
403 Access denied for flowKey without the Flow Access permission. Edit the key (within the 2-hour window) or create another with the permission checked.
collector_online:false everywhereCollector stopped or Flow environment not configured on that server. Check the Flow screen; the API does not replace the initial setup through the interface.
Exporter listed with sem_fluxo:trueThe router stopped exporting: lost configuration, a firewall blocking the UDP export ports (2055, 4739, 9995, 9996, 6343) or the equipment rebooted.
mitigate returns queued:true but nothing happensNo active mitigation BGP peer or a dropped BGP session. Check the status field in peers and then mitigations. The failure is silent: the API returns no error in this case.
Mitigation never "clears" on its ownExpected behavior: mitigations via the API have no TTL. Remove them with mitigate_clear. The automatic TTL (mitig_ttl_seg, default 1800 s) applies only to automatic mitigations.
mitigate_clear with dst did not clearAn event_id was sent along with it: the collector prioritizes the event and ignores dst. Resend with only dst.
Whitelist "did not work" against API mitigationExpected behavior: the whitelist blocks only automatic mitigation, not manual or API mitigation.
event_false_positive did not add to the allowlistThe event target was a CIDR (carpet bombing): allowlist_added comes back null. Add it manually with allowlist_add and dst_prefixo scope.
Duplicate events in pollingUse since_id with the highest id already processed, instead of filtering by date.
Huge numbers in topThese are bytes accumulated in the 60-second bucket, not bits per second. For rates, use live.
drops_canal/drops_kernel growing in healthCollector saturated by CPU or flow volume. A high rollup_lag_sec indicates a slow database.