FabrikFabrik
FabrikAPI Reference

Queries

Saved queries, executions, scheduled tasks, pipeline executions, and category management — every endpoint under /api/queries/.

The query engine is the largest surface of Fabrik's API. Seven ViewSets are mounted under /api/queries/:

RouteResource
/api/queries/categories/Folder-style categories for organizing saved queries
/api/queries/saved-queries/The saved queries themselves — canvas + metadata
/api/queries/execution-logs/Historical execution records (read-only)
/api/queries/scheduled-tasks/Cron-style scheduled queries
/api/queries/scheduled-executions/Run history for scheduled tasks
/api/queries/task-settings/Task management preferences (retention, concurrency)
/api/queries/pipeline-executions/Multi-query pipeline runs

Categories

GET /api/queries/categories/

List categories the user can see. Supports ?parent=<id> to list children of a specific folder.

Resource shape:

{ "id": 1, "name": "Network Health", "parent": null, "query_count": 12, "children": [2, 3] }

POST /api/queries/categories/

Body: { "name": "...", "parent": <id|null> }.

PATCH / DELETE /api/queries/categories/<id>/

Standard semantics. Deleting a category with children returns 409 Conflict unless ?force=true.

Saved queries

GET /api/queries/saved-queries/

Paginated list.

Filters:

  • ?category=<id> — filter by category.
  • ?search=<term> — name and description.
  • ?is_favorite=true — only favorited.
  • ?ordering=-updated_at — recent first.

Resource shape (summary):

{
  "id": "af3…",
  "name": "Tenant BD health",
  "description": "All BDs with misconfigured subnets",
  "category": 1,
  "apic_connection": "a3e1f…",
  "nodes": [ /* React Flow nodes */ ],
  "edges": [ /* React Flow edges */ ],
  "post_processors": [ /* pipeline steps */ ],
  "current_version": "2.3",
  "current_version_hash": "sha256:…",
  "is_favorite": false,
  "created_at": "…",
  "updated_at": "…"
}

POST /api/queries/saved-queries/

Create a query. nodes, edges, and apic_connection are required.

GET /api/queries/saved-queries/<id>/

Full detail including version_history.

PATCH /api/queries/saved-queries/<id>/

Any change to nodes, edges, or post_processors auto-increments the version and appends to version_history. Non-structural fields (name, description) don't bump the version.

POST /api/queries/saved-queries/<id>/execute/

Execute the query synchronously. Runs on the calling thread, times out at 30 seconds.

Request (optional overrides):

{
  "apic_connection": "<id>",          // override default
  "variables": { "tenantName": "common" },
  "skip_post_processors": false
}

Response 200:

{
  "execution_id": "…",
  "status": "success",
  "row_count": 142,
  "generated_query": "/api/class/fvBD.json?query-target-filter=...",
  "actual_query_path": "/api/mo/uni/tn-common.json?query-target=subtree&target-subtree-class=fvBD",
  "results": [ /* raw APIC MOs, possibly post-processed */ ],
  "duration_ms": 1840
}

For queries that might take longer than 30 seconds, use execute_background/ instead — it returns immediately with a job ID you stream progress from over WebSocket.

POST /api/queries/saved-queries/<id>/execute_background/

Fire and forget. Returns { "job_id": "…" }. Subscribe to ws://…/ws/chain-execution/<job_id>/ for progress and results. See WebSockets.

POST /api/queries/saved-queries/<id>/validate/

Dry-run validation. Returns any connection-graph or filter errors without executing.

POST /api/queries/saved-queries/<id>/favorite/ / unfavorite/

Toggle favorite status.

POST /api/queries/saved-queries/<id>/duplicate/

Server-side clone. Returns the new query.

GET /api/queries/saved-queries/<id>/versions/

Full version history — every change with before/after snapshot hashes and timestamps.

Execution logs

Read-only. Populated automatically by every execution (manual or scheduled).

GET /api/queries/execution-logs/

Filters:

  • ?saved_query=<id>
  • ?status=<success|failure|timeout>
  • ?executed_after=<iso> / ?executed_before=<iso>

Resource shape:

{
  "id": "…",
  "saved_query": "af3…",
  "user": "alice",
  "apic_connection": "a3e1f…",
  "status": "success",
  "row_count": 142,
  "duration_ms": 1840,
  "executed_at": "2026-04-22T08:00:00Z",
  "error_message": null,
  "results_truncated": false
}

Result payloads aren't returned in the list — fetch /api/queries/execution-logs/<id>/ for the full body (subject to a per-user retention policy).

Scheduled tasks

GET /api/queries/scheduled-tasks/

List scheduled tasks the user owns or has been granted access to.

Resource shape:

{
  "id": "…",
  "name": "Daily BD audit",
  "saved_query": "af3…",
  "apic_connections": ["a3e1f…", "b7c2d…"],
  "schedule_type": "cron",
  "cron_expression": "0 2 * * *",
  "timezone": "Europe/Istanbul",
  "enabled": true,
  "notify_on_failure": true,
  "notify_on_changes": true,
  "next_run_at": "2026-04-23T02:00:00+03:00",
  "last_run_at": "2026-04-22T02:00:00+03:00",
  "last_run_status": "success",
  "failure_streak": 0
}

POST /api/queries/scheduled-tasks/

Create a schedule. schedule_type is cron or interval. Interval-type accepts interval_minutes instead of cron_expression.

POST /api/queries/scheduled-tasks/<id>/enable/ / disable/

Toggle the enabled flag. Disabled tasks stay in the list but don't fire.

POST /api/queries/scheduled-tasks/<id>/run_now/

Trigger the task immediately. Returns the resulting execution_id — monitor the same way as a background execution.

Scheduled task executions

GET /api/queries/scheduled-executions/

History for scheduled-task runs. Filter by ?scheduled_task=<id> for a single task's timeline.

Task management settings

GET / PATCH /api/queries/task-settings/

Per-user preferences. Single-resource ViewSet — there's no list.

Fields:

  • max_concurrent_background — soft cap on parallel background jobs.
  • execution_log_retention_days — when to prune old logs.
  • default_timezone — used as the default when creating new scheduled tasks.

Pipeline executions

Pipelines chain multiple saved queries with variable passing between stages. Full pipeline definition lives on SavedQuery via a special node type — this ViewSet is about runs, not definitions.

GET /api/queries/pipeline-executions/

List pipeline runs. Filter by ?saved_query=<id> for a specific pipeline.

GET /api/queries/pipeline-executions/<id>/

Full detail — every stage's inputs, outputs, and timing.

POST /api/queries/pipeline-executions/<id>/cancel/

Request cancellation. In-flight APIC calls finish; subsequent stages don't start.