Skip to main content

Call Logs API Integration

Overview

The Call Logs API provides access to user call records including transcripts, summaries, and metadata. This API powers the CDC (Change Data Capture) pipeline that syncs external call data into the Syntropy-Journals health check-in system. The API is Directus-based (REST) and backed by Bland.ai telephony.

Base URL

https://directus-staging-ee94.up.railway.app/items/call_logs

Authentication

Bearer token via the Authorization header:
Authorization: Bearer <CALL_LOGS_API_KEY>
Configured via the CALL_LOGS_API_KEY environment variable.

Endpoints

GET /items/call_logs

Fetch call log records with filtering, sorting, and pagination. Headers:
HeaderValueRequired
acceptapplication/jsonYes
AuthorizationBearer <token>Yes
Query Parameters:
ParameterTypeDescriptionExample
limitintegerMax records to return50
offsetintegerRecords to skip0
sortstringSort field (- prefix = descending)-call_date
fieldsstringFields to include*.*
metastringMetadata fieldstotal_count,filter_count
filter[field][operator]stringFilter conditionsSee below
Filter Operators:
OperatorDescriptionExample
_eqEqualsfilter[caller_phone][_eq]=+12126804645
_nnullIs not nullfilter[full_transcript][_nnull]=true
_gtGreater thanfilter[duration][_gt]=60
_gteGreater than or equalfilter[call_date][_gte]=2025-01-01

Response Schema

Success Response (200 OK)

{
  "meta": {
    "total_count": 458,
    "filter_count": 2
  },
  "data": [
    {
      "id": 314,
      "date_created": "2025-04-26T00:21:16.359Z",
      "call_date": "2025-04-26T05:51:14",
      "duration": 120,
      "summary": "User discussed their morning routine...",
      "call_id": "871dd0b7-0d36-45a9-a29d-218f71aa0a28",
      "full_transcript": "AI: Hi! How are you doing today?...",
      "caller_phone": "+12126804645"
    }
  ]
}

Call Log Record Fields

FieldTypeNullableDescription
idintegerNoUnique identifier
date_createdstring (ISO 8601)NoRecord creation timestamp
call_datestring (ISO 8601)NoWhen the call occurred
durationintegerNoCall duration in seconds
summarystringYesHuman-readable summary
notesstring (JSON)YesAdditional metadata
call_idstring (UUID)NoUnique call identifier
full_transcriptstringYesComplete call transcript
caller_phonestringNoPhone number (E.164 format)

CDC Pipeline Integration

The call logs API feeds into the check-in CDC pipeline:
API Fetch -> Sync to call_logs table -> Claim unprocessed -> LLM Extract -> CheckIn + health entries

Processing Flow

  1. fetch_and_sync_raw() — Pull new records from API, upsert into call_logs table
  2. claim_unprocessed_call_logs_sync() — Atomically claim unprocessed records
  3. LLM extraction — Parse transcript into structured health data
  4. update_call_log_metrics() — Create CheckIn + MedicationEntry + FoodLogEntry + SymptomEntry
  5. On failure: unclaim_call_log_sync() — Reset for retry

Data Integrity

  • 1:1 mapping: Every processed CallLog has a corresponding CheckIn record
  • Idempotent: Same call log is never processed twice (claimed atomically)
  • Auto-fix: Orphaned CallLogs (processed=True but no CheckIn) are detected and reset on page load

Python Usage

import httpx

async def fetch_calls_with_transcripts(phone_number: str, token: str):
    async with httpx.AsyncClient() as client:
        response = await client.get(
            "https://directus-staging-ee94.up.railway.app/items/call_logs",
            params={
                "limit": 50,
                "sort": "-call_date",
                "fields": "*.*",
                "filter[caller_phone][_eq]": phone_number,
                "filter[full_transcript][_nnull]": "true",
            },
            headers={
                "accept": "application/json",
                "Authorization": f"Bearer {token}",
            },
            timeout=30.0,
        )
        response.raise_for_status()
        return response.json()

Error Responses

StatusCodeDescription
401INVALID_TOKENInvalid or expired bearer token
403FORBIDDENInsufficient permissions
400INVALID_QUERYMalformed query parameters

Rate Limits

  • Default: 100 requests per minute per token
  • Burst: Up to 10 concurrent requests

Environment Variables

VariableDescriptionRequired
CALL_LOGS_API_KEYBearer token for API authenticationYes
CALL_LOGS_API_BASEBase URL overrideNo