Skip to content

CLI of the API v2 (pandora-cli)

pandora-cli is a command-line client for the API v2. Every command is one HTTP request: the binary authenticates, converts the arguments and renders the response. Nothing else. All validation, permissions and business rules stay in the console, which is where they belong.

That defines what it can and cannot do. It does not replace the administration CLI pandora_manage: the API v2 does not expose everything the classic tool does yet — unlocking users, managing clusters, touching local configuration files, creating custom graphs or resetting counters, among others. The comparison of the three tools (pandora_manage, pandora_revent and pandora-cli) is in the administration CLI reference, in Part 09.

How to get it

The binary is distributed with the server package, where the Pandora AI service uses it, and it will also be available in the Marketplace (https://marketplace.pandorafms.com/), where it can be downloaded once published. This chapter gives no installation steps: when the Marketplace entry exists, that is the place.

It is built for Linux (x86-64 and ARM64), macOS (Intel and Apple silicon) and Windows (x86-64). The version tested for this edition is Linux x86-64.

Requirements

Three things, none of them optional:

  • An API v2 token. It is created in the console under the user whose permissions the CLI must use. Every command runs with that user's ACL profile. How to create it and how to send it is in chapter 13.1.
  • Network access to the console, over HTTP or HTTPS.
  • The client address allowed by the API ACL. The console restricts API access by IP. If the address is not on the list, every call fails with:
401 IP 10.0.0.5 is not in ACL list

That is fixed in the console, not in the CLI: the "IP list with API access" field under Administration → Setup → General. One IP per line.

Configuring access

Storing a token

auth login checks the token against the console before writing anything. If the console rejects it, nothing is stored.

pandora-cli auth login --token <token> --url https://console.example.com/pandora_console/api/v2/

The URL must point at the API root and end in /api/v2/. If omitted, the default is http://localhost/pandora_console/api/v2/.

The credentials are written to ~/.pandora-cli/config.json, with the directory at 0700 and the file at 0600. The token is stored base64-encoded: that keeps it out of a casual look at the terminal, but it is not encryption; the file permissions are what protect it. The CLI refuses to read a configuration whose permissions are wider than 0600. To keep it somewhere else, PANDORA_CLI_HOME.

Several consoles

Each console is a named context:

pandora-cli auth login --token <token> --url https://prod/pandora_console/api/v2/ --context prod
pandora-cli auth login --token <token> --url https://lab/pandora_console/api/v2/  --context lab --insecure

pandora-cli auth context list
pandora-cli auth context use prod
pandora-cli user list --context lab

--token and --url can also be passed to any command. Used that way, the token is never written to disk, which is what a CI job that already holds it in a secret wants. The price is that it ends up in the shell history and in the operating system's process list: do not use it on a shared machine.

Self-signed certificates

--insecure skips TLS verification. It is never applied by default. Passed to auth login, it is remembered for that context; passed to any other command, it applies to that run only.

Checking that it works

pandora-cli auth status
Context:  prod
URL:      https://console.example.com/pandora_console/api/v2/
Insecure: false
Config:   /home/user/.pandora-cli/config.json
Token:    valid
Version:  v8.0NG.805 (build PC260915)
MR:       805
Package:  805
LTS:      Feature Release

Console specification: 519 operations, 69 entities (read 2026-10-23T09:12:37Z)

Token: valid means the console accepted it. If not, the command exits with a non-zero code. The version, MR, package and LTS lines are what the console says about itself, and appear only when it says it. With -o json the output carries the same data in an object, plus a console object with the version when the console publishes it. --refresh re-reads the API description after upgrading the console.

Then, something real:

pandora-cli user list
IDUSER  FULLNAME  EMAIL              ISADMIN  DISABLED
admin   Pandora   [email protected]  true     false

1 shown, 1 total.

Correlation with Pandora AI sessions

--ai-session-id adds a correlation header (X-Pandora-AI-Session) to every request. It groups the calls of one work session in the audit trail.

  • In auth login, an explicit ID is stored in that context; without the option, the context keeps the one it had; and --ai-session-id= clears it.
  • In any other command it is transient: it applies to that run and does not touch the stored value. --ai-session-id= disables the header for that call.
  • A failed auth login writes nothing.

The resolution order is: explicit option, then the active context, then nothing. It is correlation metadata, not a credential: it does not authenticate or grant permissions. Whether the console records or displays it in the audit trail is explained in Pandora AI auditing.

The output

The output is a table on a terminal and JSON when redirected or piped, so a script does not have to ask for a format:

pandora-cli user list                      # table
pandora-cli user list | jq '.[].idUser'    # JSON
pandora-cli user list > users.json         # JSON

It can be forced with -o json, -o table or -o yaml. The informational lines (1 shown, 1 total.) appear only in table format; not in JSON or YAML, so what is piped is always valid. The command exits with 0 on success and non-zero on failure, so it can be used directly in an if.

Pagination and filters

Here is the number one trap of the CLI, and it comes from the source: --page starts at 1, while the API's page parameter starts at 0. The CLI translates, but it is worth knowing so as not to mix the two worlds. The API's pagination rules are in API conventions.

CLI option What it does
--page <n> Page number, 1-based. --page 1 is the first.
--size <n> Rows per page.
--limit <n> Maximum rows to return. Alternative to --page/--size.
--offset <n> Rows to skip. Alternative to --page/--size.

--limit and --offset cannot be mixed with --page and --size; the CLI refuses before sending anything. A list whose endpoint does not accept them, such as event list, does not offer them. If --size is passed without --page, the CLI sends both anyway, because some endpoints ignore the size without a page number.

How it maps to the API

The three advanced filters of the CLI are the API parameters under another name:

CLI option API parameter
--where fieldConditions
--fields requestedFields
--in multipleSearchString

--filter is different: it accepts any field of the entity and combines with AND. When the schema declares the field as an array, repeating --filter accumulates values instead of adding conditions, and an explicit null clears the field.

Whether --where, --fields and --in are accepted is decided per entity, not per console: /user/list may accept fieldConditions while /event/list rejects it. The CLI validates both sets locally and, when one is wrong, lists the valid names. event is the exception: it does not validate those three filters and lets the console decide.

When the console rejects a filter

If the entity does not accept the parameter, the response is a 400 and the CLI names the option that sent it:

Error: POST event/list failed: 400 Field: fieldConditions is not a valid parameter
--where (fieldConditions) is not available on this console.

The rest of the call is unaffected: only the rejected request fails. To see what the entity accepts in the installed version, pandora-cli <entity> --help.

A special case: dateRange

The date filter of event list does not accept the string "<start> - <end>": it wants JSON. A preset and a relative interval:

pandora-cli event list --filter 'dateRange={"preset":{"value":"last_24_hours"}}'
pandora-cli event list --filter 'dateRange={"start":{"mode":"relative","value":1,"unit":"hours"},"end":{"mode":"now"}}'

The old string fails with 400 Invalid date range format. Must be valid JSON. In Windows PowerShell 5.1 (and in PowerShell 7 before 7.3) the double quotes of the argument are lost before reaching the CLI, so they must be escaped:

pandora-cli event list --filter 'dateRange={\"preset\":{\"value\":\"last_24_hours\"}}'

Values are converted to their JSON type: true and false are booleans, digits are numbers and null is null. To force a string, quote it: --filter name='"42"'.

Creating and changing

--set adds a field to the body and can be repeated. For a full body, --from-file reads a JSON from a file or from standard input:

pandora-cli user create --set idUser=jdoe --set fullName='Jane Doe' --set password=secret
pandora-cli user update jdoe --set email=[email protected]
pandora-cli user delete jdoe --yes

pandora-cli user create --from-file user.json
cat user.json | pandora-cli user create --from-file -

--set and --from-file cannot be combined. --from-file accepts an object or a whole array, tolerates a UTF-8 BOM at the start (Windows editors) and is the only way to send nested objects and arrays.

--set converts values to their JSON type, and there is a classic trap: a text field whose value looks like a number is sent as a number. --set permissions=0755 sends 755. Quote it to force the string:

pandora-cli <entity> <verb> --set permissions='"0755"'

In a field declared as an array, repeating --set accumulates elements, and an explicit null clears the array. --set does not parse object or array literals: --set rules='{"agentGroup":2}' travels as text. For that, use --from-file.

delete asks for confirmation. In a non-interactive session it refuses instead of prompting, so a script that forgot --yes fails loudly instead of deleting silently.

Some rules live only in the console and do not appear in the field list:

  • agent create needs a real group: idGroup=0 is rejected with 400 Agent group is missing. The agent name is generated by the console; for the label you control, use alias.
  • module create needs idModule (the server type) together with idModuleType, not only the filter columns.
  • A newly created non-admin user needs at least one profile assigned with user profile add before it can log in.
  • The first rule of an event-alert-rule must carry operation=NOP; the console rejects any other.
  • module force-check requests an immediate check and answers 202 with no body: the check finishes on its own. Modules that do not support an immediate check, such as pushed-data modules, return 400.

Nested entities and groups

A nested entity takes the parent identifier first:

pandora-cli report-design-page list 12
pandora-cli report-design-page-widget list 12 3

Nested lists take the same list options as first-level ones, each only when the command declares it. Giving the same property with an option and with --set fails locally:

Error: --page conflicts with "page" already present in the payload: give it once

Some entities group part of their commands into groups, with the form <entity> <group> <verb> <ids…>: policy, collection, service, agent, module, log, pandora-ai-audit, rmm and notification. pandora-cli <entity> --help lists the groups of each one.

pandora-cli policy module list 7
pandora-cli collection file upload 3 --file ./a.conf
pandora-cli service element add 2 --set description='Frontend CPU' --set idAgenteModulo=42

Recipes and limits of the API v2

What follows is not the CLI manual: it is what the API does and does not tell you. It is grouped by domain because each one has its own quirks.

Block Origin
Agents, modules, policies, collections, downtimes, graphs, counters and 2FA Tested against a console
NCM: vendors, models, firmware, scripts, templates and ncm agent list Tested against a console
NCM on a device (enable, bulk, update, backup, queue, script) Documented from --help
RMM, notifications, e-mail, SIEM and Pandora AI tasks Documented from --help

In the "documented from --help" blocks the interface is described, not verified behaviour: check the response before trusting it.

Agents and modules

monitoring create pushes agent data. The body is an array with snake_case keys: agent_data and module_data.

cat > payload.json << 'EOF'
[
  {
    "agent_data": {"agent_name": "web1", "address": "10.0.0.5", "interval": 300},
    "module_data": [
      {"name": "cpu_usage", "type": "generic_data", "data": 12.5}
    ]
  }
]
EOF
pandora-cli monitoring create --from-file payload.json

agent_name, address and interval are required; every module_data entry needs a type. Re-sending the same agent, module and timestamp updates the value instead of duplicating it.

Two traps that cost an afternoon each:

  • Data for an agent that already exists is dropped silently if the payload does not name it the way the console stores it: agent_name must be the name, not the alias, and the agent needs a serverName matching the node. See them with pandora-cli agent get <id> -o json. An agent created through the API has a hashed name, an alias for display and no serverName.
  • Modules written this way need an asynchronous type (async_data, async_proc, async_string) to have a status and fire alerts. A generic_* stores the value but does not compute a status.

Policies

The policy queue is asynchronous: policy purge and the policy queue operations enqueue work and return without waiting. A policy cannot be deleted while it has pending queue entries or assigned agents: check policy queue list — or policy queue summary — and use policy queue clear, or wait.

Removing is not deleting. remove, delete and bulk-delete on a policy child (agent, alert, collection, group, module, plugin) only mark it pendingDelete; the effect arrives when the queue is applied, and restore undoes the mark. policy alert-action remove and policy queue delete are the exception: they act at once.

Removing an agent takes two steps: policy agent remove marks it, and policy queue apply-pending ignores agents in that state. The operation has to be queued:

pandora-cli policy agent remove 7 25
pandora-cli policy queue add 7 --set operation=delete --set idAgent=42

policyLinked has four states: 0 unlinked, 1 linked, 10 pending unlink and 11 pending link. module policy link and unlink move between them. The bulk-* plugin operations take a JSON array of identifiers, which --set cannot build: they go with --from-file. The day-to-day detail of policies, with their queue and their marks, is in Monitoring policies.

Collections

collection file upload sends multipart/form-data: files with --file (repeatable, at least one) and text fields with --set. collection file download returns bytes, so it requires --output-file; an existing file is replaced only with --force, and a failed download leaves no half-written file.

Assigning a collection to an agent (agent collection add) requires an agent with remote configuration (remote=1) available in the console. The assignment only lands in its remote configuration; after changing the files, run collection apply so the agents pick up the package. The collections chapter covers the rest.

Scheduled downtimes

dateFrom and dateTo are Unix timestamps, not readable dates. The downtime and what it covers are separate entities: scheduled-downtime-agent and scheduled-downtime-module are created apart, with the downtime identifier first. scheduled-downtime-module has no update: the module is removed and added again. The module in idAgentModule must belong to the agent in idAgent or the console answers 404.

Graphs

module graph does not return a binary image: it returns the image base64-encoded in the graph field, with its mimeType and its encoding next to it. period is in seconds (minimum 300; by default, one day).

pandora-cli module graph 12 --set period=3600 -o json | jq -r .graph | base64 -d > graph.png

graphType accepts only data or histogram; the line, area and bar styles belong to chartType. Any other graphType returns 400 Invalid value for graphType.

SIEM and auditing

  • siem-event and siem-log are read-only and need a SIEM backend configured in the console; without it, 503 Invalid or missing log backend configuration. They are not the same: siem-event searches events and siem-log searches the decoded logs. Without dates, they cover the last 24 hours.
  • log reads the records retained per agent and pages with a cursor: use --size and, for the next page, --cursor with the value returned by the previous one. It has no --page.
  • audit-log (alias audit) is read-only and reads the console audit trail. get <idSession> returns one entry with its extended data.

Notifications and e-mail

notification manages the console messages, their sources (read-only) and each user's preferences. message create requires idUser, subject and message; message update ignores read, which is read-only. email send sends a message through the console transport and email config shows the configuration without credentials.

Pandora AI

ai-task manages Pandora AI scheduled tasks: create requires firstRun (Unix timestamp) and periodicity accepts hourly, daily, weekly, monthly or yearly; notifySuccess and notifyError accept never, on_request or always. ai-notify send notifies the owner of a task and requires idScheduledTask, event, subject and message. The audit of the conversations is read with pandora-ai-audit, which is read-only.

RMM

rmm covers remote monitoring and management: agents, scripts, resources, routines, schedules, batch jobs and their queues. They are groups, not loose verbs: rmm agent, rmm batch, rmm pending-software, rmm queue, rmm resource, rmm routine, rmm rule, rmm schedule, rmm script and rmm settings. Fields that carry arrays, such as inputs or idAgentsRmm, are sent with --from-file. Routines have no delete for their agents or their schedules: they are marked with --set pendingDelete=true.

NCM

ncm manages network configuration: the agents under management, firmware, scripts, templates and vendors. It is a single entity with groups, and it has 51 commands. The script types are TEST, GET_CONFIGURATION, SET_CONFIGURATION, GET_FIRMWARE, SET_FIRMWARE, CUSTOM_TASK, SNIPPET and GET_OS_VERSION.

The regexp field of a script is a list of [expression, boolean] pairs, so it goes with --from-file:

echo '{"name":"Show version","idGroup":0,"type":"SNIPPET","content":"show version","regexp":[["^.*$",true]]}' \
  | pandora-cli ncm script create --from-file -

A template takes the identifier of an existing script in idScript; its type comes from that script and cannot be set. The NCM chapter covers the console side.

2FA and web sessions

user 2fa manages the second factor: status, reset (creates or rotates the secret; it appears only in that response), disable, bulk-disable and disable-all. reason is optional and goes to the audit trail. bulk-disable and disable-all ask for confirmation; disable-all affects the whole console, so check where you run it.

token session manages console sessions, the ones opened by the web interface and the mobile apps, which are not the API tokens of token create:

pandora-cli token session login --set id_user=jdoe --set password='...'
pandora-cli --token <access_token> token session logout

login needs no token. It returns access_token, access_expires_in and session_expires_at; if the account has a second factor, it returns status: mfa_required with an mfa_token, completed with token session login-mfa. A session cannot be renewed from the CLI: renewal needs the HttpOnly cookie the console sets, and the tool keeps no cookies. When it expires, log in again. Treat the access token as a password: out of the history and out of the logs.

Inspecting the API and diagnosing

spec reads the description the console publishes about itself, without opening the swagger.json by hand:

pandora-cli spec list                # published schemas
pandora-cli spec show EventFilter    # one schema, with allOf resolved
pandora-cli spec raw                 # the full swagger

The names are the ones the console publishes (EventFilter, ReportDataSource), not the CLI's hyphenated names; spec list lists them and spec show suggests the closest match if you mistype.

To see what is sent and what comes back, --verbose traces the request and the response status to standard error, and leaves standard output clean for piping:

pandora-cli user list --filter isAdmin=true -v -o json > users.json
→ POST https://console.example.com/pandora_console/api/v2/user/list
→ body: {"isAdmin":true}
← 200, 1834 bytes

pandora-cli docs prints the full reference of the installed build, and pandora-cli skill install leaves a usage skill for agents working in a terminal. Run it again after upgrading, so the skill keeps describing the binary that is there.

Common problems

Symptom Cause and remedy
401 ... token was rejected Wrong or expired token. Run auth login again.
401 IP ... is not in ACL list The address is not in the API ACL. Add it in the console.
403 ... lacks permission The token is valid, but its user's ACL profile does not allow the operation.
404 ... or the API base URL is wrong Check auth status: the URL must end in /api/v2/.
TLS verification failed Self-signed certificate. --insecure, or store it in the context at login.
has permissions 0644 The configuration file is readable by others. chmod 0600 ~/.pandora-cli/config.json.
--fields ... is not available on this console The entity does not accept that parameter; the CLI names the option that sent it.
unknown field "..." The field does not exist on the entity; the message lists the valid ones.
the "..." entity does not exist on this console The console does not publish that entity. Try auth status --refresh if you upgraded it.
A value such as 0755 arrives as 755 --set converts anything that looks numeric. Quote the value or use --from-file.
An object or array from --set arrives as text --set does not parse {...} or [...]. Use --from-file.
unknown flag: --limit That list does not support --limit/--offset. Use --page and --size.
A policy cannot be deleted It has pending queue entries or assigned agents. policy queue clear or policy purge, and wait.
A policy child is still there after remove It is only marked pendingDelete. Apply the queue or use restore.
A collection cannot be assigned to an agent The agent needs remote configuration (remote=1) available.

Command reference

Chapter 13.6 · CLI command reference lists the 75 entities and their commands, one page per domain. It is generated from the binary itself and is always in English:

pandora-cli docs                  # the same reference, from the installed build
pandora-cli <entity> --help      # the options of one specific command