Ravicor public API

Integrate Ravicor 7.2 with your ISP's systems: create API keys with per-area permissions, authenticate calls and consume JSON responses from any language.

Overview

The public API lets external ISP systems (ERP, CRM, automation scripts, in-house panels, provisioning systems) query and operate Ravicor without opening the web interface. Typical use cases:

  • Provision and delete ONTs on the OLT from the ISP's management system.
  • Query the status of monitored groups, devices and sensors, and also create, edit and delete these items via API. New in 7.2
  • Query PPPoE sessions on the concentrators: online users, history and traffic.
  • Manage domains and records of the authoritative DNS.
  • Send WhatsApp messages through the number paired in Ravi.
  • Monitor and manage the Flow environment (anti-DDoS) through external integration: live traffic, events, mitigation, whitelist and more. New in 7.2

The entire API runs over a single endpoint, with authentication by API keys created in the interface itself. Each key has independent permissions per system area: OLT, Devices, Concentrators, DNS, WhatsApp and Flow.

How calls are organized

Every request provides two routing parameters, in addition to the token:

ParameterWhat it isExamples
actionThe system area to be accessed.olt, dispositivo, concentradora, dns, whatsapp, flow
operationThe operation within the area.list_groups, overview, send

Summary of the available areas (each one has its own page in this documentation):

actionPermission on the keyWhat it covers
oltOLTs AccessActivation, deletion and query of ONTs, lookup by position and status summary.
dispositivoDevice AccessFull CRUD of groups, devices and sensors, SNMP discovery, catalog and topology.
concentradoraConcentrators AccessPPPoE sessions: listing, details, history, traffic and statistics.
dnsDNS AccessDomains and records of the authoritative DNS, recursive lookup.
whatsappWhatsApp AccessMessage sending and pairing status.
flowFlow Access New in 7.2About 36 monitoring and management operations for the anti-DDoS.
cpeACS access New in 7.269 CPE management operations: inventory, Wi-Fi/WAN/LAN, profiles, campaigns, routines and diagnostics.

Current API and legacy webservice

