When automating OpenCTI with the GraphQL API makes sense
Use the GraphQL API when a threat intelligence team keeps doing the same platform work by hand: bulk relabeling of indicators, closing out stale reports, applying markings across hundreds of entities, or pushing reports on a schedule to a chat channel, ticketing system or SOAR platform. OpenCTI provides a web application with a GraphQL API on top of a knowledge schema based on the STIX2 standards, so every object the UI shows (reports, threat actors, observables, relationships) can also be read and changed programmatically. If the work is a one-off correction of a few dozen records, the UI is usually faster and safer. The API starts to pay off when the same change must be repeated, audited, or run without an analyst clicking through screens.
Confirm three things before you commit to scripting. First, check which operations your platform version exposes and how they behave under your access model, because a service account can only change what its roles allow. Second, decide whether the work is read-heavy or write-heavy, since large writes compete with the platform's own ingestion and the background workers that process them. Third, identify who will own the script after the author moves on. A short script that edits a few entities once is a poor fit for a long-running integration with credentials, retries and monitoring.
The GraphQL API is not always the right entry point. If you are building new objects in STIX form from a feed or internal source, the official Python client or a custom connector is usually the better fit, because it handles bundle structure and queuing for you. If other systems need to react to changes as they happen, the live stream is the better fit than polling the API on a timer. Use the GraphQL API for queries, bulk edits and scheduled reporting, and move to a sibling approach when you need ingestion, event-driven flows or a reusable client library.
How a scripted API request moves through OpenCTI
A script authenticates with a service account token and sends a GraphQL request to the OpenCTI platform, which serves the UI and API. Writes are not applied inline: the platform queues them in RabbitMQ, and Python workers consume the messages and persist the changes to Elasticsearch or OpenSearch and object storage. The UI reaches the same platform as a parallel client. Check the token boundary first, then confirm which requests are queued writes versus reads, because a script can flood the queues even when its requests look small.
Scripted and UI requests enter one API, and writes reach storage through queued workers.
Which API approach fits which automation job
This table compares direct GraphQL calls, the pycti Python client, the live stream and notifiers or connectors by the type of job, how often it runs and what it costs to maintain. Read each row as a starting point: the pycti and connector topics cover the build detail, and GraphQL is the lowest-level option that the others rely on.
| Approach | Best-fit job | Cadence | Maintenance burden |
|---|---|---|---|
| Direct GraphQL calls | Ad hoc queries, one-off bulk edits and small reporting scripts that need exact control over each request | Manual runs or scheduled batch jobs | Lowest library dependency, but you own query shapes, pagination and error handling as the schema evolves |
| pycti Python client | Repeatable scripts that create or update entities with markings and dates, and teams that want typed helpers over raw queries | Scheduled batch or event-driven scripts | Moderate: keep the client aligned with the platform's release cadence and test scripts after upgrades |
| Live stream consumer | Pushing changes from OpenCTI into in-house systems as they happen, such as alerting or syncing a data store | Continuous, near real time | Moderate to high: handle reconnects, resume from event IDs after restarts and filter with live stream definitions |
| Notifiers | Sending OpenCTI triggers to chat, ticketing or SOAR webhooks using templates maintained inside the platform | Triggered by platform events | Low to moderate: template changes need review, and the available functions are limited to the allowlist for your version |
| Custom connector | Importing from or exporting to a source or tool with no official integration, including niche or internal feeds | Scheduled or continuous, running as a worker | Highest: packaging, STIX 2.1 bundle validity, testing and upkeep for each source you own |
| Service account for any of the above | Non-interactive automation that must not run under a person's login | Applies to every approach | Ongoing: scope its permissions, rotate its credentials and review its audit trail |
Setting up a service account and first API calls
This sequence gives an integration its own scoped OpenCTI identity, a stored token, and a verified path from a read-only query to a logged, dry-run-tested write. Each step produces a check that the next step depends on.
Create a dedicated service account
An OpenCTI administrator creates a service account for the script or integration, not a personal user account, and gives it the narrowest role that the job needs. Limit it to the groups and marking definitions (such as TLP levels or organization-based segments) it must read or write, and grant no administrative capabilities. Confirm the exact role, group and marking settings in the OpenCTI administration documentation for your release, because the available options depend on the edition and version you run. Check: the account can sign in only through its token, and a test read of an object outside its markings returns nothing.
Generate and store the API token
Generate the token for the service account from its profile, then place it in your secrets manager instead of in source code, shell history or a shared configuration file. Give the consuming job a reference to the secret rather than the value, and record who owns the token and where it is used. Plan the rotation procedure before go-live, including how the running job picks up a new token without downtime. Check: the token is absent from the repository and container images, and the secret path and owner are recorded in your inventory.
Confirm the endpoint and schema in a test instance
Point a client at a non-production OpenCTI instance and confirm the GraphQL endpoint answers an authenticated request with the service account token. Open the schema through the platform's GraphQL tooling to identify the entity types, filter keys and mutations available in your exact release, since field names can change between versions. Record the release version alongside the queries you write so you can retest them after upgrades. Check: an authenticated introspection or simple query succeeds, and the schema snapshot is saved with the release number.
Run a read-only query with filters and paging
Write a read-only query that selects a specific entity type, applies a filter on a stable field such as a creation or update date, and requests a bounded page size. Follow the returned cursor or pagination field until the result set is complete, and log the count per page. Keep the page size modest for the first run and test it against a busy environment only after you know its limits. Check: the query returns the expected number of records for a known filter, the pagination terminates, and no results fall outside the service account's markings.
Add write mutations behind a dry run
Before any mutation runs, build it so the script prints the intended create or update payload for each record without sending it. Compare the dry-run output with a small set of objects checked by a human analyst, covering the identifiers, markings, labels and relationships that will change. Only then enable the write path, and keep it limited to the test instance until the output matches expectations. Check: the dry-run diff matches the reviewed sample, and a write to the test instance produces the object shown in the interface.
Keep a change log for every write
Have the script append a structured record for each mutation: timestamp, service account, target identifier, action, a summary of changed fields, and the job run identifier. Store the log outside the OpenCTI instance so it survives platform restores, and set retention to match your records policy. Review the log against the platform's own activity records during a test run to confirm they agree. Check: each test write has a matching log entry, and you can reverse a sample change from the log without relying on memory.
Filters, pagination and bulk writes compared
Filtered reads push selection into the query so the platform returns only the objects a script needs. This is the cheapest pattern when the filter matches a narrow set of entities, such as indicators created by one connector in a given date window or reports carrying a specific marking. The trade-off is that filter semantics vary by entity type and by version, so a filter that works in a test query can behave differently on another release. Check each filter against the schema of the installed version before you rely on it in a scheduled job.
- Filter keys: Confirm which filter keys each entity type accepts, and whether relationship filters can be combined with attribute filters in one call.
- Operators: Verify which comparison and list operators exist for dates, labels and identifiers, and how they handle empty values.
- Scope of results: Test whether a filter returns the entities you expect across markings your service account can see, since access control applies to results.
- Ordering: Check whether the sort field you intend to use is supported, because unsorted results make incremental jobs harder to resume.
- Broad queries: Avoid filters that match most of the data, since they recreate the load of a full export.
Before promoting a filtered read to production, run it against a copy of the platform with the same release and compare counts with the UI.
Cursor pagination reads large result sets in bounded pages, passing a cursor from one response to the next. It keeps memory use and per-request load predictable, and it lets a job stop and resume. The trade-off is time: a full read takes many round trips, and each page must be handled with backoff so that a busy platform is not pushed further. Page size should be a deliberate setting that you tune and record, not a default you inherit.
- Page size: Start with a modest first value and raise it only after measuring response time and error rates on your platform.
- Cursor handling: Store the last cursor only after the page has been processed, so a failure does not skip records.
- Backoff: Retry throttled or failed pages with increasing delays and a maximum attempt count, rather than in a tight loop.
- Concurrency: Run one paginated reader per entity type unless testing shows that parallel readers do not slow the search index.
- Stability: Check how the cursor behaves when records change during a long read, and design the job to tolerate duplicates.
Confirm in the schema of your installed version that the connection fields expose cursors and page limits, and confirm any maximum page size your administrators have set.
Bulk writes group many create or update operations into fewer mutation calls and let the platform process them asynchronously through its message queue. This is the most efficient pattern for loading large batches, but it is also the easiest way to overload a shared deployment. Writes are processed by workers that consume RabbitMQ messages, so a script that outruns the workers builds a backlog that delays every user and connector. Respect queue depth as a signal to slow down, not as a number to ignore.
- Batch size: Keep batches small enough that a failed batch is cheap to retry, and record which items each batch contained.
- Queue awareness: Check queue depth and worker health before each batch, and pause when the backlog grows.
- Idempotency: Use stable external identifiers so that a retried write updates an existing object instead of creating a duplicate.
- Error handling: Separate rejected records, such as invalid STIX content or missing markings, from transient failures, and log each category.
- Verification: Read back a sample of written objects after each run to confirm the data landed as intended.
Confirm with your administrator how many workers and platform nodes your deployment runs, and check the mutation names and input types in the schema of your installed version before you write the batch logic.
Keeping scripts from overloading a busy platform
Scripts that bulk-write or read through the OpenCTI GraphQL API compete with analysts, connectors and background workers for the same platform, queues and search indices. The cards below cover the controls that keep a scripted run predictable, from how fast it sends requests to how it recovers when the platform is slow.
Set request rates in the script
Decide a maximum request rate and concurrency for each script before it runs against production, and write it into the script configuration rather than leaving it to defaults. Start with one worker and raise concurrency only after watching queue depth during a test run. Check that every script shares one agreed budget when several teams run jobs at the same time.
Schedule runs off peak
Run bulk jobs in a window when analysts are least active and when connector imports are quiet, so that writes do not stack on top of user searches. Ask the platform owner for the usual busy hours and for any scheduled connector runs. Keep heavy jobs out of the same window as large feed imports.
Sync incrementally with date filters
Query only objects created or updated since the last successful run instead of scanning the whole knowledge base each time. Store the high-water mark in a durable place and advance it only after the batch commits. Full scans are useful for audits, but they should be rare and scheduled deliberately.
Retry with backoff on queue lag
Asynchronous writes pass through RabbitMQ and Python workers, so a write can succeed at the API while the change lands later. Treat slow responses and errors as signals to pause, then retry with increasing delays and a cap. Confirm with the platform team how they expose queue depth so the script can read it before sending more work.
Monitor workers and indices during runs
Watch worker health, queue depth and search index status while the script runs, and stop the job if they degrade. Search indices are the usual bottleneck for heavy read patterns, so check their health alongside API latency. Record these readings with the run log so you can match a slowdown to a specific job later.
Make re-runs idempotent
Design each write so that running the same batch twice does not create duplicate objects or relationships. Use stable external identifiers and look up existing objects before creating new ones. Test re-runs against a copy of the platform, because a duplicate created by a retry is harder to clean up than a skipped record.
Questions buyers ask about OpenCTI API automation
What drives the effort and cost of building OpenCTI API scripts?
The biggest drivers are how many distinct operations the scripts must perform, how cleanly the data model maps to your sources, and how much governance the output needs. A script that only reads indicators and tags them is a small job. A script that creates reports, applies marking definitions, respects organization-based access and retries safely under load is a larger one. Cost splits into design work (agreeing which objects change and who may change them), build work (queries, mutations, pagination and error handling), test work against a non-production instance, and handover documentation. Ask any provider to price each of these separately so you can see what is one-time and what you will maintain later.
How long does a first OpenCTI API integration usually take?
No researched timeline is available for this work, so treat any duration you hear as unverified until it is tied to a written scope. The honest answer depends on the number of endpoints touched, whether a service account and roles already exist, how many data sources feed the script, and whether your team has a non-production OpenCTI instance to test against. Ask the provider to break the schedule into discovery, build, testing against your data volumes and handover, and to name the dependencies on your side, such as access approvals and sample data.
What must our internal team provide before an outside provider starts?
Your team should provide a non-production OpenCTI environment that matches the production version, a service account with a defined role, sample data that reflects real volumes and markings, and a named owner who can approve design decisions. You also need a list of the objects the automation must read or write, the systems on either side of the integration, and the schedule on which it must run. Without these, the provider spends the engagement discovering requirements rather than building them, which is the most common source of overrun. Confirm credential storage rules and change approval steps before any code is written.
Can our own team build OpenCTI API automation without outside help?
Yes, a team with Python or JavaScript experience and a working knowledge of STIX objects can build simple automation using the official client and the GraphQL schema, especially for read-only reporting. The harder parts are rate control on a busy platform, pagination over large result sets, idempotent writes that do not create duplicates, and keeping scripts working across releases. Outside help is most useful for designing the service account model, load testing and handover. Decide early which parts your team will own after go-live, because that determines how much design documentation you need.
How do OpenCTI upgrades affect our API scripts?
Upgrades can change the schema, field names, filter behavior and deprecated operations that your scripts depend on, so every upgrade needs a regression pass. OpenCTI uses date-based version numbers, with regular releases that ship from daily to weekly and LTS releases every 6 months, each supported for 1 year. LTS lines receive only critical bug and security fixes after a one-month stabilization. Pin your client library version, keep a test suite that exercises your queries and mutations, and schedule the retest into each upgrade window. Ask the provider who runs that retest and how often.
What should a fixed-scope quote for OpenCTI automation include?
A fixed-scope quote should list the exact automations, the OpenCTI version and license edition they target, the endpoints and object types touched, the test environment used, and the acceptance criteria. It should also state deliverables such as source code, configuration, runbooks and a handover session, plus any retesting after an upgrade and what is one-time versus recurring. Confirm which OpenCTI edition is required, because authentication strategies including SSO are an Enterprise Edition feature since 7.260224.0. DeployOpen agrees scope, deliverables and timelines in writing before work starts, so any quote without those items is incomplete.
Keeping API scripts working across OpenCTI releases
Every script that calls the OpenCTI GraphQL API depends on the platform version it was written against, so the first decision is which release line your platform runs and which one it will move to next. OpenCTI uses date-based version numbers in the form x.YYMMDD.z for regular releases, where the date is the release date. LTS releases follow the form x.YYMMDD.z-lts.n, where the date is the LTS branching date and the trailing number counts hotfixes on that line. Regular releases ship when ready, from daily to weekly, so a team on a non-LTS build will see frequent change. LTS releases arrive every 6 months and each is supported for 1 year, which gives a 6-month overlap between consecutive LTS versions. After a one-month stabilization period, an LTS line receives only critical bug and security fixes. Confirm the current support window for your line in the OpenCTI product life cycle documentation before you commit a script to it.
Treat every platform upgrade as a trigger for regression testing of your API scripts, not as a separate task. Keep a test environment that mirrors production in version, configuration and the relevant data shape, including the same authentication strategy and the same service account with the same permissions. Run the full script suite against the target version before the production upgrade, and check specifically for changed field names, altered filter behavior, renamed entity types and different error responses. Because LTS releases require a specific license key, confirm that the test instance holds a key valid for the target line. Use the platform's GitHub releases page to review what changed between your current and target builds, and record each result so the next upgrade starts from a known baseline.
Pin the pycti client version in every script or container that calls the API, and install it from a lock file rather than a floating version range. Match the client to the platform line you run, and upgrade the client in the test environment first, the same way you upgrade the platform. Store the pinned version next to the script in source control, so a rollback restores both the script and the client it was tested with. Where scripts use raw GraphQL queries instead of the client, pin the query text in version control and add a small check that runs a representative query against the test instance on each change. Ask your team to name an owner for each script who signs off on the upgrade test, since a script nobody owns is usually the one that breaks silently.
Testing API changes before each platform upgrade
This sequence checks that scripts, reports and integrations built on the GraphQL API still return the same results and write the same data on the version you plan to run. It ends with a written go or no-go decision that the upgrade owner signs off.
Inventory every API consumer before the upgrade
List each script, scheduled job, report, dashboard query and integration that calls the GraphQL API or the pycti client, and record the service account it uses, the queries and mutations it sends, and the owner who answers for it. Keep the inventory in version control next to the scripts. The step is done when every consumer has a named owner and a test case or an explicit reason it has none.
Stand up a staging platform on the target version
Deploy a staging OpenCTI instance on the target release, using the same dependency versions, connector set and authentication settings as production, and load a sanitized copy of production data. Confirm the target version against the OpenCTI releases page before you start, because release numbers follow a date-based scheme and LTS builds need a valid license key. The step is done when the staging version string, dependency versions and connector list match your change record.
Replay read queries and compare results
Run each inventoried read query against staging on the current production version and on the target version, using the same service account and filters. Save the responses and diff them on the fields your consumers actually use, such as entity IDs, standard identifiers, markings, dates and pagination cursors. The step is done when every difference is either expected and documented or traced to a bug or a field change that the owner accepts.
Verify mutation effects on test entities
Run each scripted write (creates, updates, relationship changes, bulk imports and deletes) against staging test entities, then read the results back through the API and the UI. Check that the object type, relationships, markings, created and modified dates, and author match what the script intended. The step is done when each write produces the expected stored state and the cleanup routine returns staging to its baseline.
Check worker queues and load behavior
While the replay runs, watch the RabbitMQ queues, worker consumption and error logs on staging, and compare the request volume and response times with the baseline from the current version. Look for growing queues, failed messages, repeated retries and rate-limit responses that the scripts did not see before. The step is done when queues drain as they did before the upgrade and no new error class appears in the logs without a recorded decision.
Confirm authentication and permissions still hold
Test each service account against the target version, confirming it can read and write only the objects its role allows and that tokens and strategies behave as they did before. Where Enterprise Edition features such as SSO or organization-based segregation are part of the setup, verify them separately on the target build. The step is done when each account's allowed and denied actions match the access matrix.
Record findings and obtain the go or no-go decision
Write a short test report listing each consumer, the checks run, the differences found, the fix or workaround for each, and the retest result. The upgrade owner and the owner of each affected consumer review it and record a go or no-go decision. The step is done when the signed report is attached to the change record and any open items have a named owner.
Approve production only after all checks pass
Schedule the production upgrade only once the report shows no unresolved failures in read, write, queue and access checks. Keep the previous version and a tested backup available so the rollback decision can be made quickly, and rerun the smoke set of queries immediately after the upgrade. The step is done when the production smoke run matches the staging results and the change is closed with the report linked.
How DeployOpen scopes and delivers OpenCTI API automation
DeployOpen plans, builds, documents and supports OpenCTI API automation inside your own infrastructure, so scripts and integrations run against your platform under your access model. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
How we scope
- We inventory the bulk changes, reports and integrations you want automated, and the teams that own each one.
- We confirm which OpenCTI edition, release line and authentication setup your platform runs before any script is designed.
- The written scope names service accounts, entity types, query volumes, schedules and the systems each integration touches.
How we build
- We build scripts and integrations with pagination, filters and rate controls so they do not overload a busy platform.
- We test each automation against a non-production instance, checking marking, permission and data-quality behavior before release.
- We confirm API calls and client usage against the OpenCTI version you run, since the release cadence can change them.
How we hand over
- You receive source code, configuration, service account setup notes and a runbook describing schedules and failure handling.
- We document how to rotate credentials, change filters and roll scripts forward when OpenCTI is upgraded.
- Handover includes a walkthrough with your platform and security teams so they can review and operate the automation.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, scoped separately from the build.
- Retainers can cover re-testing automations after each OpenCTI release you adopt, including LTS line changes.
- Confirm with us during scoping which support levels, response expectations and reporting cadence your organization needs.

