### List All Networks (Go) Source: https://developers.telnyx.com/api-reference/networks/list-all-networks This Go example shows how to initialize the Telnyx client and list networks. Ensure you have the telnyx-go library installed. ```go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.Networks.List(context.TODO(), telnyx.NetworkListParams{}) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` -------------------------------- ### Assistant Configuration Example Source: https://developers.telnyx.com/api-reference/assistants/create-an-assistant Defines an assistant with specific LLM, transcription, and voice settings. Use this for initial assistant setup. ```json { "id": "n_intake", "instructions": "Focus on intake questions. Use the billing tool to look up the caller's latest invoice before answering.", "externalLlm": { "baseURL": "base_url", "model": "model", "authenticationMethod": "token", "certificateRef": "certificate_ref", "forwardMetadata": true, "llmAPIKeyRef": "llm_api_key_ref", "tokenRetrievalURL": "token_retrieval_url" }, "instructionsMode": "replace", "llmAPIKeyRef": "my-key-ref", "model": "moonshotai/Kimi-K2.6", "name": "Intake", "position": {"x": 120, "y": 80}, "sharedToolIDs": ["tool-faq-kb"], "toolsMode": "replace", "transcription": { "apiKeyRef": "api_key_ref", "language": "language", "model": "deepgram/flux", "region": "region", "settings": { "eagerEotThreshold": 0.3, "enableEndpointDetection": true, "endOfTurnConfidenceThreshold": 0, "eotThreshold": 0.5, "eotTimeoutMs": 500, "interimResults": true, "keyterm": "keyterm", "maxEndpointDelayMs": 500, "maxTurnSilence": 100, "minTurnSilence": 100, "numerals": true, "smartFormat": true } }, "type": "prompt", "voiceSettings": { "voice": "voice", "apiKeyRef": "api_key_ref", "backgroundAudio": { "type": "predefined_media", "value": "silence", "volume": 0.1 }, "expressiveMode": true, "languageBoost": "auto", "similarityBoost": 0, "speed": 0, "style": 0, "temperature": 0, "useSpeakerBoost": true, "voiceSpeed": 0 } } ``` -------------------------------- ### Start a Mission Run (CLI) Source: https://developers.telnyx.com/api-reference/missions/start-a-run This command-line interface example shows how to start a mission run using the Telnyx CLI tool. Provide your API key and the mission ID. ```CLI telnyx ai:missions:runs create \ --api-key 'My API Key' \ --mission-id 182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e ``` -------------------------------- ### Get AI Embeddings Tasks (Ruby) Source: https://developers.telnyx.com/api-reference/embeddings/get-tasks-by-status This Ruby example retrieves AI embedding tasks. Ensure the Telnyx gem is installed and provide your API key. ```ruby require "telnyx" telnyx = Telnyx::Client.new(api_key: "My API Key") embeddings = telnyx.ai.embeddings.list puts(embeddings) ``` -------------------------------- ### List Managed Accounts (Go) Source: https://developers.telnyx.com/api-reference/managed-accounts/lists-accounts-managed-by-the-current-user This Go example shows how to initialize the Telnyx client and list managed accounts. ```Go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.ManagedAccounts.List(context.TODO(), telnyx.ManagedAccountListParams{}) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` -------------------------------- ### Get API Usage - Python Source: https://developers.telnyx.com/api-reference/bucket-usage/get-api-usage This Python example shows how to get API usage for a Telnyx bucket. It requires the Telnyx Python library and an environment variable for your API key. The filter parameter accepts datetime objects for start and end times. ```python import os from datetime import datetime from telnyx import Telnyx client = Telnyx( api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted ) response = client.storage.buckets.usage.get_api_usage( bucket_name="", filter={ "end_time": datetime.fromisoformat("2019-12-27T18:11:19.117"), "start_time": datetime.fromisoformat("2019-12-27T18:11:19.117"), }, ) print(response.data) ``` -------------------------------- ### Get Conference Participant (PHP) Source: https://developers.telnyx.com/api-reference/texml-rest-commands/get-conference-participant-resource Retrieves a conference participant resource using the Telnyx PHP client. This example assumes you have the Telnyx PHP package installed via Composer. ```PHP calls()->streamingStart( 'call_control_id', [ 'stream_url' => 'wss://www.example.com/websocket', 'stream_track' => 'both_tracks', 'stream_codec' => StreamCodec::PCMA, 'stream_bidirectional_mode' => StreamBidirectionalMode::RTP, 'stream_bidirectional_codec' => StreamBidirectionalCodec::G722, 'stream_bidirectional_sampling_rate' => StreamBidirectionalSamplingRate::RATE_16000, 'stream_bidirectional_target_legs' => StreamBidirectionalTargetLegs::BOTH, 'enable_dialogflow' => false, 'dialogflow_config' => [ 'analyzeSentiment' => false, 'partialAutomatedAgentReply' => false ], 'stream_auth_token' => 'your-auth-token', 'custom_parameters' => [ ['name' => 'param1', 'value' => 'value1'], ['name' => 'param2', 'value' => 'value2'], ], ] ); var_dump($response); } catch (APIException $e) { echo $e->getMessage(); } ``` -------------------------------- ### Create FQDN using Go Source: https://developers.telnyx.com/api-reference/fqdns/create-an-fqdn This Go example demonstrates creating an FQDN with the Telnyx Go SDK. It requires setting up the client with an API key and providing the necessary parameters. ```go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) fqdn, err := client.Fqdns.New(context.TODO(), telnyx.FqdnNewParams{ ConnectionID: "1516447646313612565", DNSRecordType: "a", Fqdn: "example.com", }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", fqdn.Data) } ``` -------------------------------- ### Get API Usage with PHP Source: https://developers.telnyx.com/api-reference/bucket-usage/get-api-usage Fetch API usage data for a bucket using the PHP client. This example includes error handling for API exceptions and requires the Telnyx SDK to be installed. ```php storage->buckets->usage->getAPIUsage( '', filter: [ 'endTime' => new \DateTimeImmutable('2019-12-27T18:11:19.117Z'), 'startTime' => new \DateTimeImmutable('2019-12-27T18:11:19.117Z'), ], ); var_dump($response); } catch (APIException $e) { echo $e->getMessage(); } ``` -------------------------------- ### Get API Usage - JavaScript Source: https://developers.telnyx.com/api-reference/bucket-usage/get-api-usage Use this JavaScript snippet to retrieve API usage for a specific bucket. Ensure you have the Telnyx SDK installed and your API key configured. The filter parameter requires start and end times. ```javascript import Telnyx from 'telnyx'; const client = new Telnyx({ apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted }); const response = await client.storage.buckets.usage.getAPIUsage('', { filter: { end_time: '2019-12-27T18:11:19.117Z', start_time: '2019-12-27T18:11:19.117Z' }, }); console.log(response.data); ``` -------------------------------- ### Create Managed Account with Go Source: https://developers.telnyx.com/api-reference/managed-accounts/create-a-new-managed-account This Go example demonstrates creating a managed account using the Telnyx Go SDK. It requires setting up the client with an API key. ```Go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) managedAccount, err := client.ManagedAccounts.New(context.TODO(), telnyx.ManagedAccountNewParams{ BusinessName: "Larry's Cat Food Inc", }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", managedAccount.Data) } ``` -------------------------------- ### Assistant Configuration Example Source: https://developers.telnyx.com/api-reference/assistants/create-an-assistant This snippet shows a detailed configuration for an assistant, including LLM settings, fallback configurations, and various integration and telephony settings. It's useful for setting up complex conversational agents. ```php $assistant = [ 'name' => 'name', 'description' => 'description', 'dynamicVariables' => ['foo' => 'bar'], 'dynamicVariablesWebhookTimeoutMs' => 1, 'dynamicVariablesWebhookURL' => 'dynamic_variables_webhook_url', 'enabledFeatures' => [ EnabledFeatures::TELEPHONY ], 'externalLlm' => [ 'baseURL' => 'base_url', 'model' => 'model', 'authenticationMethod' => 'token', 'certificateRef' => 'certificate_ref', 'forwardMetadata' => true, 'llmAPIKeyRef' => 'llm_api_key_ref', 'tokenRetrievalURL' => 'token_retrieval_url', ], 'fallbackConfig' => [ 'externalLlm' => [ 'baseURL' => 'base_url', 'model' => 'model', 'authenticationMethod' => 'token', 'certificateRef' => 'certificate_ref', 'forwardMetadata' => true, 'llmAPIKeyRef' => 'llm_api_key_ref', 'tokenRetrievalURL' => 'token_retrieval_url', ], 'llmAPIKeyRef' => 'llm_api_key_ref', 'model' => 'model', ], 'greeting' => 'greeting', 'insightSettings' => ['insightGroupID' => 'insight_group_id'], 'integrations' => [ ['integrationID' => 'integration_id', 'allowedList' => ['string']] ], 'interruptionSettings' => [ 'disableGreetingInterruption' => true, 'enable' => true, 'startSpeakingPlan' => [ 'transcriptionEndpointingPlan' => [ 'onNoPunctuationSeconds' => 0, 'onNumberSeconds' => 0, 'onPunctuationSeconds' => 0, ], 'waitSeconds' => 0, ], ], 'llmAPIKeyRef' => 'llm_api_key_ref', 'mcpServers' => [['id' => 'id', 'allowedTools' => ['string']]], 'messagingSettings' => [ 'conversationInactivityMinutes' => 1, 'defaultMessagingProfileID' => 'default_messaging_profile_id', 'deliveryStatusWebhookURL' => 'delivery_status_webhook_url', ], 'model' => 'model', 'observabilitySettings' => [ 'host' => 'host', 'promptLabel' => 'prompt_label', 'promptName' => 'prompt_name', 'promptSync' => 'enabled', 'promptVersion' => 1, 'publicKeyRef' => 'public_key_ref', 'secretKeyRef' => 'secret_key_ref', 'status' => 'enabled', ], 'postConversationSettings' => ['enabled' => true], 'privacySettings' => ['dataRetention' => true], 'tags' => ['string'], 'telephonySettings' => [ 'defaultTexmlAppID' => 'default_texml_app_id', 'noiseSuppression' => 'krisp', 'noiseSuppressionConfig' => [ 'attenuationLimit' => 0, 'mode' => 'advanced' ], 'recordingSettings' => [ 'channels' => 'single', 'enabled' => true, 'format' => 'wav', 'stopOnConversationEnd' => true, ], 'supportsUnauthenticatedWebCalls' => true, ], ]; ``` -------------------------------- ### Transcription Start Request Example Source: https://developers.telnyx.com/api-reference/call-commands/transcription-start An example of a TranscriptionStartRequest object, demonstrating the structure and common parameters for initiating a transcription. ```json { "transcription_engine": "Google", "transcription_engine_config": { "transcription_engine": "Google", "language": "en" }, "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d", "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901" } ``` -------------------------------- ### Start SIPREC Session (Java) Source: https://developers.telnyx.com/api-reference/call-commands/siprec-start Example of starting a SIPREC session using the Telnyx Java SDK. The client is initialized from environment variables. ```java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.calls.actions.ActionStartSiprecParams; import com.telnyx.sdk.models.calls.actions.ActionStartSiprecResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); ActionStartSiprecResponse response = client.calls().actions().startSiprec("call_control_id"); } } ``` -------------------------------- ### List All Clusters (Go) Source: https://developers.telnyx.com/api-reference/clusters/list-all-clusters This Go example shows how to list clusters using the Telnyx Go client. It initializes the client with an API key and fetches the cluster list. ```Go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.AI.Clusters.List(context.TODO(), telnyx.AIClusterListParams{}) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` -------------------------------- ### Successful Response Example Source: https://developers.telnyx.com/api-reference/texml-rest-commands/list-conference-recordings This is an example of a successful JSON response when listing conference recordings. It includes pagination details and the start and end of the recording list. ```json { "participants": [], "end": 0, "first_page_uri": "/v2/texml/Accounts/61bf923e-5e4d-4595-a110-56190ea18a1b/Conferences/6dc6cc1a-1ba1-4351-86b8-4c22c95cd98f/Recordings.json?page=0&pagesize=20", "page": 0, "page_size": 20, "start": 0, "uri": "/v2/texml/Accounts/61bf923e-5e4d-4595-a110-56190ea18a1b/Conferences/6dc6cc1a-1ba1-4351-86b8-4c22c95cd98f/Recordings.json?page=0&pagesize=20" } ``` -------------------------------- ### Create Room Composition with Go Source: https://developers.telnyx.com/api-reference/room-compositions/create-a-room-composition This Go example demonstrates creating a room composition using the Telnyx Go SDK. Replace 'My API Key' with your actual key. ```go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) roomComposition, err := client.RoomCompositions.New(context.TODO(), telnyx.RoomCompositionNewParams{}) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", roomComposition.Data) } ``` -------------------------------- ### Start Streaming Media (Java) Source: https://developers.telnyx.com/api-reference/texml-rest-commands/start-streaming-media-from-a-call Example of starting media streaming from a call using the Telnyx Java SDK. Ensure the TelnyxClient is properly initialized. ```Java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.texml.accounts.calls.CallStreamsJsonParams; import com.telnyx.sdk.models.texml.accounts.calls.CallStreamsJsonResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); CallStreamsJsonParams params = CallStreamsJsonParams.builder() .accountSid("account_sid") .callSid("call_sid") .build(); CallStreamsJsonResponse response = client.texml().accounts().calls().streamsJson(params); } } ``` -------------------------------- ### List room sessions (Go) Source: https://developers.telnyx.com/api-reference/room-sessions/view-a-list-of-room-sessions This Go example shows how to initialize the Telnyx client and list room sessions. Replace 'My API Key' with your actual API key. ```go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.Rooms.Sessions.List0(context.TODO(), telnyx.RoomSessionList0Params{}) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` -------------------------------- ### Start Conference Recording CLI Source: https://developers.telnyx.com/api-reference/conference-commands/conference-recording-start This example demonstrates how to start recording a conference using the Telnyx CLI. You can specify the audio format and the conference ID. ```APIDOC ## Start Conference Recording ### Description Starts recording a conference. You can specify the audio format, command ID, channels, beep sound, trim silence, custom file name, and region. ### Method `POST` ### Endpoint `/v2/conferences/{conference_id}/actions/record-start` ### Parameters #### Path Parameters - **conference_id** (string) - Required - The ID of the conference to record. #### Request Body - **format** (string) - Required - The audio file format used when storing the conference recording. Can be either `mp3` or `wav`. - **command_id** (string) - Optional - Use this field to avoid duplicate commands. Telnyx will ignore any command with the same `command_id` for the same `conference_id`. - **channels** (string) - Optional - When `dual`, final audio file will be stereo recorded with the conference creator on the first channel, and the rest on the second channel. Defaults to `single`. - **play_beep** (boolean) - Optional - If enabled, a beep sound will be played at the start of a recording. - **trim** (string) - Optional - When set to `trim-silence`, silence will be removed from the beginning and end of the recording. - **custom_file_name** (string) - Optional - The custom recording file name to be used instead of the default `call_leg_id`. Telnyx will still add a Unix timestamp suffix. - **region** (string) - Optional - Region where the conference data is located. Defaults to the region defined in user's data locality settings (Europe or US). ### Request Example ```json { "format": "wav", "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901", "play_beep": true, "trim": "trim-silence", "custom_file_name": "my_recording_file_name", "region": "US" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the result of the command. - **result** (string) - The result of the command, e.g., 'ok'. #### Response Example ```json { "data": { "result": "ok" } } ``` ``` -------------------------------- ### List Knowledge Bases (Go) Source: https://developers.telnyx.com/api-reference/missions/list-knowledge-bases This Go example shows how to list knowledge bases for a mission using the Telnyx Go SDK. It requires setting up the client with an API key and providing the mission ID. ```Go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) response, err := client.AI.Missions.KnowledgeBases.ListKnowledgeBases(context.TODO(), "mission_id") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response) } ``` -------------------------------- ### Start a Mission Run (JavaScript) Source: https://developers.telnyx.com/api-reference/missions/start-a-run Use this snippet to start a new run for a mission. Ensure you have the Telnyx SDK installed and your API key configured. ```JavaScript import Telnyx from 'telnyx'; const client = new Telnyx({ apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted }); const run = await client.ai.missions.runs.create('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e'); console.log(run.data); ``` -------------------------------- ### List Rooms with Go SDK Source: https://developers.telnyx.com/api-reference/rooms/view-a-list-of-rooms This Go code example demonstrates how to initialize the Telnyx Go client and list rooms. Ensure you provide a valid API key and handle potential errors. ```Go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.Rooms.List(context.TODO(), telnyx.RoomListParams{}) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` -------------------------------- ### Start SIPREC Session (PHP) Source: https://developers.telnyx.com/api-reference/call-commands/siprec-start Starts a SIPREC session using the Telnyx PHP library. This example shows various optional parameters for the SIPREC session. ```php calls->actions->startSiprec( 'call_control_id', clientState: 'aGF2ZSBhIG5pY2UgZGF5ID1d', connectorName: 'my-siprec-connector', includeMetadataCustomHeaders: true, secure: true, sessionTimeoutSecs: 900, sipTransport: 'tcp', siprecTrack: 'both_tracks', ); var_dump($response); } catch (APIException $e) { echo $e->getMessage(); } ``` -------------------------------- ### Create Knowledge Base with Java Source: https://developers.telnyx.com/api-reference/missions/create-knowledge-base This Java example shows how to create a knowledge base for an AI mission using the Telnyx Java SDK. The client is initialized from environment variables. ```java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.ai.missions.knowledgebases.KnowledgeBaseCreateKnowledgeBaseParams; import com.telnyx.sdk.models.ai.missions.knowledgebases.KnowledgeBaseCreateKnowledgeBaseResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); KnowledgeBaseCreateKnowledgeBaseResponse response = client.ai().missions().knowledgeBases().createKnowledgeBase("mission_id"); } } ``` -------------------------------- ### Start Streaming Media (JavaScript) Source: https://developers.telnyx.com/api-reference/texml-rest-commands/start-streaming-media-from-a-call Use this snippet to start streaming media from a call in JavaScript. Ensure you have the Telnyx SDK installed and your API key configured. ```JavaScript import Telnyx from 'telnyx'; const client = new Telnyx({ apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted }); const response = await client.texml.accounts.calls.streamsJson('call_sid', { account_sid: 'account_sid', }); console.log(response.account_sid); ``` -------------------------------- ### List Tools for a Mission (Java) Source: https://developers.telnyx.com/api-reference/missions/list-tools This Java example demonstrates listing tools for a mission using the Telnyx Java SDK. It initializes the client from environment variables. ```Java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.ai.missions.tools.ToolListToolsParams; import com.telnyx.sdk.models.ai.missions.tools.ToolListToolsResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); ToolListToolsResponse response = client.ai().missions().tools().listTools("mission_id"); } } ``` -------------------------------- ### List Fine-Tuning Jobs in Go Source: https://developers.telnyx.com/api-reference/fine-tuning/list-fine-tuning-jobs This Go example demonstrates how to list fine-tuning jobs using the Telnyx Go SDK. It requires setting up the client with an API key and handling potential errors. ```go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) jobs, err := client.AI.FineTuning.Jobs.List(context.TODO()) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", jobs.Data) } ``` -------------------------------- ### Start a Mission Run (Ruby) Source: https://developers.telnyx.com/api-reference/missions/start-a-run This Ruby snippet shows how to start a mission run. Ensure the Telnyx Ruby gem is installed and your API key is set. ```Ruby require "telnyx" telnyx = Telnyx::Client.new(api_key: "My API Key") run = telnyx.ai.missions.runs.create("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") puts(run) ``` -------------------------------- ### Start AI Assistant with PHP Source: https://developers.telnyx.com/api-reference/call-commands/start-ai-assistant Utilize the Telnyx PHP SDK to enable an AI assistant on a call. This example shows basic initialization and the call to start the assistant. ```php calls->actions->startAIAssistant( 'call_control_id', assistant: [ 'id' => 'id', 'dynamicVariables' => [ 'customer_name' => 'John', 'account_id' => 'ACC-12345' ], 'externalLlm' => [ 'authenticationMethod' => 'token', 'baseURL' => 'base_url', 'certificateRef' => 'certificate_ref', 'forwardMetadata' => true, 'llmAPIKeyRef' => 'llm_api_key_ref', 'model' => 'model', 'tokenRetrievalURL' => 'token_retrieval_url', ], 'fallbackConfig' => [ 'externalLlm' => [ ``` -------------------------------- ### List Migration Sources in Java Source: https://developers.telnyx.com/api-reference/data-migration/list-all-migration-sources This Java example shows how to list migration sources using the Telnyx Java SDK. It initializes the client from environment variables. ```java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.storage.migrationsources.MigrationSourceListParams; import com.telnyx.sdk.models.storage.migrationsources.MigrationSourceListResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); MigrationSourceListResponse migrationSources = client.storage().migrationSources().list(); } } ``` -------------------------------- ### List Room Compositions with Go SDK Source: https://developers.telnyx.com/api-reference/room-compositions/view-a-list-of-room-compositions Use the Telnyx Go SDK to list room compositions. This example demonstrates basic client initialization and listing. ```Go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.RoomCompositions.List(context.TODO(), telnyx.RoomCompositionListParams{}) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` -------------------------------- ### Get Bucket Usage with Java Source: https://developers.telnyx.com/api-reference/bucket-usage/get-bucket-usage This Java example shows how to get bucket usage information using the Telnyx Java SDK. It initializes the client from environment variables. ```Java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.storage.buckets.usage.UsageGetBucketUsageParams; import com.telnyx.sdk.models.storage.buckets.usage.UsageGetBucketUsageResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); UsageGetBucketUsageResponse response = client.storage().buckets().usage().getBucketUsage(""); } } ``` -------------------------------- ### Create TeXML Application using CLI Source: https://developers.telnyx.com/api-reference/texml-applications/creates-a-texml-application This command-line interface example shows how to create a TeXML application. It requires your API key, a friendly name, and a voice URL. Additional parameters can be appended to configure the application further. ```bash telnyx texml-applications create \ --api-key 'My API Key' \ --friendly-name call-router \ --voice-url https://example.com ``` -------------------------------- ### Get Conference Participant (Ruby) Source: https://developers.telnyx.com/api-reference/texml-rest-commands/get-conference-participant-resource Shows how to get a conference participant resource using the Telnyx Ruby gem. Requires the gem to be installed and an API key to be provided. ```Ruby require "telnyx" telnyx = Telnyx::Client.new(api_key: "My API Key") participant = telnyx.texml.accounts.conferences.participants.retrieve( "call_sid_or_participant_label", account_sid: "account_sid", conference_sid: "conference_sid" ) puts(participant) ``` -------------------------------- ### Run Portability Check - Go Source: https://developers.telnyx.com/api-reference/phone-number-porting/run-a-portability-check This Go code example shows how to run a portability check using the Telnyx Go SDK. It requires setting up the client with an API key and providing an empty params struct. ```go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) response, err := client.PortabilityChecks.Run(context.TODO(), telnyx.PortabilityCheckRunParams{}) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Data) } ``` -------------------------------- ### Get Sharing Status (Go) Source: https://developers.telnyx.com/api-reference/shared-campaigns/get-sharing-status Example of how to get the sharing status of a 10DLC partner campaign using the Telnyx Go SDK. Requires context and API key configuration. ```go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) response, err := client.Messaging10dlc.PartnerCampaigns.GetSharingStatus(context.TODO(), "campaignId") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response) } ``` -------------------------------- ### Create Initial Plan - Java Source: https://developers.telnyx.com/api-reference/missions/create-initial-plan This Java example shows how to create an initial plan for an AI mission run using the Telnyx Java SDK. Ensure the Telnyx client is initialized with your API key. ```java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.ai.missions.runs.plan.PlanCreateParams; import com.telnyx.sdk.models.ai.missions.runs.plan.PlanCreateResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); PlanCreateParams params = PlanCreateParams.builder() .missionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .runId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addStep(PlanCreateParams.Step.builder() .description("description") .sequence(0L) .stepId("step_id") .build()) .build(); PlanCreateResponse plan = client.ai().missions().runs().plan().create(params); } } ``` -------------------------------- ### Start Forking Request Body Source: https://developers.telnyx.com/api-reference/call-commands/forking-start Example of a request body to start forking, specifying media stream targets and optional parameters like client state and command ID. ```json { "rx": "udp:192.0.2.1:9000", "tx": "udp:192.0.2.1:9001", "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d", "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901" } ``` -------------------------------- ### Create AI Assistant with PHP Source: https://developers.telnyx.com/api-reference/assistants/create-an-assistant This PHP example demonstrates creating an AI Assistant. It includes basic setup and error handling for API calls. ```PHP ai->assistants->create( instructions: 'instructions', name: 'name', conversationFlow: [ 'nodes' => [ [ 'id' => 'n_intake', 'instructions' => 'Greet the caller and ask what they\'re calling about.', 'externalLlm' => [ 'baseURL' => 'base_url', 'model' => 'model', 'authenticationMethod' => 'token', 'certificateRef' => 'certificate_ref', 'forwardMetadata' => true, ``` -------------------------------- ### Example CLI Usage for Test Run Details Source: https://developers.telnyx.com/api-reference/assistants/get-specific-test-run-details This example shows how to use the CLI to retrieve details for a specific test run. Ensure you replace 'My API Key', 'test_id', and 'run_id' with your actual values. ```bash --api-key 'My API Key' \ --test-id test_id \ --run-id run_id ``` -------------------------------- ### Get Usage Report Options in PHP Source: https://developers.telnyx.com/api-reference/usage-reports-beta/get-usage-reports-query-options-beta Use the Telnyx PHP SDK to get usage report query options. This example includes basic error handling for API exceptions. ```PHP usageReports->getOptions( product: 'product', authorizationBearer: 'authorization_bearer' ); var_dump($response); } catch (APIException $e) { echo $e->getMessage(); } ``` -------------------------------- ### List Campaigns in Java Source: https://developers.telnyx.com/api-reference/campaign/list-campaigns Example of initializing the Telnyx Java client from environment variables and preparing to list campaigns. ```java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.messaging10dlc.campaign.CampaignListPage; import com.telnyx.sdk.models.messaging10dlc.campaign.CampaignListParams; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); ``` -------------------------------- ### Get Pending Upload Count (Java) Source: https://developers.telnyx.com/api-reference/external-connections/get-the-count-of-pending-upload-requests This Java example shows how to use the Telnyx Java SDK to get the count of pending upload requests. It initializes the client from environment variables. ```Java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.externalconnections.uploads.UploadPendingCountParams; import com.telnyx.sdk.models.externalconnections.uploads.UploadPendingCountResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); UploadPendingCountResponse response = client.externalConnections().uploads().pendingCount("1293384261075731499"); } } ``` -------------------------------- ### Get Campaign Cost (Java) Source: https://developers.telnyx.com/api-reference/campaign/get-campaign-cost This Java example demonstrates how to get the cost for a campaign use case using the Telnyx Java client. Ensure the client is initialized with environment variables. ```java package com.telnyx.sdk.example; import com.telnyx.sdk.client.TelnyxClient; import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; import com.telnyx.sdk.models.messaging10dlc.campaign.usecase.UsecaseGetCostParams; import com.telnyx.sdk.models.messaging10dlc.campaign.usecase.UsecaseGetCostResponse; public final class Main { private Main() {} public static void main(String[] args) { TelnyxClient client = TelnyxOkHttpClient.fromEnv(); UsecaseGetCostParams params = UsecaseGetCostParams.builder() .usecase("usecase") .build(); UsecaseGetCostResponse response = client.messaging10dlc().campaign().usecase().getCost(params); } } ``` -------------------------------- ### List Porting Order Action Requirements (Go) Source: https://developers.telnyx.com/api-reference/porting-orders/list-action-requirements-for-a-porting-order This Go example shows how to initialize the Telnyx client and list action requirements for a porting order. It prints the raw response data. ```go package main import ( "context" "fmt" "github.com/team-telnyx/telnyx-go" "github.com/team-telnyx/telnyx-go/option" ) func main() { client := telnyx.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.PortingOrders.ActionRequirements.List( context.TODO(), "porting_order_id", telnyx.PortingOrderActionRequirementListParams{}, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` -------------------------------- ### Get Pending Upload Count (JavaScript) Source: https://developers.telnyx.com/api-reference/external-connections/get-the-count-of-pending-upload-requests Use this snippet to get the count of pending upload requests for an external connection. Ensure you have the Telnyx SDK installed and your API key configured. ```JavaScript import Telnyx from 'telnyx'; const client = new Telnyx({ apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted }); const response = await client.externalConnections.uploads.pendingCount('1293384261075731499'); console.log(response.data); ```