connect_query
Read-only access to the Connect system, which tracks CRM enrichment job execution and detailed per-record audit logs.
When to use it
Section titled “When to use it”- “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.
Inputs
Section titled “Inputs”| Parameter | Type | Required | Description |
|---|---|---|---|
tenant_id | string | Yes | Tenant identifier to scope the query. |
query | string | Yes | PostgreSQL SELECT against Connect tables. |
Tables
Section titled “Tables”connect_runs— enrichment job execution history (id,tenant,task_name,task_type,status,start_time,end_time,task_id,metadataJSONB). 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_fieldsJSONB,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 ofconnect_runswith per-entity-type result counts expanded from the metadata JSONB.
Example queries
Section titled “Example queries”Recent runs for a tenant:
SELECT id, task_name, status, start_time, end_timeFROM connect_runsORDER BY start_time DESCLIMIT 20Run summary (flat):
SELECT task_name, status, account_updated, lead_updated, contact_updatedFROM connect_runs_expanded_vORDER BY start_time DESCLIMIT 10Audit log sample for a run:
SELECT crm_entity_type, crm_entity_id, status, enrichment_type, update_scope, updated_fieldsFROM connect_audit_logsWHERE run_id = <run_id>LIMIT 50Returns
Section titled “Returns”JSON with total_count, rows (max 1,000), and truncated.
- Always filter by tenant (via
run_idor directly). - Column naming is not consistent across tables:
connect_runsandconnect_tasksusetenant;connect_audit_logsusestenant_id. - Write statements (
INSERT,UPDATE,DELETE,CREATE, …) are blocked.