You are reading the documentation of OpenCTI 7.260811 LTS · 7.260811.0-lts.1, supported until 2027-09.Latest is 7.261119.0 →
How-to guide

New filter API

Convert the filters of your scripts, connectors and API calls to the recursive filter format that OpenCTI 5.12 introduced, with the renamed filter keys.

OpenCTIFor platform engineers and developers

OpenCTI 5.12 replaced the filter format of its API with a recursive one that combines filters with and and or, nests groups, and tests empty fields. OpenCTI converts the filters it stores, but not those of your own scripts, connectors and API calls. This page shows how to convert them.

FILTERS BEFORE 5.12CONVERSIONOPENCTI 5.12 AND LATERStored filtersSaved in the databaseYour codeConnectors, GraphQL queries, PythonscriptsView filtersIn the URL and local storage, lostFirst start of 5.12Migrates them on its ownYour conversionRename keys, filterMode to mode, splitnull values, wrap in a groupFilterGroupmode, filters, nested filterGroups
  1. Stored filters → First start of 5.12: at first start
  2. First start of 5.12 → FilterGroup: converted
  3. Your code → Your conversion: convert by hand
  4. Your conversion → FilterGroup: new format
  5. View filters → FilterGroup: build again
OpenCTI 5.12 converts its stored filters to the recursive filter group on its own, while you convert the filters of your code and build the view filters again
Version
Changed inOpenCTI 5.12

Why the format changed

The old format could not express complex combinations: no filters within filters, one fixed combination (and between filters, or between the values of a filter), and the operator was part of the key, as in entity_type_not_eq. The frontend and backend formats differed, and the keys were static lists maintained by hand. The Filigran blog post on advanced filtering tells the full story.

// OpenCTI < 5.12: a flat list
type Filter = {
  key: string,       // one of the filter keys of the entity type
  values: string[],
  operator: string,
  filterMode: 'and' | 'or',
}

The new format is a recursive group of filters:

// OpenCTI >= 5.12
type FilterGroup = {
  mode: 'and' | 'or'
  filters: Filter[]
  filterGroups: FilterGroup[] // nested groups
}

type Filter = {
  key: string[]
  values: string[]
  operator: 'eq' | 'not_eq' | 'gt' // and more
  mode: 'and' | 'or',
}

// Reports and RFIs, not marked TLP:RED, with labelX or no label
const filters = {
  mode: 'and',
  filters: [
    { key: 'entity_type', values: ['Report', 'Case-Rfi'], operator: 'eq', mode: 'or' },
    { key: 'objectMarking', values: ['<id-for-TLP:RED>'], operator: 'not_eq', mode: 'or' },
  ],
  filterGroups: [{
    mode: 'or',
    filters: [
      { key: 'objectLabel', values: ['<id-for-labelX>'], operator: 'eq', mode: 'or' },
      { key: 'objectLabel', values: [], operator: 'nil', mode: 'or' },
    ],
    filterGroups: [],
  }],
};

What changed

  • Each filter has its own operator and mode, and groups nest through filterGroups.
  • Keys are strings, no longer a fixed list per entity type.
  • values can no longer contain null: the new operators nil and not_nil test whether a field is empty.
  • Some keys were renamed to match the entity schema: see Renamed filter keys.

What migrates on its own

FiltersMigrated
Stored filters, saved in the databaseYes, when OpenCTI 5.12 first starts
Filters in your connectors, GraphQL queries and Python scriptsNo: convert them below
Filters of the views, kept in the URL and the browser's local storageNo: they are lost. Build them again in the interface

A URL with filters in the old format shows a warning, and OpenCTI removes its filters. Build the filters again and share the new URL.

Convert a filter

  1. Rename the key if it is in the renamed filter keys.
  2. Rename filterMode to mode.
  3. If values contains null, split the filter in two, as shown below.
  4. Put the converted filters in a group: { mode: 'and', filters: [ ... ], filterGroups: [] }.
const oldFilter = {
  key: 'old_key',
  values: ['value1', 'value2'],
  operator: 'XX',
  filterMode: 'XX',
}

const convertedFilter = {
  key: 'converted_key_if_necessary',
  values: ['value1', 'value2'],
  operator: 'XX',
  mode: 'XX',
}

const newFilters = {
  mode: 'and',
  filters: [convertedFilter1, convertedFilter2], // every converted filter
  filterGroups: [],
}

Filters with a null value

Split a filter whose values contain null in two:

  • A filter for null, with values: [] and the operator nil (if it was eq) or not_nil (if it was not_eq).
  • A filter with the other values.
// Must have a label, and not Label1 or Label2
const oldFilter = {
  key: 'labelledBy',
  values: [null, 'id-for-Label1', 'id-for-Label2'],
  operator: 'not_eq',
  filterMode: 'and',
}

const newFilters = {
  mode: 'and',
  filters: [
    { key: 'objectLabel', values: ['id-for-Label1', 'id-for-Label2'], operator: 'not_eq', mode: 'and' },
    { key: 'objectLabel', values: [], operator: 'not_nil', mode: 'and' },
  ],
  filterGroups: [],
}
Nest a group to keep the logic

An eq filter with a null value, combined in and mode with other filters, needs a nested group to mean the same thing: see the second example below.

Renamed filter keys

Key before 5.12Key from 5.12
labelledByobjectLabel
markedByobjectMarking
objectContainsobjects
killChainPhasekillChainPhases
assigneeToobjectAssignee
participantobjectParticipant
creatorcreator_id
hasExternalReferenceexternalReferences
hashes_MD5hashes.MD5
hashes_SHA1hashes.SHA-1
hashes_SHA256hashes.SHA-256
hashes_SHA512hashes.SHA-512

Examples

Reports with label1 or label2

(entity_type = Report) AND (label = label1 OR label2)

const oldBackendFilter = [
  { key: 'entity_type', values: ['Report'], operator: 'eq', filterMode: 'or' },
  { key: 'labelledBy', values: [label1_id, label2_id], operator: 'eq', filterMode: 'or' },
];

const newFilters = {
  mode: 'and',
  filters: [
    { key: 'entity_type', values: ['Report'], operator: 'eq', mode: 'or' },
    { key: 'objectLabel', values: [label1_id, label2_id], operator: 'eq', mode: 'or' },
  ],
  filterGroups: [],
};

Reports with label1, label2 or no label

(entity_type = Report) AND (label = "No label" OR label1 OR label2)

const oldBackendFilter = [
  { key: 'labelledBy', values: [label1_id, label2_id, null], operator: 'eq', filterMode: 'or' },
  { key: 'entity_type', values: ['Report'], operator: 'eq', filterMode: 'or' },
];

const newFilters = {
  mode: 'and',
  filters: [
    { key: 'entity_type', values: ['Report'], operator: 'eq', mode: 'or' },
  ],
  // this combination of mode and operator needs a nested group
  filterGroups: [
    {
      mode: 'or',
      filters: [
        { key: 'objectLabel', values: [label1_id, label2_id], operator: 'eq', mode: 'or' },
        { key: 'objectLabel', values: [], operator: 'nil', mode: 'or' }, // values and mode do not matter
      ],
      filterGroups: [],
    },
  ],
};

What's next

NextPromote to indicator
Deploy
Install, configure, secure, scale and upgrade the platform.

Published

Overview
Run the XTM platform locally
OverviewDeploy with an AI agent