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
| Property | Value |
|---|---|
| Function Name | import-telnyx-to-ultravox |
| HTTP Method | POST |
| Authentication | Supabase JWT (Bearer token) |
| Required Role | agency_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
| Status | Condition |
|---|---|
| 400 | Missing required credentials (response includes missing array listing which keys are absent) |
| 401 | Missing or invalid authorization header |
| 403 | User is not an agency user or is not an agency_owner |
| 405 | HTTP method is not POST |
| 500 | Failed to retrieve agency credentials |
| 500 | Internal server error |
| 502 | Ultravox API returned an error (proxied error message) |
Behavior
- Authenticates the user via Supabase JWT and verifies they have the
agency_ownerrole - Retrieves agency credentials using the
get_agency_credentialsRPC function - Validates that all four required credentials are present:
ultravox_api_key,telnyx_api_key,telnyx_public_key, andtelnyx_application_id(the application ID must exist from a prior provisioning run) - Sends a
PATCHrequest to the Ultravox telephony config endpoint with the Telnyx API key, public key, and application SID, enablingcallCreationAllowAllAgents - If the agency was not previously marked as telephony-configured, calls the
mark_telephony_configuredRPC to update the flag - Returns whether the Telnyx configuration was successfully applied in Ultravox
Database Tables Read/Written
| Table | Operation | Purpose |
|---|---|---|
users | Read | Verify user role and agency membership |
RPC Functions Called
| Function | Purpose |
|---|---|
get_agency_credentials | Retrieve decrypted API keys and Telnyx application ID |
mark_telephony_configured | Mark the agency as telephony-configured (if not already) |
External APIs Called
| API | Method | Endpoint | Purpose |
|---|---|---|---|
| Ultravox | PATCH | /api/accounts/me/telephony_config | Import Telnyx credentials into Ultravox |
Related Functions
- Provision Telephony -- Full end-to-end provisioning (includes this step)
- Verify Telephony Config -- Verify sync status between Virsyn DB and Ultravox
- Store Telnyx Credentials -- Store Telnyx API keys in the database