Skip to main content

Get Call Batch

Returns a single batch with its summary data and a paginated list of contacts. Batch data comes from the v_call_batch_summary view; contacts come from the campaign_contacts table.

Endpoint

PropertyValue
Function Namecalls-batch-get
HTTP MethodGET
AuthenticationSupabase JWT (Bearer token)
Required RoleAny authenticated agency user

Request

Headers

Authorization: Bearer <supabase_jwt_token>

Query Parameters

FieldTypeRequiredDescription
batch_idstring (UUID)YesThe batch to retrieve
contact_statusstringNoFilter contacts by status: pending, queued, in_progress, completed, failed, skipped
contact_limitnumberNoNumber of contacts per page. Default: 50, max: 200.
contact_offsetnumberNoPagination offset for contacts. Default: 0.

Response

Success (200)

{
"batch": {
"id": "uuid",
"agency_id": "uuid",
"campaign_id": "uuid",
"campaign_name": "Q1 Outreach",
"agent_mapping_id": "uuid",
"agent_name": "Sales Agent",
"from_number": "+15551234567",
"status": "processing",
"total_contacts": 1000,
"queued": 500,
"in_progress": 5,
"completed": 400,
"failed": 10,
"skipped": 0,
"progress_percentage": 41.0,
"remaining_count": 590,
"calls_per_minute": 30,
"max_concurrent": 10,
"scheduled_for": null,
"created_at": "2025-01-15T10:30:00Z",
"started_at": "2025-01-15T10:31:00Z"
},
"contacts": [
{
"id": "uuid",
"phone_number": "+15559876543",
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com",
"company": "ACME",
"title": "Manager",
"status": "completed",
"call_id": "uuid",
"attempts": 1,
"max_attempts": 3,
"outcome": "answered",
"duration_seconds": 145,
"outcome_notes": null,
"last_attempt_at": "2025-01-15T10:35:00Z",
"completed_at": "2025-01-15T10:37:25Z",
"custom_data": {},
"do_not_call": false,
"timezone": "EST",
"created_at": "2025-01-15T10:30:00Z"
}
],
"contact_pagination": {
"total": 1000,
"limit": 50,
"offset": 0,
"has_more": true
}
}

Error Responses

StatusCondition
400batch_id query parameter is missing
401Missing or invalid authorization header
403User is not associated with an agency
404Batch not found or does not belong to the user's agency
405HTTP method is not GET
500Failed to fetch batch or contacts from the database

Behavior

  • Authenticates the user via Supabase JWT and retrieves their agency_id.
  • Fetches the batch from v_call_batch_summary filtered by batch_id and agency_id.
  • Fetches contacts from campaign_contacts for the batch with optional contact_status filter.
  • Returns contacts ordered by created_at ascending with pagination.

Database Tables

Table / ViewOperationDescription
usersReadFetches user profile to determine agency_id
v_call_batch_summaryReadRetrieves batch summary with agent and campaign names
campaign_contactsReadRetrieves paginated contacts with call details and outcomes

External APIs

None.