### Setting up and Running the Example App Source: https://docs.jambonz.org/sdks/webrtc-web These commands guide you through cloning the repository, installing dependencies, building the SDK, and running the full web example application locally. ```bash # 1. Clone the repo git clone https://github.com/jambonz/webrtc-sdk.git cd webrtc-sdk # 2. Install and build the SDK npm install npm run build # 3. Install and run the web example cd examples/web npm install npm run dev ``` -------------------------------- ### Install Dependencies and Start Application Source: https://docs.jambonz.org/tutorials/voice-ai-examples/google-gemini-live Install project dependencies using npm and start the Jambonz application. The GOOGLE_API_KEY environment variable must be set. ```bash npm install GOOGLE_API_KEY= npm start ``` -------------------------------- ### Install React Native Example App Source: https://docs.jambonz.org/sdks/webrtc-react-native Install the Node.js dependencies for the React Native example application after cloning the SDK repository. ```bash cd examples/react-native npm install ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.jambonz.org/reference/rest-platform-management/recent-calls/get-recent-call-trace This Go example shows how to construct and execute an HTTP GET request to fetch call trace information. It includes reading the response body and printing it. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/Accounts/3fa85f64-5717-4562-b3fc-2c963f66afa6/RecentCalls/trace/call_01F8MECHZX3TBDSZ7XRADM79XE" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Tenant Information (PHP) Source: https://docs.jambonz.org/reference/rest-platform-management/settings/get-tenant Example using GuzzleHttp in PHP to make a GET request for tenant information. This requires the GuzzleHttp library to be installed via Composer. ```php request('GET', 'https://api.jambonz.cloud/v1/MicrosoftTeamsTenants/TenantSid', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### Python SDK Example Source: https://docs.jambonz.org/reference/webhooks/call-hook-get Use this Python snippet to make a GET request to the call hook endpoint. Ensure you have the 'requests' library installed. Replace placeholders with your server details and credentials. ```python import requests url = "https://{yourserver}/webhooks/call" querystring = {"call_sid":"CA1234567890abcdef1234567890abcdef","application_sid":"APabcdef1234567890abcdef1234567890","account_sid":"ACabcdef1234567890abcdef1234567890","direction":"inbound","from":"+14155551234","to":"+14155556789","caller_name":"John Doe","call_status":"ringing","sip_status":"100"} payload = {} headers = { "Content-Type": "application/json" } response = requests.get(url, json=payload, headers=headers, params=querystring, auth=("", "")) print(response.json()) ``` -------------------------------- ### Get Service Provider Accounts with Swift Source: https://docs.jambonz.org/reference/rest-platform-management/service-providers/get-service-provider-accounts An example using Swift's `URLSession` to perform a GET request. It demonstrates setting up the request with headers and handling the response. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.jambonz.cloud/v1/ServiceProviders/ServiceProviderSid/Accounts")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Go SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-speech-credential-by-account Use the net/http package to make a GET request to retrieve speech credentials. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/Accounts/AccountSid/SpeechCredentials/SpeechCredentialSid" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Tenant Information (Ruby) Source: https://docs.jambonz.org/reference/rest-platform-management/settings/get-tenant A Ruby example using Net::HTTP to make a GET request for tenant information. It demonstrates setting the Authorization and Content-Type headers. ```ruby require 'uri' require 'net/http' url = URI("https://api.jambonz.cloud/v1/MicrosoftTeamsTenants/TenantSid") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Ruby SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-speech-credential-by-account Use the net/http library to make a GET request to retrieve speech credentials. ```ruby require 'uri' require 'net/http' url = URI("https://api.jambonz.cloud/v1/Accounts/AccountSid/SpeechCredentials/SpeechCredentialSid") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Java SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-speech-credential-by-account Use the Unirest library to make a GET request to retrieve speech credentials. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.jambonz.cloud/v1/Accounts/AccountSid/SpeechCredentials/SpeechCredentialSid") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` -------------------------------- ### Python SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-speech-credential-by-account Use the requests library to make a GET request to retrieve speech credentials. ```python import requests url = "https://api.jambonz.cloud/v1/Accounts/AccountSid/SpeechCredentials/SpeechCredentialSid" payload = {} headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.get(url, json=payload, headers=headers) print(response.json()) ``` -------------------------------- ### Swift SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-speech-credential-by-account Use URLSession to make a GET request to retrieve speech credentials. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.jambonz.cloud/v1/Accounts/AccountSid/SpeechCredentials/SpeechCredentialSid")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get Tenant Information (Swift) Source: https://docs.jambonz.org/reference/rest-platform-management/settings/get-tenant An example in Swift using URLSession to perform a GET request for tenant information. This code sets up the request headers and body, then initiates the data task. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.jambonz.cloud/v1/MicrosoftTeamsTenants/TenantSid")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### JavaScript SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-speech-credential-by-account Use the fetch API to make a GET request to retrieve speech credentials. ```javascript const url = 'https://api.jambonz.cloud/v1/Accounts/AccountSid/SpeechCredentials/SpeechCredentialSid'; const options = { method: 'GET', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### C# SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-speech-credential-by-account Use the RestSharp library to make a GET request to retrieve speech credentials. ```csharp using RestSharp; var client = new RestClient("https://api.jambonz.cloud/v1/Accounts/AccountSid/SpeechCredentials/SpeechCredentialSid"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` -------------------------------- ### PHP SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-speech-credential-by-account Use the Guzzle HTTP client to make a GET request to retrieve speech credentials. ```php request('GET', 'https://api.jambonz.cloud/v1/Accounts/AccountSid/SpeechCredentials/SpeechCredentialSid', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` -------------------------------- ### Get Call Count (PHP) Source: https://docs.jambonz.org/reference/rest-call-control/calls/get-call-count Example using GuzzleHttp in PHP to get the call count. Ensure you have Guzzle installed and your authorization token is valid. ```php request('GET', 'https://api.jambonz.cloud/v1/Accounts/AccountSid/CallCount', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Clone and Build WebRTC SDK Source: https://docs.jambonz.org/sdks/webrtc-react-native Clone the repository, install dependencies, and build the WebRTC SDK. This is a prerequisite for running the example application. ```bash git clone https://github.com/jambonz/webrtc-sdk.git cd webrtc-sdk npm install npm run build ``` -------------------------------- ### Get Service Provider LCRs (PHP) Source: https://docs.jambonz.org/reference/rest-platform-management/call-routing/get-service-provider-lcrs A PHP example using GuzzleHttp to send a GET request to the LCR endpoint. This requires the GuzzleHttp client to be installed via Composer. ```php request('GET', 'https://api.jambonz.cloud/v1/ServiceProviders/ServiceProviderSid/Lcrs', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Get API Keys using PHP GuzzleHttp Source: https://docs.jambonz.org/reference/rest-platform-management/accounts/get-account-api-keys A PHP example using the GuzzleHttp client to retrieve API keys. Make sure to install Guzzle via Composer (`composer require guzzlehttp/guzzle`). ```php request('GET', 'https://api.jambonz.cloud/v1/ApiKeys', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Create React Native Project Source: https://docs.jambonz.org/sdks/webrtc-react-native Use the React Native CLI to initialize a new project. Navigate into the project directory. ```bash npx @react-native-community/cli init MyJambonzApp cd MyJambonzApp ``` -------------------------------- ### Ruby Net::HTTP Example Source: https://docs.jambonz.org/reference/webhooks/call-hook-get This Ruby snippet utilizes the `Net::HTTP` library to perform a GET request for call hook data. It demonstrates setting up the URI, authentication, and headers. Ensure you have Ruby installed. ```ruby require 'uri' require 'net/http' url = URI("https://{yourserver}/webhooks/call?call_sid=CA1234567890abcdef1234567890abcdef&application_sid=APabcdef1234567890abcdef1234567890&account_sid=ACabcdef1234567890abcdef1234567890&direction=inbound&from=%2B14155551234&to=%2B14155556789&caller_name=John+Doe&call_status=ringing&sip_status=100") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request.basic_auth("", "") request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Create Call Request Example Source: https://docs.jambonz.org/reference/rest-call-control/calls/create-call This example demonstrates how to make a POST request to create a new call. It includes essential parameters like 'to', 'from', and 'application_sid'. ```bash curl -X POST https://api.jambonz.cloud/v1/Accounts/{AccountSid}/Calls \ -H "Content-Type: application/json" \ -d '{ "to": "+15551234567", "from": "+15557654321", "application_sid": "your-application-sid" }' ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.jambonz.org/reference/rest-platform-management/recent-calls/get-recent-call-trace-by-account Demonstrates fetching the call trace using Go's standard net/http package. Ensure proper error handling for production code. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/Accounts/3fa85f64-5717-4562-b3fc-2c963f66afa6/RecentCalls/call_1234567890abcdef/pcap" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### PHP Guzzle Example Source: https://docs.jambonz.org/reference/webhooks/call-hook-get This PHP snippet uses the Guzzle HTTP client to send a GET request to the call hook endpoint. It demonstrates setting up the client, authentication, headers, and body. Ensure you have Guzzle installed via Composer. ```php request('GET', 'https://{yourserver}/webhooks/call?call_sid=CA1234567890abcdef1234567890abcdef&application_sid=APabcdef1234567890abcdef1234567890&account_sid=ACabcdef1234567890abcdef1234567890&direction=inbound&from=%2B14155551234&to=%2B14155556789&caller_name=John+Doe&call_status=ringing&sip_status=100', [ 'body' => '{}', 'headers' => [ 'Content-Type' => 'application/json', ], 'auth' => ['', ''], ]); echo $response->getBody(); ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.jambonz.org/reference/webhooks/call-hook-get This Go program shows how to make a GET request to the call hook endpoint using the standard `net/http` package. It includes setting basic authentication and content type. Remember to handle potential errors. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://{yourserver}/webhooks/call?call_sid=CA1234567890abcdef1234567890abcdef&application_sid=APabcdef1234567890abcdef1234567890&account_sid=ACabcdef1234567890abcdef1234567890&direction=inbound&from=%2B14155551234&to=%2B14155556789&caller_name=John+Doe&call_status=ringing&sip_status=100" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.SetBasicAuth("", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Clients (PHP) Source: https://docs.jambonz.org/reference/rest-platform-management/clients/get-clients This PHP example utilizes the Guzzle HTTP client to fetch client data. It shows how to configure the request with headers and body. Make sure to install Guzzle via Composer and replace '' with your API token. ```php request('GET', 'https://api.jambonz.cloud/v1/Clients', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.jambonz.org/reference/rest-platform-management/settings/delete-tenant Shows how to delete an MS Teams tenant using Go's standard net/http package. This example constructs the request, sets headers, and prints the response. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/MicrosoftTeamsTenants/TenantSid" req, _ := http.NewRequest("DELETE", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.jambonz.org/reference/rest-platform-management/recent-calls/get-recent-call-trace-by-call-id Demonstrates how to fetch call trace data using Go's standard net/http package. Remember to replace with your actual API token. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/ServiceProviders/3fa85f64-5717-4562-b3fc-2c963f66afa6/RecentCalls/trace/call_20240612_153045_abc123xyz" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get SIP Gateway using PHP Guzzle Source: https://docs.jambonz.org/reference/rest-platform-management/carriers/get-sip-gateway This PHP example demonstrates fetching SIP gateway information using the Guzzle HTTP client. Ensure Guzzle is installed via Composer and replace '' with your API bearer token. ```php request('GET', 'https://api.jambonz.cloud/v1/SipGateways/SipGatewaySid', [ 'body' => '{}', 'headers' => [ 'Authorization' => 'Bearer ', 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Get API Keys using Python Requests Source: https://docs.jambonz.org/reference/rest-platform-management/accounts/get-account-api-keys Use the Python Requests library to make a GET request to the API keys endpoint. Ensure you have the library installed (`pip install requests`). ```python import requests url = "https://api.jambonz.cloud/v1/ApiKeys" payload = {} headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.get(url, json=payload, headers=headers) print(response.json()) ``` -------------------------------- ### PHP SDK Example for Get Least Cost Routing Route Source: https://docs.jambonz.org/reference/rest-platform-management/call-routing/get-least-cost-routing-route This PHP example uses the Guzzle HTTP client to get a least cost routing route. Replace "" with your actual API bearer token. ```php request('GET', 'https://api.jambonz.cloud/v1/LcrRoutes/LcrRouteSid', [ 'headers' => [ 'Authorization' => 'Bearer ', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Run a Jambonz WebSocket Application Source: https://docs.jambonz.org/guides/get-started/developer-quickstart Navigate to your application's directory and start the Node.js server using `npm start`. This command initiates the websocket server, typically listening on port 3000. ```bash $ cd my-echo-app/ $ npm start > my-echo-app@0.0.1 start > node app { "level":30, "time":1739116350704, "pid":31336, "msg":"jambonz websocket server listening at http://localhost:3000" } ``` -------------------------------- ### Java Unirest Example Source: https://docs.jambonz.org/reference/rest-platform-management/recent-calls/get-recent-call-trace-by-account This Java example uses the Unirest library to make the GET request. Ensure Unirest is included in your project dependencies. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.jambonz.cloud/v1/Accounts/3fa85f64-5717-4562-b3fc-2c963f66afa6/RecentCalls/call_1234567890abcdef/pcap") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` -------------------------------- ### Create Application using Go HTTP Client Source: https://docs.jambonz.org/reference/rest-platform-management/applications/create-application Example of creating an application using Go's standard HTTP client. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/Applications" payload := strings.NewReader("{ \n \"name\": \"string\",\n \"account_sid\": \"string\",\n \"call_hook\": {\n \"url\": \"https://acme.com\",\n \"method\": \"get\"\n },\n \"call_status_hook\": {\n \"url\": \"https://acme.com\",\n \"method\": \"get\"\n }\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Service Provider LCRs (Java) Source: https://docs.jambonz.org/reference/rest-platform-management/call-routing/get-service-provider-lcrs This Java example uses the Unirest library to make a GET request. Ensure Unirest is included as a dependency in your project. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.jambonz.cloud/v1/ServiceProviders/ServiceProviderSid/Lcrs") .header("Authorization", "Bearer ") .asString(); ``` -------------------------------- ### Node.JS Websocket SDK Example Source: https://docs.jambonz.org/nodeclientws Example demonstrating how to set up an HTTP server, create a WebSocket endpoint, define a service for a specific path, and handle new incoming calls. It includes session event handling and the use of jambonz verbs. ```javascript /* create an http/s server in your application however you like */ const {createServer} = require('http'); const server = createServer(); server.listen(3000); /* require the library and call the returned function with your server */ const {createEndpoint} = require('@jambonz/node-client-ws'); const makeService = createEndpoint({server}); /* create a jambonz application listeng for requests with URL path '/hello-world' */ const svc = makeService({path: '/hello-world'}); /* listen for new calls to that service */ svc.on('session:new', (session) => { /* the 'session' object has all of the properties of the incoming call */ console.log({session}, `new incoming call: ${session.call_sid}`); /* set up some event handlers for this session */ session .on('close', onClose.bind(null, session)) .on('error', onError.bind(null, session)); /* all of the jambonz verbs are available as methods on the session object https://www.jambonz.org/docs/webhooks/overview/ */ session .pause({length: 1.5}) .say({text}) .pause({length: 0.5}) .hangup() .send(); // sends the queued verbs to jambonz }); const onClose = (session, code, reason) => { console.log({session, code, reason}, `session ${session.call_sid} closed`); }; const onError = (session, err) => { console.log({err}, `session ${session.call_sid} received error`); }; ``` -------------------------------- ### Get Google Custom Voice (JavaScript) Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-google-custom-voice Utilize the fetch API in JavaScript to get Google Custom Voice information. This example includes basic error handling. ```javascript const url = 'https://api.jambonz.cloud/v1/GoogleCustomVoices/GoogleCustomVoiceSid'; const options = {method: 'GET', headers: {Authorization: 'Bearer '}}; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Create Account using Ruby Net::HTTP Source: https://docs.jambonz.org/reference/rest-platform-management/accounts/create-account This Ruby example demonstrates creating an account using the Net::HTTP library. It shows how to set the request method, headers, and body. ```ruby require 'uri' require 'net/http' url = URI("https://api.jambonz.cloud/v1/Accounts") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{\n \"name\": \"foobar\",\n \"service_provider_sid\": \"85f9c036-ba61-4f28-b2f5-617c23fa68ff\"\n}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Install @jambonz/tools Source: https://docs.jambonz.org/guides/features/voice-agents Install the necessary package for using pre-built tools. ```bash npm install @jambonz/tools ``` -------------------------------- ### Create Account using Swift URLSession Source: https://docs.jambonz.org/reference/rest-platform-management/accounts/create-account This Swift example demonstrates creating an account using URLSession. It covers setting up the request with headers, HTTP method, and JSON body. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [ "name": "foobar", "service_provider_sid": "85f9c036-ba61-4f28-b2f5-617c23fa68ff" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.jambonz.cloud/v1/Accounts")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get Tenant Information (JavaScript) Source: https://docs.jambonz.org/reference/rest-platform-management/settings/get-tenant Utilize the fetch API in JavaScript to get tenant information. This example demonstrates setting request headers and handling the JSON response. ```javascript const url = 'https://api.jambonz.cloud/v1/MicrosoftTeamsTenants/TenantSid'; const options = { method: 'GET', headers: {Authorization: 'Bearer ', 'Content-Type': 'application/json'}, body: '{}' }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### List Microsoft Teams Tenants (Go) Source: https://docs.jambonz.org/reference/rest-platform-management/settings/list-ms-teams-tenants This Go example demonstrates making an HTTP GET request to list Microsoft Teams tenants. It includes setting the necessary headers and reading the response body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/MicrosoftTeamsTenants" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Service Provider Accounts with Ruby Source: https://docs.jambonz.org/reference/rest-platform-management/service-providers/get-service-provider-accounts A Ruby example using the `net/http` library to perform a GET request. It sets the necessary headers, including the Authorization token. ```ruby require 'uri' require 'net/http' url = URI("https://api.jambonz.cloud/v1/ServiceProviders/ServiceProviderSid/Accounts") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### Get Account Carriers with Swift Source: https://docs.jambonz.org/reference/rest-platform-management/carriers/get-account-carriers An example using Swift's URLSession to perform a GET request. It covers setting up headers, the request body, and handling the response. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.jambonz.cloud/v1/Accounts/AccountSid/VoipCarriers")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Get Clients (Swift) Source: https://docs.jambonz.org/reference/rest-platform-management/clients/get-clients This Swift example demonstrates fetching client data using URLSession. It shows how to set up the request with headers and body. Replace '' with your API token. ```swift import Foundation let headers = [ "Authorization": "Bearer ", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.jambonz.cloud/v1/Clients")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Create Service Provider using Go HTTP Client Source: https://docs.jambonz.org/reference/rest-platform-management/service-providers/create-service-provider Create a service provider using Go's standard net/http package. This example demonstrates making a POST request with a JSON body. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/ServiceProviders" payload := strings.NewReader("{\n \"name\": \"fastcomms\"\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Account Carriers with Ruby Source: https://docs.jambonz.org/reference/rest-platform-management/carriers/get-account-carriers A Ruby example using Net::HTTP to make a GET request. It demonstrates setting the Authorization header and retrieving the response body. ```ruby require 'uri' require 'net/http' url = URI("https://api.jambonz.cloud/v1/Accounts/AccountSid/VoipCarriers") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["Authorization"] = 'Bearer ' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` -------------------------------- ### C# RestSharp Example Source: https://docs.jambonz.org/reference/rest-platform-management/recent-calls/get-recent-call-trace This C# example demonstrates using the RestSharp library to make a GET request for call trace details. It configures the client, request, and headers. ```csharp using RestSharp; var client = new RestClient("https://api.jambonz.cloud/v1/Accounts/3fa85f64-5717-4562-b3fc-2c963f66afa6/RecentCalls/trace/call_01F8MECHZX3TBDSZ7XRADM79XE"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Create User with Go HTTP Client Source: https://docs.jambonz.org/reference/rest-platform-management/users/create-user Create a new user using Go's built-in net/http package. This example shows how to construct the POST request with JSON payload and headers. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/Users" payload := strings.NewReader("{ \n \"name\": \"jdoe\",\n \"email\": \"jdoe@example.com\",\n \"is_active\": true,\n \"force_change\": true,\n \"initial_password\": \"Str0ngP@ssw0rd!\",\n \"is_view_only\": false\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Service Provider Carriers (C#) Source: https://docs.jambonz.org/reference/rest-platform-management/carriers/get-service-provider-carriers This C# example utilizes the RestSharp library to perform a GET request for service provider carriers. It demonstrates adding headers and parameters. ```csharp using RestSharp; var client = new RestClient("https://api.jambonz.cloud/v1/ServiceProviders/ServiceProviderSid/VoipCarriers"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Python SDK Example Source: https://docs.jambonz.org/reference/rest-platform-management/recent-calls/get-recent-call-trace-by-sp Use the Python requests library to fetch a call trace. Ensure you have the 'requests' library installed. Replace '' with your actual API token. ```python import requests url = "https://api.jambonz.cloud/v1/ServiceProviders/3fa85f64-5717-4562-b3fc-2c963f66afa6/RecentCalls/call-1234567890abcdef/pcap" payload = {} headers = { "Authorization": "Bearer ", "Content-Type": "application/json" } response = requests.get(url, json=payload, headers=headers) print(response.json()) ``` -------------------------------- ### Get Service Provider Carriers (Java) Source: https://docs.jambonz.org/reference/rest-platform-management/carriers/get-service-provider-carriers This Java example uses the Unirest library to make a GET request to the API. It shows how to set the authorization header and content type. ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.get("https://api.jambonz.cloud/v1/ServiceProviders/ServiceProviderSid/VoipCarriers") .header("Authorization", "Bearer ") .header("Content-Type", "application/json") .body("{}") .asString(); ``` -------------------------------- ### Install Jambonz-mini with inline domain configuration Source: https://docs.jambonz.org/self-hosting/bare-metal-vps/debian-package Installs the Jambonz-mini package while setting the portal domain directly in the installation command using an environment variable. ```bash sudo -E JAMBONES_PORTAL_DOMAIN=portal.example.com \ DEBIAN_FRONTEND=noninteractive apt-get install -y jambonz-mini ``` -------------------------------- ### Get Supported Languages and Voices (C#) Source: https://docs.jambonz.org/reference/rest-platform-management/speech/supported-languages-and-voices A C# example using RestSharp to make a GET request for supported speech languages and voices. This snippet requires the RestSharp NuGet package. ```csharp using RestSharp; var client = new RestClient("https://api.jambonz.cloud/v1/ServiceProviders/ServiceProviderSid/SpeechCredentials/speech/supportedLanguagesAndVoices?vendor=vendor"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Install Node.js SDK Source: https://docs.jambonz.org/sdks/node-sdk Install the @jambonz/sdk package using npm. ```bash npm install @jambonz/sdk ``` -------------------------------- ### Get Google Custom Voice (Go) Source: https://docs.jambonz.org/reference/rest-platform-management/speech/get-google-custom-voice Implement a GET request in Go to fetch Google Custom Voice data. This example shows how to handle the HTTP response and read the body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/GoogleCustomVoices/GoogleCustomVoiceSid" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Go HTTP Client Example Source: https://docs.jambonz.org/reference/rest-platform-management/recent-calls/get-recent-call-trace-by-sp This Go code snippet demonstrates how to make an HTTP GET request to fetch call trace data. It includes setting necessary headers and reading the response body. Ensure you replace '' with your valid API token. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.jambonz.cloud/v1/ServiceProviders/3fa85f64-5717-4562-b3fc-2c963f66afa6/RecentCalls/call-1234567890abcdef/pcap" payload := strings.NewReader("{}") req, _ := http.NewRequest("GET", url, payload) req.Header.Add("Authorization", "Bearer ") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Tenant Information (C#) Source: https://docs.jambonz.org/reference/rest-platform-management/settings/get-tenant This C# example uses the RestSharp library to execute a GET request for tenant details. Make sure to add the RestSharp NuGet package to your project. ```csharp using RestSharp; var client = new RestClient("https://api.jambonz.cloud/v1/MicrosoftTeamsTenants/TenantSid"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", "Bearer "); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ```