Skip to content

connect_query

Read-only access to the Connect system, which tracks CRM enrichment job execution and detailed per-record audit logs.

  • “Show me recent enrichment runs for this tenant.”
  • “Why did <run_id> fail?”
  • “Aggregate stats for run <id>.”
  • Anything that needs a SQL view of Connect’s runs, tasks, or audit trail.
ParameterTypeRequiredDescription
tenant_idstringYesTenant identifier to scope the query.
querystringYesPostgreSQL SELECT against Connect tables.
  • connect_runs — enrichment job execution history (id, tenant, task_name, task_type, status, start_time, end_time, task_id, metadata JSONB). Status: initializing, running, completed, failed, stopped.
  • connect_tasks — scheduled enrichment task definitions (id, tenant, task_name, task_type, cron, created_at, updated_at).
  • connect_audit_logs — per-record enrichment audit trail (tenant_id, task_name, run_id, crm_entity_type, crm_entity_id, status, enrichment_type, update_scope, updated_fields JSONB, data_sources_* JSONB arrays, matcher_name, processing_stage, enrichment_errors, filter_reasons, …).
  • connect_run_audit_summary — pre-aggregated run-level statistics.
  • connect_runs_expanded_v — flat view of connect_runs with per-entity-type result counts expanded from the metadata JSONB.

Recent runs for a tenant:

SELECT id, task_name, status, start_time, end_time
FROM connect_runs
ORDER BY start_time DESC
LIMIT 20

Run summary (flat):

SELECT task_name, status, account_updated, lead_updated, contact_updated
FROM connect_runs_expanded_v
ORDER BY start_time DESC
LIMIT 10

Audit log sample for a run:

SELECT crm_entity_type, crm_entity_id, status, enrichment_type,
update_scope, updated_fields
FROM connect_audit_logs
WHERE run_id = <run_id>
LIMIT 50

JSON with total_count, rows (max 1,000), and truncated.

  • Always filter by tenant (via run_id or directly).
  • Column naming is not consistent across tables: connect_runs and connect_tasks use tenant; connect_audit_logs uses tenant_id.
  • Write statements (INSERT, UPDATE, DELETE, CREATE, …) are blocked.