Skip to main content

Queue Tables

webhook_queue

Pending Ultravox webhook events waiting to be processed. Events are enqueued by webhook-ingest and dequeued by process-webhook-queue (cron).

ColumnTypeDefaultNullableDescription
iduuiduuid_generate_v4()noPrimary key
agency_iduuidnoFK → agencies.id
event_typevarchar(50)noUltravox event type (e.g., call.started, call.ended)
payloadjsonbnoFull webhook event payload
statusprocessing_status'pending'noProcessing state
attemptsinteger0noNumber of processing attempts
max_attemptsinteger5noMaximum retries before permanent failure
error_messagetextyesLast error message
created_attimestamptznow()noWhen the event was received
processing_started_attimestamptzyesWhen processing began
processed_attimestamptzyesWhen processing completed
next_retry_attimestamptzyesWhen to retry after a failure

Constraints:

ConstraintTypeDetails
webhook_queue_pkeyPrimary keyid
webhook_queue_agency_id_fkeyForeign keyagency_idagencies(id) ON DELETE CASCADE
webhook_queue_max_attemptsCheckattempts <= max_attempts

Indexes:

IndexColumnsNotes
idx_webhook_queue_pendingcreated_atFiltered: WHERE status = 'pending' — FIFO dequeue
idx_webhook_queue_retrynext_retry_atFiltered: WHERE status = 'failed' AND attempts < max_attempts — retryable items
idx_webhook_queue_agencyagency_idAgency-scoped queries
idx_webhook_queue_statusstatusStatus monitoring
idx_webhook_queue_processedprocessed_atFiltered: WHERE status = 'completed' — cleanup queries

Related edge functions: webhook-ingest (enqueues), process-webhook-queue (dequeues)


webhook_logs

Audit trail for all incoming webhook requests, including validation failures.

ColumnTypeDefaultNullableDescription
iduuiduuid_generate_v4()noPrimary key
agency_iduuidyesFK → agencies.id (null if agency lookup failed)
request_methodvarchar(10)'POST'noHTTP method of the webhook request
request_pathtextnoURL path of the request
request_headersjsonbyesRequest headers (sanitized)
request_bodyjsonbyesRequest body payload
validation_successbooleannoWhether webhook validation passed
validation_errortextyesValidation failure reason
queue_item_iduuidyesFK → webhook_queue.id (if enqueued)
received_attimestamptznow()noWhen the request was received
source_ipinetyesIP address of the sender

Constraints:

ConstraintTypeDetails
webhook_logs_pkeyPrimary keyid
webhook_logs_agency_id_fkeyForeign keyagency_idagencies(id) ON DELETE CASCADE

Indexes:

IndexColumnsNotes
idx_webhook_logs_agency(agency_id, received_at DESC)Agency webhook history
idx_webhook_logs_receivedreceived_at DESCChronological listing
idx_webhook_logs_failedreceived_at DESCFiltered: WHERE validation_success = false — failed requests

Related edge functions: webhook-ingest


enrichment_queue

Processing queue for call transcript fetching and AI analysis. Items are created by database triggers and processed by process-enrichment-queue (cron).

ColumnTypeDefaultNullableDescription
iduuiduuid_generate_v4()noPrimary key
call_iduuidnoFK → calls.id
typeenrichment_typenotranscript or analysis
statusprocessing_status'pending'noProcessing state
attemptsinteger0noNumber of processing attempts
max_attemptsinteger3noMaximum retries
error_messagetextyesLast error message
priorityinteger100noPriority (lower = higher priority)
created_attimestamptznow()noWhen the item was queued
processing_started_attimestamptzyesWhen processing began
processed_attimestamptzyesWhen processing completed
next_retry_attimestamptzyesWhen to retry after a failure

Constraints:

ConstraintTypeDetails
enrichment_queue_pkeyPrimary keyid
enrichment_queue_unique_pendingUnique(call_id, type, status) — prevents duplicate pending items
enrichment_queue_call_id_fkeyForeign keycall_idcalls(id) ON DELETE CASCADE
enrichment_queue_max_attemptsCheckattempts <= max_attempts

Indexes:

IndexColumnsNotes
idx_enrichment_queue_pending(priority, created_at)Filtered: WHERE status = 'pending' — priority-ordered dequeue
idx_enrichment_queue_retrynext_retry_atFiltered: WHERE status = 'failed' AND attempts < max_attempts — retryable items
idx_enrichment_queue_callcall_idItems for a specific call
idx_enrichment_queue_typetypeFilter by enrichment type
idx_enrichment_queue_statusstatusStatus monitoring
idx_enrichment_queue_processedprocessed_atFiltered: WHERE status = 'completed' — cleanup queries

Related edge functions: process-enrichment-queue

Trigger-based creation: Items are automatically inserted by database triggers on the calls table:

  1. call_ended_queue_transcript — inserts a transcript item when a call ends
  2. transcript_fetched_queue_analysis — inserts an analysis item when the transcript is fetched