The MispQL guide
MispQL is an SQL-like language for searching MISP; mispql is the command-line
client that speaks it. This guide covers both. Every example shows the statement and the
request it turns into, exactly as mispql --dry-run prints it.
How it works
A statement names a table, the conditions rows must meet, and how to print them. mispql
checks the whole statement, compiles it into one request to that table's
restSearch endpoint, with the conditions as the request's query,
and sends it with your API key. MISP evaluates the conditions within what your user may see,
as on any other API call, and mispql prints the rows it answers with.
SELECT * FROM attributes WHERE type = 'domain' AND value LIKE '%.example.com' LIMIT 50
POST /attributes/restSearch
{
"returnFormat": "json",
"limit": 50,
"page": 1,
"query": {
"AND": [
{
"type": "domain"
},
{
"value": {
"LIKE": "%.example.com"
}
}
]
}
}
mispql only searches: nothing is ever written to MISP. A condition can only narrow what your user is allowed to see, never widen it.
Setting up
Requirements
- A MISP 3.0 server.
- A role with the Complex query permission, or a site administrator. It is
off for every role until an administrator turns it on. It is needed for every statement with a
WHERE, forDESCRIBEandSHOW TABLES, and for any search on the tables other than attributes, events, objects and galaxy clusters. Without it MISP answers 403. - Python 3.11 or later on the machine running mispql.
A MISP without complex queries does not refuse a WHERE: it leaves the condition
out and answers as if there were none, with every row or every event counted. So before the
first statement with a WHERE, mispql asks MISP whether it runs them
(GET /attributes/queryDescribe), once per database. When it does not answer with
its tables, the statement stops with an error and is not sent: a 404 means that MISP does not
support complex queries, a 403 that the key may not use them or that MISP does not support
them.
Install
From a checkout of the mispql repository:
python3 -m venv .venv
.venv/bin/pip install .
Configuration
mispql reads the first config file it finds: the one given with --config, else
$MISPQL_CONFIG, else config.toml next to the package, else
~/.config/mispql/config.toml. Each profile is a TOML table; [default]
is used unless --profile names another.
[default]
url = "https://misp.example.org"
key = "..." # chmod 600 the file
verify_ssl = true # or the path of a CA bundle
timeout = 300 # seconds to wait for an answer
[readonly] # another account on the same MISP
url = "https://misp.example.org"
key = "..."
[test]
url = "https://misp-test.example.org"
key = "..."
MISPQL_URL and MISPQL_KEY override the file, and
--key-file PATH reads the key from a file of its own. The key is never a
command-line argument, where other users of the machine could see it. Without a key, mispql
asks for one when it runs at a terminal. A config file holding a key that others can read
gets a warning.
Running mispql
mispql # the interactive prompt, at a terminal
mispql -e "SELECT ...; SELECT ...;" # statements on the command line
mispql script.mql # statements from a file
mispql < script.mql # or from stdin
Every statement of a script is checked before the first one is sent, and the script stops at the first statement that fails. Results go to stdout; errors and warnings to stderr.
-- this week's events: how many, then the newest ten
SELECT COUNT(*) FROM events WHERE date >= '7d';
SELECT id, date, info FROM events WHERE date >= '7d' ORDER BY event_id DESC LIMIT 10 FORMAT table;
POST /events/restSearch
{
"returnFormat": "json",
"limit": 1,
"page": 1,
"metadata": 1,
"query": {
"date": {
">=": "7d"
}
}
}
POST /events/restSearch
{
"returnFormat": "json",
"metadata": 1,
"limit": 10,
"page": 1,
"order": [
"id desc"
],
"query": {
"date": {
">=": "7d"
}
}
}
The prompt
Enter runs the input once it ends with ;; Alt-Enter runs it as it is. Tab
completes keywords, table names and, after FROM, the fields of that table. Type
help for a syntax summary; Ctrl-C clears the input or stops a running query;
quit or Ctrl-D leaves. History is kept in
~/.local/state/mispql/history (or under $XDG_STATE_HOME), readable
by you alone.
Options
| Option | |
|---|---|
-e TEXT | run these statements |
--config PATH | the config file to use |
--profile NAME | the profile (TOML table) of the config file |
--key-file PATH | read the API key from this file |
-v, --verbose | print each request to stderr as it is sent |
--dry-run | print the requests the statements compile to and send nothing; needs no server and no key |
Exit codes
| Code | Meaning |
|---|---|
| 0 | every statement ran |
| 1 | a statement failed |
| 2 | a usage, input or configuration error |
| 130 | interrupted |
| 141 | stdout was closed early, as by | head |
Databases
Each profile of the config file is a database: one MISP and one API key. Two profiles can
point at the same MISP with different accounts, to see what each of them sees.
SHOW DATABASES lists the profiles and asks each MISP whose key it is; a MISP that
does not answer, or turns the key down, says so in its row.
SHOW DATABASES
+---+----------+-------------------------------+---------------------+-----------+-------+
| | database | url | email | role | org |
+---+----------+-------------------------------+---------------------+-----------+-------+
| * | default | https://misp.example.org | analyst@example.org | Org Admin | CIRCL |
| | readonly | https://misp.example.org | reader@example.org | Read Only | CIRCL |
| | test | https://misp-test.example.org | (key rejected) | | |
+---+----------+-------------------------------+---------------------+-----------+-------+
3 databases
GET /users/view/me (default)
GET /users/view/me (readonly)
GET /users/view/me (test)
USE switches to another database once its MISP accepts the key. At the prompt
it says who you are now, and the prompt shows the database in use
(mispql [readonly]>); in a script, each statement runs on the database chosen
last. WHOAMI shows the current one.
USE readonly
GET /users/view/me (readonly)
WHOAMI
+----------+--------------------------+--------------------+-----------+-------+
| database | url | email | role | org |
+----------+--------------------------+--------------------+-----------+-------+
| readonly | https://misp.example.org | reader@example.org | Read Only | CIRCL |
+----------+--------------------------+--------------------+-----------+-------+
GET /users/view/me
Keys never cross databases: MISPQL_URL, MISPQL_KEY and
--key-file apply to the database the session starts with, and every other profile
is used as written. A profile without a key asks for one at a terminal. Names with capitals,
dots or spaces go in backticks: USE `Prod.EU`.
Statements
SELECT * | COUNT(*) | column, ... FROM table
[WHERE condition]
[ORDER BY field [ASC | DESC], ...]
[LIMIT n [OFFSET n]]
[FORMAT word];
DESCRIBE table;
SHOW TABLES;
SHOW DATABASES;
USE database;
WHOAMI;
- Keywords can be written in any case. Table and field names are case-insensitive.
- A name in backticks is taken as written: for a keyword used as a name
(
`count`), for a name with characters other than letters, digits and_, or to keep its case. - Strings take single or double quotes; a doubled quote inside stands for one
(
'O''Brien'). Numbers are whole numbers, negative ones too; a word starting with a digit, such as'7d', needs quotes.TRUEandFALSEare booleans. --starts a comment that runs to the end of the line.- Statements are separated by
;. The last one needs none. - A search needs a
WHEREor aLIMIT: MISP takes no search without either.
Conditions
| Condition | Meaning |
|---|---|
field = value, field != value | equals, does not equal (<> is the same as !=) |
<, >, <=, >= | numbers, timestamps, dates and datetimes only |
field IN (v, ...), NOT IN | one of the values, none of them |
field LIKE 'pattern', NOT LIKE | text fields only; see patterns |
AND, OR, NOT, ( ) | combine conditions |
NOT binds tighter than AND, and AND tighter than
OR; parentheses group.
SELECT * FROM attributes
WHERE category = 'Network activity' AND (type = 'domain' OR type IN ('ip-src', 'ip-dst'))
AND id > 50000
LIMIT 100
POST /attributes/restSearch
{
"returnFormat": "json",
"limit": 100,
"page": 1,
"query": {
"AND": [
{
"category": "Network activity"
},
{
"OR": [
{
"type": "domain"
},
{
"type": {
"IN": [
"ip-src",
"ip-dst"
]
}
}
]
},
{
"id": {
">": 50000
}
}
]
}
}
SELECT * FROM attributes
WHERE event_id = 4711 AND NOT (to_ids = TRUE OR comment LIKE '%false positive%')
LIMIT 100
POST /attributes/restSearch
{
"returnFormat": "json",
"limit": 100,
"page": 1,
"query": {
"AND": [
{
"event_id": 4711
},
{
"NOT": {
"OR": [
{
"to_ids": true
},
{
"comment": {
"LIKE": "%false positive%"
}
}
]
}
}
]
}
}
Values and types
Types are strict, nothing is converted: text fields take strings, numeric fields numbers
(id = '50000' is an error), booleans TRUE or FALSE.
- Timestamps (
timestamp,event_timestamp,publish_timestamp, …) take a Unix time or a relative time: digits and one ofd,h,m,s, so'7d'is seven days ago. - Dates (
date, the event date) take'YYYY-MM-DD'or a number of days ('30d'). - Datetimes (
createdandmodifiedon analyst data and collections,date_createdanddate_modifiedon organisations) take what timestamps take, or'YYYY-MM-DD'and'YYYY-MM-DD HH:MM:SS'.
SELECT * FROM events WHERE date >= '2026-01-01' AND publish_timestamp >= '12h' LIMIT 50
POST /events/restSearch
{
"returnFormat": "json",
"limit": 50,
"page": 1,
"query": {
"AND": [
{
"date": {
">=": "2026-01-01"
}
},
{
"publish_timestamp": {
">=": "12h"
}
}
]
}
}
Patterns
LIKE takes a % at the start, the end or both
('%evil', 'evil%', '%evil%'), and nowhere else.
= and IN compare literally: a value starting or ending with
% is refused there.
tags is the exception, as in MISP's classic tag filter: its value is always
matched against tag names as a pattern, _ standing for any one character and a
% inside the value for any run of them, and a value of digits only is a tag
id.
SELECT * FROM attributes
WHERE tags LIKE 'tlp:%' AND tags NOT IN ('tlp:red', 'tlp:amber+strict') AND timestamp >= '1d'
LIMIT 100
POST /attributes/restSearch
{
"returnFormat": "json",
"limit": 100,
"page": 1,
"query": {
"AND": [
{
"tags": {
"LIKE": "tlp:%"
}
},
{
"tags": {
"NOT IN": [
"tlp:red",
"tlp:amber+strict"
]
}
},
{
"timestamp": {
">=": "1d"
}
}
]
}
}
Empty fields
Some fields can be empty (NULL), such as an attribute's comment or an
object's object_name. !=, NOT IN, NOT LIKE
and NOT also match rows where the field is empty: comment NOT LIKE
'%test%' includes the attributes without a comment.
Columns
SELECT * prints whole rows. A column list prints only those columns, in that
order:
- Nested values are reached with dots:
Event.info,Event.Orgc.name. - The names conditions use work as columns too, where the row holds the value:
eventinfoprints the event'sinfo,orgthe creator organisation's name. Each table's list is in Tables. The column is headed by the row's own name. Tagis one cell: the tag names joined by commas.- Columns match the row's keys in any case. A column no row has gets a warning on stderr, and no value.
SELECT id, type, value, Event.info, Event.Orgc.name, Tag FROM attributes
WHERE type = 'btc' LIMIT 20 FORMAT table
POST /attributes/restSearch
{
"returnFormat": "json",
"limit": 20,
"page": 1,
"query": {
"type": "btc"
}
}
SELECT id, eventinfo, org, tags FROM events
WHERE org = 'CIRCL' AND date >= '30d' LIMIT 20 FORMAT table
POST /events/restSearch
{
"returnFormat": "json",
"metadata": 1,
"limit": 20,
"page": 1,
"query": {
"AND": [
{
"org": "CIRCL"
},
{
"date": {
">=": "30d"
}
}
]
}
}
Without a FORMAT, a column list prints JSON objects keyed by the column
names:
SELECT id, eventinfo, org FROM events
WHERE tags = 'tlp:clear' AND date >= '7d' ORDER BY event_id DESC LIMIT 2
[
{
"id": "4720",
"info": "Credential phishing against webmail users",
"Orgc.name": "CIRCL"
},
{
"id": "4718",
"info": "Loader infrastructure seen in honeypot logs",
"Orgc.name": "ORG-B"
}
]
POST /events/restSearch
{
"returnFormat": "json",
"metadata": 1,
"limit": 2,
"page": 1,
"order": [
"id desc"
],
"query": {
"AND": [
{
"tags": "tlp:clear"
},
{
"date": {
">=": "7d"
}
}
]
}
}
A keyword used as a column name goes in backticks, as the tag column count
does:
SELECT id, name, `count`, attribute_count FROM tags
WHERE is_galaxy = FALSE ORDER BY name LIMIT 20 FORMAT table
POST /tags/restSearch
{
"returnFormat": "json",
"limit": 20,
"page": 1,
"order": [
"name asc"
],
"query": {
"is_galaxy": false
}
}
Sorting and paging
ORDER BY takes one or more fields, each ASC (the default) or
DESC. Each table sorts by a fixed set of fields, listed in
Tables; objects cannot be sorted. mispql checks the names itself,
because MISP silently ignores a sort field it does not know when there is no
WHERE.
SELECT * FROM events WHERE published = TRUE
ORDER BY publish_timestamp DESC, event_id LIMIT 25 FORMAT table
POST /events/restSearch
{
"returnFormat": "json",
"metadata": 1,
"limit": 25,
"page": 1,
"order": [
"publish_timestamp desc",
"id asc"
],
"query": {
"published": true
}
}
LIMIT n asks for n rows and OFFSET skips rows
before them; MISP pages by limit and page. An offset that is a
multiple of the limit is one page. Any other offset fetches the page it starts in and, when
that page is full, the next one, and keeps the rows asked for. With one of MISP's own
formats, which mispql prints untouched, the offset must be a multiple of the limit.
SELECT * FROM attributes WHERE type = 'url' ORDER BY id LIMIT 10 OFFSET 15 FORMAT flat
POST /attributes/restSearch
{
"returnFormat": "json",
"limit": 10,
"page": 2,
"order": [
"id asc"
],
"query": {
"type": "url"
}
}
POST /attributes/restSearch (sent only when the first page is full)
{
"returnFormat": "json",
"limit": 10,
"page": 3,
"order": [
"id asc"
],
"query": {
"type": "url"
}
}
Output formats
Without a FORMAT, SELECT * prints the rows as a JSON array,
exactly as MISP sends them, and a column list prints JSON objects with those columns.
FORMAT table and FORMAT flat are rendered by mispql; any other
word is one of MISP's own export formats.
Flattening
For a column list, FORMAT table and FORMAT flat, rows are
flattened: nested objects become dotted names (Event.Orgc.name), Tag
becomes one cell of names, and every other list (an event's attributes and objects, an
object's attributes, galaxies, …) is left out. Those stay in the JSON of SELECT *
and in MISP's own formats.
FORMAT table
A text table. Without a column list it shows each table's default columns, listed in
Tables. Cells are cut at 60 characters, and line breaks in a value are
shown as \n.
SELECT * FROM events
WHERE tags = 'tlp:clear' AND date >= '7d' ORDER BY event_id DESC LIMIT 3 FORMAT table
+------+------------+-------------------------------------------------+-----------+-----------------+----------+-----------+-----------------+-------------------------------------+
| id | date | info | Orgc.name | threat_level_id | analysis | published | attribute_count | Tag |
+------+------------+-------------------------------------------------+-----------+-----------------+----------+-----------+-----------------+-------------------------------------+
| 4720 | 2026-11-14 | Credential phishing against webmail users | CIRCL | 2 | 1 | true | 37 | tlp:clear |
| 4718 | 2026-11-13 | Loader infrastructure seen in honeypot logs | ORG-B | 3 | 2 | true | 1204 | tlp:clear |
| 4711 | 2026-11-12 | Command and control domains of a banking trojan | CIRCL | 1 | 2 | true | 58 | tlp:clear,misp-galaxy:banker="Zeus" |
+------+------------+-------------------------------------------------+-----------+-----------------+----------+-----------+-----------------+-------------------------------------+
3 rows
POST /events/restSearch
{
"returnFormat": "json",
"metadata": 1,
"limit": 3,
"page": 1,
"order": [
"id desc"
],
"query": {
"AND": [
{
"tags": "tlp:clear"
},
{
"date": {
">=": "7d"
}
}
]
}
}
FORMAT flat
CSV with a header row: the column list, or with * every name the rows have,
in the order first seen. Values are written as they are, so a value starting with
= can act as a formula when the file is opened in a spreadsheet; MISP's own
FORMAT xlsx is the safer choice there.
SELECT id, date, info, Orgc.name, Tag FROM events
WHERE tags = 'tlp:clear' AND date >= '7d' ORDER BY event_id DESC LIMIT 3 FORMAT flat
id,date,info,Orgc.name,Tag
4720,2026-11-14,Credential phishing against webmail users,CIRCL,tlp:clear
4718,2026-11-13,Loader infrastructure seen in honeypot logs,ORG-B,tlp:clear
4711,2026-11-12,Command and control domains of a banking trojan,CIRCL,"tlp:clear,misp-galaxy:banker=""Zeus"""
POST /events/restSearch
{
"returnFormat": "json",
"metadata": 1,
"limit": 3,
"page": 1,
"order": [
"id desc"
],
"query": {
"AND": [
{
"tags": "tlp:clear"
},
{
"date": {
">=": "7d"
}
}
]
}
}
MISP's formats
Any other word is passed to MISP as the returnFormat, and the answer is
printed byte for byte: csv, text, xlsx,
stix2, suricata, … Each table takes the formats its endpoint
knows; MISP refuses the others. A column list needs FORMAT table,
FORMAT flat or no format.
SELECT * FROM attributes
WHERE type IN ('ip-src', 'ip-dst') AND to_ids = TRUE AND timestamp >= '30d'
LIMIT 1000 FORMAT csv
POST /attributes/restSearch
{
"returnFormat": "csv",
"limit": 1000,
"page": 1,
"query": {
"AND": [
{
"type": {
"IN": [
"ip-src",
"ip-dst"
]
}
},
{
"to_ids": true
},
{
"timestamp": {
">=": "30d"
}
}
]
}
}
mispql -e "SELECT * FROM events WHERE date >= '30d' LIMIT 100 FORMAT xlsx" > events.xlsx
Counting
SELECT COUNT(*) prints the number of rows that meet the conditions, counted
by the server; no rows are fetched. It needs a WHERE and takes no
ORDER BY, LIMIT, OFFSET or FORMAT.
SELECT COUNT(*) FROM attributes WHERE type = 'domain' AND timestamp >= '30d'
POST /attributes/restSearch
{
"returnFormat": "count",
"query": {
"AND": [
{
"type": "domain"
},
{
"timestamp": {
">=": "30d"
}
}
]
}
}
Events are counted differently: mispql asks for one event, without its attributes, and
reads the total from the X-Result-Count header.
SELECT COUNT(*) FROM events WHERE tags = 'tlp:clear' AND published = TRUE
POST /events/restSearch
{
"returnFormat": "json",
"limit": 1,
"page": 1,
"metadata": 1,
"query": {
"AND": [
{
"tags": "tlp:clear"
},
{
"published": true
}
]
}
}
Tables
Each table is one kind of MISP record. What a table can be searched by is listed by
DESCRIBE (see Fields and discovery); this section gives
what each one returns and how it behaves.
attributes
Attributes, each with its event (Event, with the creator organisation under
Event.Orgc) and its tags. Event fields (eventinfo,
org, published, event_timestamp, …) are conditions on
the attribute's event. tags matches a tag on the attribute or on its event;
negated, neither carries it.
- Endpoint
POST /attributes/restSearch- Default columns
id,event_id,category,type,value,to_ids,timestamp,Tag- ORDER BY
id,event_id,object_id,type,category,value,distribution,timestamp,object_relation,publish_timestamp- Field names as columns
eventinfo→Event.info,org→Event.Orgc.name,tags→Tag,event_timestamp→Event.timestamp,publish_timestamp→Event.publish_timestamp,threat_level_id→Event.threat_level_id
SELECT id, value, Event.info FROM attributes
WHERE eventinfo LIKE '%phishing%' AND type IN ('url', 'domain') AND to_ids = TRUE
LIMIT 50 FORMAT table
POST /attributes/restSearch
{
"returnFormat": "json",
"limit": 50,
"page": 1,
"query": {
"AND": [
{
"eventinfo": {
"LIKE": "%phishing%"
}
},
{
"type": {
"IN": [
"url",
"domain"
]
}
},
{
"to_ids": true
}
]
}
}
events
Events. Event fields are conditions on the event itself. Attribute fields
(type, value, category, …) and object fields
(object_name, object_template_uuid) select an event holding at
least one matching attribute or object that you can see; they cannot be negated, so "events
without a btc attribute" cannot be asked.
tags selects an event carrying the tag, or holding an attribute that does.
Negated (!=, NOT IN, NOT LIKE), it leaves out the
events tagged with it and removes the matching attributes and event reports from the events
returned; it is allowed only where every enclosing condition is an AND.
- Endpoint
POST /events/restSearch- Default columns
id,date,info,Orgc.name,threat_level_id,analysis,published,attribute_count,Tag- ORDER BY
id,event_id,eventinfo,analysis,threat_level_id,distribution,timestamp,event_timestamp,publish_timestamp- Field names as columns
event_id→id,eventinfo→info,org→Orgc.name,event_timestamp→timestamp,tags→Tag
SELECT id, info, Orgc.name, attribute_count FROM events
WHERE value = '198.51.100.23' AND published = TRUE
ORDER BY event_id DESC LIMIT 20 FORMAT table
POST /events/restSearch
{
"returnFormat": "json",
"metadata": 1,
"limit": 20,
"page": 1,
"order": [
"id desc"
],
"query": {
"AND": [
{
"value": "198.51.100.23"
},
{
"published": true
}
]
}
}
objects
Objects, each with the attributes of it you can see. Object and event fields can be
negated freely; attribute fields select an object holding a matching attribute and cannot be
negated, and tags works as on events. Objects cannot be sorted.
- Endpoint
POST /objects/restSearch- Default columns
id,event_id,name,meta-category,comment,timestamp- ORDER BY
- none
- Field names as columns
object_id→id,object_name→name,object_template_uuid→template_uuid,orgc_id→Event.orgc_id
SELECT id, event_id, name, comment FROM objects
WHERE object_name IN ('domain-ip', 'url') AND event_timestamp >= '7d'
AND value LIKE '%.example.com'
LIMIT 50 FORMAT table
POST /objects/restSearch
{
"returnFormat": "json",
"limit": 50,
"page": 1,
"query": {
"AND": [
{
"object_name": {
"IN": [
"domain-ip",
"url"
]
}
},
{
"event_timestamp": {
">=": "7d"
}
},
{
"value": {
"LIKE": "%.example.com"
}
}
]
}
}
galaxy_clusters
Galaxy clusters, with their galaxy. Text fields compare without regard to case.
galaxy_name, galaxy_namespace and galaxy_uuid are
conditions on the cluster's galaxy; org is the creator organisation, by name or
uuid, and 'MISP' selects the clusters the MISP project maintains.
meta.<key> matches the cluster's own meta values under that key, such
as meta.synonyms or meta.country. A key with characters other
than letters, digits and _ goes in backticks. A negated condition selects the
clusters with no such value, including those without the key.
- Endpoint
POST /galaxy_clusters/restSearch- Default columns
id,value,Galaxy.name,Orgc.name,distribution,default- ORDER BY
id,version,type,value,distribution,orgc_id,org_id,tag_name,galaxy_id- Field names as columns
org→Orgc.name,galaxy_uuid→Galaxy.uuid,galaxy_name→Galaxy.name,galaxy_namespace→Galaxy.namespace
SELECT id, value, Galaxy.name FROM galaxy_clusters
WHERE org = 'MISP' AND meta.`cfr-suspected-victims` LIKE '%Ukraine%'
ORDER BY value LIMIT 50 FORMAT table
POST /galaxy_clusters/restSearch
{
"returnFormat": "json",
"limit": 50,
"page": 1,
"order": [
"value asc"
],
"query": {
"AND": [
{
"org": "MISP"
},
{
"meta.cfr-suspected-victims": {
"LIKE": "%Ukraine%"
}
}
]
}
}
SELECT COUNT(*) FROM galaxy_clusters
WHERE galaxy_namespace = 'mitre-attack' AND description LIKE '%credential%'
POST /galaxy_clusters/restSearch
{
"returnFormat": "count",
"query": {
"AND": [
{
"galaxy_namespace": "mitre-attack"
},
{
"description": {
"LIKE": "%credential%"
}
}
]
}
}
event_reports
Event reports, searched as children of their event: event fields use the same names as
on the other tables. tags matches a tag on the report or on its event. Deleted
reports are left out unless the conditions name deleted. A condition on
content reads the Markdown of every report you can see.
- Endpoint
POST /event_reports/restSearch- Default columns
id,event_id,name,Event.info,distribution,timestamp,Tag- ORDER BY
id,event_id,name,timestamp,distribution- Field names as columns
eventinfo→Event.info,org→Event.Orgc.name,org_id→Event.org_id,orgc_id→Event.orgc_id,date→Event.date,tags→Tag
SELECT * FROM event_reports
WHERE tags = 'tlp:clear' AND published = TRUE AND date >= '30d'
ORDER BY timestamp DESC LIMIT 20 FORMAT table
POST /event_reports/restSearch
{
"returnFormat": "json",
"limit": 20,
"page": 1,
"order": [
"timestamp desc"
],
"query": {
"AND": [
{
"tags": "tlp:clear"
},
{
"published": true
},
{
"date": {
">=": "30d"
}
}
]
}
}
notes, opinions, relationships
Analyst data, one table per type. You see the records your organisation holds and those
shared with you. The record they are attached to is matched by its address only
(object_type, object_uuid, object_sha256), whether or
not you can see it. created and modified are datetimes in UTC.
notes
- Endpoint
POST /analyst_data/restSearch/Note- Default columns
id,object_type,object_uuid,note,authors,created- ORDER BY
id,created,modified,distribution- Field names as columns
org→Orgc.name
SELECT * FROM notes WHERE object_type = 'Event' AND note LIKE '%ransomware%'
ORDER BY created DESC LIMIT 20 FORMAT table
POST /analyst_data/restSearch/Note
{
"returnFormat": "json",
"limit": 20,
"page": 1,
"order": [
"created desc"
],
"query": {
"AND": [
{
"object_type": "Event"
},
{
"note": {
"LIKE": "%ransomware%"
}
}
]
}
}
opinions
- Endpoint
POST /analyst_data/restSearch/Opinion- Default columns
id,object_type,object_uuid,opinion,comment,authors- ORDER BY
id,created,modified,distribution,opinion- Field names as columns
org→Orgc.name
SELECT * FROM opinions WHERE opinion < 50 AND created >= '2026-11-01'
ORDER BY opinion LIMIT 20 FORMAT table
POST /analyst_data/restSearch/Opinion
{
"returnFormat": "json",
"limit": 20,
"page": 1,
"order": [
"opinion asc"
],
"query": {
"AND": [
{
"opinion": {
"<": 50
}
},
{
"created": {
">=": "2026-11-01"
}
}
]
}
}
relationships
- Endpoint
POST /analyst_data/restSearch/Relationship- Default columns
id,object_type,object_uuid,relationship_type,related_object_type,related_object_uuid- ORDER BY
id,created,modified,distribution,relationship_type- Field names as columns
org→Orgc.name
SELECT * FROM relationships
WHERE relationship_type = 'attributed-to' AND related_object_type = 'GalaxyCluster'
LIMIT 20 FORMAT table
POST /analyst_data/restSearch/Relationship
{
"returnFormat": "json",
"limit": 20,
"page": 1,
"query": {
"AND": [
{
"relationship_type": "attributed-to"
},
{
"related_object_type": "GalaxyCluster"
}
]
}
}
collections
Collections, each with its elements. An element field (element_type,
element_uuid, element_sha256, element_description)
matches when any element of the collection does; negated, it selects the collections with
no such element, the empty ones included. Elements are matched by their address and
description, whether or not you can see what they point at. name,
type and the descriptions compare without regard to case.
- Endpoint
POST /collections/restSearch- Default columns
id,name,type,Orgc.name,distribution,element_count,modified- ORDER BY
id,name,type,created,modified,distribution- Field names as columns
org→Orgc.name
SELECT * FROM collections WHERE type = 'campaign' AND element_type = 'Event'
ORDER BY modified DESC LIMIT 20 FORMAT table
POST /collections/restSearch
{
"returnFormat": "json",
"limit": 20,
"page": 1,
"order": [
"modified desc"
],
"query": {
"AND": [
{
"type": "campaign"
},
{
"element_type": "Event"
}
]
}
}
-- collections with no elements at all
SELECT id, name FROM collections
WHERE element_type NOT IN ('Event', 'GalaxyCluster', 'Attribute', 'Object', 'AttributeValue')
LIMIT 50 FORMAT table
POST /collections/restSearch
{
"returnFormat": "json",
"limit": 50,
"page": 1,
"query": {
"element_type": {
"NOT IN": [
"Event",
"GalaxyCluster",
"Attribute",
"Object",
"AttributeValue"
]
}
}
}
tags
Every tag on the instance, as MISP's tag index shows them, with how many events you can
see carry each one (count) and how many attributes do
(attribute_count); those counts cannot be searched or sorted on.
name compares without regard to case. numerical_value searches the
tag's own value, even where your settings override it.
- Endpoint
POST /tags/restSearch- Default columns
id,name,numerical_value,hide_tag,is_galaxy,count,attribute_count- ORDER BY
id,name,numerical_value
SELECT * FROM tags
WHERE is_galaxy = TRUE AND hide_tag = FALSE AND name LIKE 'misp-galaxy:mitre-attack-pattern=%'
ORDER BY name LIMIT 20 FORMAT table
POST /tags/restSearch
{
"returnFormat": "json",
"limit": 20,
"page": 1,
"order": [
"name asc"
],
"query": {
"AND": [
{
"is_galaxy": true
},
{
"hide_tag": false
},
{
"name": {
"LIKE": "misp-galaxy:mitre-attack-pattern=%"
}
}
]
}
}
organisations
Every organisation, local and external, as MISP's organisation index shows them, with its number of users. Text fields compare without regard to case. When the instance hides the organisation index from your role, this table answers 403 as the index does.
- Endpoint
POST /organisations/restSearch- Default columns
id,name,type,nationality,sector,local,user_count- ORDER BY
id,name,date_created,date_modified
SELECT * FROM organisations WHERE name LIKE '%cert%' ORDER BY name LIMIT 50 FORMAT table
POST /organisations/restSearch
{
"returnFormat": "json",
"limit": 50,
"page": 1,
"order": [
"name asc"
],
"query": {
"name": {
"LIKE": "%cert%"
}
}
}
Fields and discovery
SHOW TABLES lists the tables you may query. DESCRIBE (or
DESC) asks the server for a table's fields, with each one's type, operators and
level (what it is matched against: the record itself, its event, its attributes, …), the
names ORDER BY takes, and the limits in effect. The prompt completes field names
from the same answer.
DESCRIBE events
GET /events/queryDescribe
SHOW TABLES
GET /attributes/queryDescribe
GET /events/queryDescribe
GET /objects/queryDescribe
GET /galaxy_clusters/queryDescribe
GET /event_reports/queryDescribe
GET /analyst_data/queryDescribe/Note
GET /analyst_data/queryDescribe/Opinion
GET /analyst_data/queryDescribe/Relationship
GET /collections/queryDescribe
GET /tags/queryDescribe
GET /organisations/queryDescribe
The full field reference, with each field's meaning, is in MISP's own documentation,
docs/restsearch-complex-query.md in the MISP repository.
Errors
mispql checks a statement before sending it, and points at the text an error is about:
SELECT * FROM attributes WHERE type = domain LIMIT 10
ERROR 1:39: expected a value ('string', number, TRUE or FALSE), found domain (strings need quotes)
SELECT * FROM attributes WHERE type = domain LIMIT 10
^^^^^^
What only the server can check (field names, operators per field, types) comes back from MISP as an error per condition, which mispql places on the statement the same way:
SELECT * FROM events WHERE event_id > 0 AND (eventinfo = 'x' OR type != 'btc') LIMIT 1
POST /events/restSearch
{
"returnFormat": "json",
"limit": 1,
"page": 1,
"query": {
"AND": [
{
"event_id": {
">": 0
}
},
{
"OR": [
{
"eventinfo": "x"
},
{
"type": {
"!=": "btc"
}
}
]
}
]
}
}
ERROR 1:65: attribute and object fields cannot be negated when searching events
SELECT * FROM events WHERE event_id > 0 AND (eventinfo = 'x' OR type != 'btc') LIMIT 1
^^^^^^^^^^^^^
Limits
The server limits how large a set of conditions may be, before it touches the database.
These are the defaults; an administrator can change them, and DESCRIBE shows
the ones in effect.
| Limit | Default | Of |
|---|---|---|
max_depth | 5 | nesting of AND, OR and NOT |
max_nodes | 50 | conditions plus the AND, OR and NOT joining them |
max_list | 100 | values in one IN or NOT IN |
max_value_length | 1024 | characters in one value |
Large events
An event can hold a million attributes. For a column list, FORMAT table and
FORMAT flat on events, mispql asks MISP for the events without their attributes,
objects and reports, which flattening would leave out anyway, so a large event costs no more
than a small one. SELECT * printed as JSON and MISP's own formats fetch whole
events: keep a LIMIT on those.
Conditions are cheapest when one of them is selective. An OR whose branches
share no index, a negated tags, or an attribute field matching a large share of
the attributes, such as a common category, is best combined with an
AND on event_id, a timestamp or another narrow condition.