Skip to main content

Get Call Recording

Fetches a fresh signed URL for a call's audio recording from the Ultravox API. The caller must be an authenticated agency user, and the call must belong to their agency and have a recording available.

Endpoint

PropertyValue
Function Nameget-call-recording
HTTP MethodGET
AuthenticationSupabase JWT (Bearer token in Authorization header)
Required RoleAny authenticated agency user (ownership validated by matching agency_id)

Request

Headers

HeaderRequiredDescription
AuthorizationYesBearer <supabase_jwt>

Query Parameters

FieldTypeRequiredDescription
call_idstring (UUID)YesThe internal call ID (not the Ultravox call ID)
GET /functions/v1/get-call-recording?call_id=550e8400-e29b-41d4-a716-446655440000

Response

Success (200)

{
"recording_url": "https://storage.example.com/recordings/call-abc123.wav?signature=..."
}

The recording_url is a time-limited signed URL that can be used to stream or download the recording.

Error Responses

StatusCondition
400call_id query parameter is missing
400Ultravox API key is not configured for the agency
401Missing or invalid Authorization header / JWT token
403Authenticated user is not associated with an agency
404Call not found, does not belong to the user's agency, or has_recording is false
404Recording not available from Ultravox (no redirect or valid response)
500Failed to retrieve agency credentials or unexpected server error

Behavior

  • Handles CORS preflight (OPTIONS) requests.
  • Validates the JWT token via supabase.auth.getUser().
  • Looks up the user's agency_id from the users table.
  • Fetches the call record from the calls table and verifies:
    • The call exists.
    • The call's agency_id matches the user's agency.
    • The call's has_recording flag is true.
  • Retrieves the agency's decrypted Ultravox API key via the get_agency_credentials RPC.
  • Makes a request to the Ultravox recording endpoint with redirect: 'manual':
    • If a 302 redirect is returned, extracts the signed URL from the Location header.
    • If a 200 response is returned, constructs the direct recording URL.
    • Otherwise, returns a 404 indicating the recording is not available.

Database Tables / RPCs

Table / RPCOperationDescription
usersReadFetches agency_id for the authenticated user
callsReadFetches ultravox_call_id, agency_id, and has_recording for ownership and availability verification
get_agency_credentials (RPC)ReadRetrieves the decrypted Ultravox API key for the agency

External APIs

APIMethodEndpointDescription
UltravoxGET/api/calls/{ultravox_call_id}/recordingRetrieves a signed URL for the call recording (returns 302 redirect or direct audio)
  • process-enrichment-queue -- Fetches transcripts and checks recording availability during enrichment
  • webhook-ingest -- Ingests call events that eventually create the call records queried here