Skip to main content

Import Telnyx to Ultravox

Imports the agency's Telnyx credentials into their Ultravox account so that Ultravox can make and receive calls via Telnyx. This function is useful for retrying a failed Ultravox import after successful Telnyx provisioning, updating Ultravox after changing Telnyx credentials, or re-syncing if the Ultravox config was accidentally changed.

Endpoint

PropertyValue
Function Nameimport-telnyx-to-ultravox
HTTP MethodPOST
AuthenticationSupabase JWT (Bearer token)
Required Roleagency_owner

Request

Headers

Authorization: Bearer <supabase_jwt_token>
Content-Type: application/json

Body

No request body is required. All credentials are read from the database.

Response

Success (200)

{
"success": true,
"telnyx_configured_in_ultravox": true,
"application_id": "telnyx-application-id"
}

Error Responses

StatusCondition
400Missing required credentials (response includes missing array listing which keys are absent)
401Missing or invalid authorization header
403User is not an agency user or is not an agency_owner
405HTTP method is not POST
500Failed to retrieve agency credentials
500Internal server error
502Ultravox API returned an error (proxied error message)

Behavior

  • Authenticates the user via Supabase JWT and verifies they have the agency_owner role
  • Retrieves agency credentials using the get_agency_credentials RPC function
  • Validates that all four required credentials are present: ultravox_api_key, telnyx_api_key, telnyx_public_key, and telnyx_application_id (the application ID must exist from a prior provisioning run)
  • Sends a PATCH request to the Ultravox telephony config endpoint with the Telnyx API key, public key, and application SID, enabling callCreationAllowAllAgents
  • If the agency was not previously marked as telephony-configured, calls the mark_telephony_configured RPC to update the flag
  • Returns whether the Telnyx configuration was successfully applied in Ultravox

Database Tables Read/Written

TableOperationPurpose
usersReadVerify user role and agency membership

RPC Functions Called

FunctionPurpose
get_agency_credentialsRetrieve decrypted API keys and Telnyx application ID
mark_telephony_configuredMark the agency as telephony-configured (if not already)

External APIs Called

APIMethodEndpointPurpose
UltravoxPATCH/api/accounts/me/telephony_configImport Telnyx credentials into Ultravox