Skip to main content

Get Integration Status

Retrieves a comprehensive overview of the agency's integration configuration, including Ultravox and Telnyx API key status, telephony provisioning state, webhook URL, and actionable next steps. This endpoint powers the settings/integration status page in the frontend.

Endpoint

PropertyValue
Function Nameget-integration-status
HTTP MethodGET
AuthenticationSupabase JWT (Bearer token in Authorization header)
Required RoleAny authenticated agency user

Request

Headers

HeaderRequiredDescription
AuthorizationYesBearer <supabase_jwt>

Query Parameters

None.

Response

Success (200)

{
"agency_id": "uuid",
"agency_name": "Acme Corp",
"webhook_url": "https://your-project.supabase.co/functions/v1/webhook-ingest/{agency_id}/{webhook_secret}",

"ultravox": {
"configured": true,
"added_at": "2025-01-15T10:00:00Z",
"validated_at": "2025-01-15T10:01:00Z"
},

"telnyx": {
"configured": true,
"has_public_key": true,
"added_at": "2025-01-16T12:00:00Z",
"validated_at": "2025-01-16T12:01:00Z",
"application_id": "telnyx-app-id",
"outbound_profile_id": "telnyx-profile-id",
"provisioned": true
},

"ready_for_provisioning": true,
"telephony_configured": true,

"next_steps": [
"Ready! You can now create agents and purchase phone numbers"
],

"can_manage_agents": true,
"can_manage_phone_numbers": true,
"can_run_campaigns": true
}

Error Responses

StatusCondition
401Missing or invalid Authorization header / JWT token
403Authenticated user is not associated with an agency
404Agency record not found in database
405HTTP method is not GET
500Unexpected server error

Behavior

  • Handles CORS preflight (OPTIONS) requests and rejects non-GET methods with a 405.
  • Validates the JWT token via supabase.auth.getUser().
  • Looks up the user's agency_id and role from the users table.
  • Fetches the full agency record from the agencies table, including:
    • Encrypted API key presence indicators (not the keys themselves)
    • Timestamps for when keys were added and validated
    • Telnyx provisioning IDs (application_id, outbound_profile_id)
    • Overall telephony_configured flag
  • Constructs the agency's webhook URL from the Supabase URL, agency ID, and webhook secret.
  • Computes derived status fields:
    • ultravox.configured: Whether an encrypted Ultravox API key exists.
    • telnyx.configured: Whether an encrypted Telnyx API key exists.
    • telnyx.has_public_key: Whether a Telnyx public key is stored (needed for webhook verification).
    • telnyx.provisioned: Whether both application_id and outbound_profile_id are set.
    • ready_for_provisioning: Ultravox configured AND Telnyx configured AND Telnyx public key present.
    • telephony_configured: Mirrors the telephony_configured column from the agency record.
  • Generates a prioritized next_steps list guiding the user through the setup process.
  • Sets capability flags (can_manage_agents, can_manage_phone_numbers, can_run_campaigns) based on configuration completeness.

Database Tables

TableOperationDescription
usersReadFetches agency_id and role for the authenticated user
agenciesReadFetches full integration configuration for the agency

External APIs

None.