Older installations may have integrations pointing to the legacy webservice (/webservice/*.php), which authenticates with the username and password of a web login passed in the URL. That mechanism is kept only for compatibility. Every new integration should use the API described here, at /api/api.php, with an API key and per-area permissions.

The legacy webservice sends the username and password as plain text in the URL. That alone is reason enough to migrate old integrations to the current API.


Create an API key Master only

The API key is a random string of 32 alphanumeric characters, generated automatically by the system and stored encrypted. It is the only API credential: there is no user, password or session. Creating, changing and deleting keys requires being logged in with the Master account.

Step by step

  1. In the top menu, click the gear icon to open Settings.
  2. Open the Integrations tab and locate the API Management card.
  3. Click New API Key. If no key exists yet, the card shows the empty state No API key configured with the same button.
  4. In the API Key Management modal, the API Key field already comes filled with the generated key. Click Copy and store the key in a safe place now.
  5. Fill in Description (optional) with the integration name (for example, "ERP Integration" or "NOC Panel"). Once the key is masked, the description is the only way to identify it.
  6. Under Access Permissions, check the areas the integration will use. At least one is mandatory; otherwise the form shows the warning "Please select at least one access permission." and does not submit.
  7. Click Create API Key. The screen returns to the Integrations tab with the message API created successfully, and the key appears in the card list with a 2-hour countdown timer.

Permissions per area

The seven permission checkboxes appear in this order in the modal:

#PermissionEnables
1OLTs Accessaction=olt
2Device Accessaction=dispositivo
3Concentrators Accessaction=concentradora
4DNS Accessaction=dns
5WhatsApp Accessaction=whatsapp
6Flow Access New in 7.2action=flow
7ACS access New in 7.2action=cpe

In the current version, the label of the 2nd checkbox appears as "Concentrators Access", the same as the 3rd. Follow the order of the list above: the 2nd in the grid enables Devices and the 3rd enables Concentrators.

Apply the principle of least privilege: check only the areas the integration actually uses. The Select all row is useful only for testing.

2-hour copy window

The key stays visible and copyable for up to 2 hours after creation. After that period, it appears masked in the list (only the last 4 characters) and the copy button is disabled. Important: the key remains valid forever; only the display expires. If you did not copy the key in time, there is no way to recover it: delete it and create another.

Change a key

In the card list, each key has the Change and Delete buttons. The Change button reopens the modal with the title Change API Key, where you can change the description and the permissions, confirming with Update API Key.

Only use Change within the first 2 hours of the key's life. After that period the modal shows the masked key and, when saving, the masked value is written as the new key: the original key stops working and integrations start receiving Invalid token. To change the permissions of an old key, the safe path is to delete it and create another, updating the token in the integration.

Delete (revoke) a key

  1. In the API Management card list, click Delete on the key's row.
  2. Confirm in the Delete API dialog ("Are you sure you want to delete this API key?").
  3. The key is removed instantly, with the message API deleted successfully!. Revocation is immediate: the next call with that key receives HTTP 401 Invalid token.

Good practice: create one key per integration, always with the description filled in. That way you can revoke a specific integration without taking down the others.


Authentication

All calls go to a single endpoint on your Ravi server:

base URL
https://<YOUR-RAVI-SERVER>/api/api.php

Authentication is done exclusively through the token parameter, sent alongside the other call parameters. It is not an HTTP header: even if the client sends Authorization, it is not read. The accepted methods are GET and POST (form-urlencoded), and all parameters work in both. Avoid sending the same parameter via GET and POST in the same call: precedence varies by area.

Required parameters on every call:

ParameterTypeRequiredDescription
tokenstringYesThe 32-character API key created in the interface.
actionstringYesThe area: olt, dispositivo, concentradora, dns, whatsapp or flow (singular, lowercase, exactly like this).
operationstringYesThe operation within the area. Each area has its own list, documented on the corresponding page.

There is no session, cookie or login: each call is independent and self-contained. There is also no user associated with the key; the key gives direct access to the enabled areas.

Prefer POST + HTTPS in production. With GET, the token is recorded in the web server's access logs, in proxies and in the browser history. Enable HTTPS in the SSL Certificate tab of Settings. In case of token leakage, delete the key and create another.

First call: complete minimal example

The example below lists the device groups (requires the Device Access permission on the key). Replace the URL and the token with yours.

terminal
# POST with form-urlencoded (recommended in production)
curl -s -X POST "https://ravi.yourprovider.com/api/api.php" \
  -d "token=aB3xK9mP2qR7sT1vW5yZ8cD4fG6hJ0kL" \
  -d "action=dispositivo" \
  -d "operation=list_groups"
PHP
<?php
$url = 'https://ravi.yourprovider.com/api/api.php';
$dados = [
    'token'     => 'aB3xK9mP2qR7sT1vW5yZ8cD4fG6hJ0kL',
    'action'    => 'dispositivo',
    'operation' => 'list_groups',
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($dados));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$corpo  = curl_exec($ch);
$codigo = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$resposta = json_decode($corpo, true);

// Treat as an error: HTTP >= 400 OR body with "msg" / "status":"error" / "success":false
if ($codigo >= 400 || isset($resposta['msg']) || ($resposta['status'] ?? '') === 'error' || ($resposta['success'] ?? true) === false) {
    die('API error: ' . $corpo);
}

print_r($resposta['groups']);
Python
import requests

URL   = "https://ravi.yourprovider.com/api/api.php"
TOKEN = "aB3xK9mP2qR7sT1vW5yZ8cD4fG6hJ0kL"

r = requests.post(URL, data={
    "token": TOKEN,
    "action": "dispositivo",
    "operation": "list_groups",
}, timeout=30)

corpo = r.json()

# Treat as an error: HTTP >= 400 OR body with "msg" / "status":"error" / "success":false
if r.status_code >= 400 or "msg" in corpo or corpo.get("status") == "error" or corpo.get("success") is False:
    raise RuntimeError(f"API error: {r.text}")

print(corpo["groups"])

Expected response (the permission is correct and there are registered groups):

JSON response
{"groups":[{"id":1,"name":"Backbone","parent_id":0}, ...]}

The same pattern applies to any area. For example, an overview of the Flow environment (permission Flow Access):

terminal
curl -s -X POST "https://ravi.yourprovider.com/api/api.php" \
  -d "token=aB3xK9mP2qR7sT1vW5yZ8cD4fG6hJ0kL" \
  -d "action=flow" \
  -d "operation=overview"
# → {"status":"success","data":{"collector_online":true,"flows_per_sec":..., "events_active":0, ...}}

Gateway validation order

Every call passes through the validations below, in this order, before reaching the requested area:

  1. token missing: HTTP 400 with {"status":"error","message":"Token not provided"}.
  2. action missing: HTTP 400 with {"status":"error","message":"Action not provided"}.
  3. Token does not match any registered key: HTTP 401 with Invalid token.
  4. Valid key but without the area permission: HTTP 403 with Access denied for <area> (for example, Access denied for flow).
  5. action outside the list of areas: HTTP 400 with Invalid action.
  6. All good: the area validates the operation and its own parameters and responds.

The endpoint responds with open CORS, so technically you can call it directly from a web page. Avoid this: it would expose the token in the browser of any visitor. Always call the API from your backend.

Connectivity test

Before integrating a specific area, you can validate the server address and the token's validity in one shot with the ping action (the status action is an equivalent alias). It requires no operation and no area permission: a valid token is enough.

terminal
curl -s "https://ravi.yourprovider.com/api/api.php?action=ping&token=YOUR_TOKEN"
JSON response
{"status":"success","data":{"status":"online","versao":"2.0","servidor":"Ravicor"}}

A response with "status":"success" confirms the server is up and the token is valid. A missing or invalid token falls into the same gateway error responses (Token not provided, Invalid token). Use ping as the first step of any integration and as an API health monitor.


Response format

Every response comes with Content-Type: application/json; charset=utf-8. Internal server errors never leak into the response body; they go to the server log, preserving the JSON.

Gateway errors (token, permission, area) always use the envelope {"status":"error","message":"..."}. The success body, on the other hand, varies by area, inherited from different generations of the API. Each area's page shows the real format; here is the summary:

Area (action)SuccessOperation error
flow{"status":"success","data":{...}} on all operations{"status":"error","message":"..."} with HTTP 4xx/5xx
concentradora{"success":true,"data":[...]}{"success":false,"error":"..."} with HTTP 400/404
dispositivovaries by operation: direct object ({"groups":[...]}, {"devices":[...]}, {"sensors":[...]}...), {"msg":"ok", ...} on creations and {"status":"success", ...} on newer operations{"msg":"..."} or {"status":"error","message":"..."}, generally with HTTP 200
oltdirect object per operation{"msg":"..."} with HTTP 200
dnsdirect object per operation{"msg":"..."} with HTTP 200
whatsapp{"msg":"ok"} on send; {"status":{...}} on status query{"msg":"..."} with HTTP 200

Practical rule for the integrator: treat as an error any HTTP greater than or equal to 400 and any body with "status":"error" or "success":false. Do not rely on the HTTP code alone: the older areas respond 200 with {"msg":"..."} both when the operation fails and on some successes (for example, {"msg":"ok"}); in those areas, compare the value of msg with the operation's expected success message, shown on each area's page.

Common error messages

The gateway error messages come in English in the response body:

MessageHTTPCause
Token not provided400The token parameter was missing.
Action not provided400The action parameter was missing.
Invalid token401Nonexistent, revoked or rewritten key (see the warning about editing keys older than 2 hours).
Access denied for <area>403The key exists, but the permission for that area was not checked.
Invalid action400action outside olt/dispositivo/concentradora/dns/whatsapp/flow.
Please provide a valid operation200 (olt, dns, whatsapp, dispositivo) or 400 (flow, concentradora)The operation parameter was missing.
Invalid OLT operation / Invalid device operation / Invalid DNS operation / Invalid WhatsApp operation200Unknown operation in the area.
Invalid Flow operation400Unknown operation in the Flow area.
Operação inválida. Operações disponíveis: list, get, ...400Unknown operation in the concentrator (this message comes in the system language).
Database connection error500 or 200Problem in the Ravi server's database.
Database error200 (olt, dns, whatsapp, dispositivo) or 500 (flow)A database query failed on the Ravi server during the operation. In the legacy areas it arrives in the {"msg":"Database error: ..."} envelope, possibly with details after the colon; in the flow area it arrives as {"status":"error","message":"Database error"}.

Limits and best practices

What you need to know about the API's limits:

  • Load control: size your integration conservatively: avoid high parallelism and aggressive polling, and apply backoff on errors. Live queries work well with 5 to 10 second intervals.
  • Avoid aggressive polling: for "live" Flow data, intervals of 5 to 10 seconds already keep up with the collector's refresh; back off on errors.
  • Set the client timeout generously: some operations take long because they talk to real equipment. OLT operations, for example, open an SSH or Telnet session with the equipment before responding. Use 60 seconds or more for OLT operations (30 seconds covers the common queries) and handle the timeout in the integration instead of blindly retrying the call.
  • No key expiration: the key is valid until it is deleted. The 2-hour window applies only to on-screen display and copying.
  • No limit on the number of keys: create as many as you need. Even so, keep few keys and delete the unused ones: each call validates the token against all registered keys, and fewer keys also make auditing easier.
  • Resources depend on the server: the API does not replace configuring resources on the screen. For example, action=flow assumes the Flow environment is configured and running (which depends on an eligible plan), and action=whatsapp assumes WhatsApp is paired. If Flow responds with collector_online:false or empty data, the environment is not active on that server.

Security checklist

  • One key per integration, with Description (optional) always filled in: it is the only way to identify the key after it is masked.
  • Least privilege: check only the areas the integration uses. Select all for testing only.
  • Copy the key and store it in a password vault at the time of creation (2-hour window).
  • Use HTTPS and POST; never embed the key in a public web page.
  • Revoke (Delete button) the keys of deactivated integrations; revocation takes effect on the very next call.
  • Rotate the keys periodically. Since the key does not expire, rotation is manual: create a new key, update the token in the integration and delete the old one.
  • Do not use Change on keys older than 2 hours (not even for rotation); delete and recreate.

Frequent issues

SymptomLikely cause and solution
Invalid token in an integration that used to workSomeone opened Change on a key older than 2 hours and saved, rewriting the key with the masked value. Delete the key, create a new one and update the integration.
Invalid token right on the integration's first callSpaces or line breaks pasted along with the key. The token is compared exactly as sent, with no automatic cleanup; a single extra space already breaks authentication. Paste the key again, without extra characters.
HTTP 403 Access denied for <area>The key does not have the permission for that area. Edit the key (if it is less than 2 hours old) or recreate it with the permission checked.
The integration "thinks" it worked, but nothing happenedLegacy areas respond HTTP 200 with {"msg":"..."} on error. Check the response body, not just the HTTP code.
The key appears with asterisks on screenNormal behavior after 2 hours; the key keeps working. If it was not copied in time, create another.
action=flow responds, but with empty dataThe Flow environment is not configured or running on that server. Configure Flow through the interface before integrating.