### List Users with Python Source: https://developers.api4com.com/operations/Users.findUsers.html Use the Python requests library to get a list of users. This example sends a GET request with the required Content-Type header and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/users' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### JavaScript Example for Listing Extensions Source: https://developers.api4com.com/operations/Extension.find__get_extensions.html This example shows how to fetch extensions using the JavaScript `fetch` API. It parses the JSON response and logs it to the console. ```javascript fetch('https://api.api4com.com/api/v1/extensions', {headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### cURL Example for Listing Extensions Source: https://developers.api4com.com/operations/Extension.find__get_extensions.html This example demonstrates how to list extensions using cURL. Ensure you include the 'Content-Type' header. ```curl curl -X GET \ 'https://api.api4com.com/api/v1/extensions' \ -H "Content-Type: application/json" ``` -------------------------------- ### PHP Example for Listing Extensions Source: https://developers.api4com.com/operations/Extension.find__get_extensions.html This PHP script uses cURL to make a GET request to the extensions endpoint. It sets the necessary headers and outputs the response. ```php 'application/json', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### Create User Python Example Source: https://developers.api4com.com/operations/Users.createUser.html This Python example uses the requests library to create a user. It specifies the URL and Content-Type header for the POST request. ```python import requests url = 'https://api.api4com.com/api/v1/users' headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### Create User Request Body Example Source: https://developers.api4com.com/operations/Users.createUser.html This is an example of the JSON body required to create a user. Ensure all fields are correctly formatted. ```json { "name": "Api4Com API de Voz", "email": "suporte@api4com.com", "password": "PwDLooL", "phone": "4833328530", "role": "USER" } ``` -------------------------------- ### Get Next Available Extension (Python) Source: https://developers.api4com.com/operations/Extension.getNextAvailable.html This Python example uses the requests library to perform a GET request for the next available extension. It includes the required headers and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/extensions/next-available' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Logged-in User Data (Python) Source: https://developers.api4com.com/operations/Users.findMe.html This Python example uses the requests library to make a GET request to the /users/me endpoint. It includes the necessary headers and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/users/me' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Successful Login Response Example Source: https://developers.api4com.com/operations/Users.loginUser.html This is an example of a successful JSON response after a user logs in. It contains the access token, its time-to-live, and creation date. ```json { "id": "YggyHfrLEHAWmKiUFbXsT93Tkw2xjwHUbwJ6mgw4Vz5YGubReFGw34HmhrhZDUBM", "ttl": 0, "created": "2025-01-01T00:00:00Z" } ``` -------------------------------- ### Create User cURL Example Source: https://developers.api4com.com/operations/Users.createUser.html Use this cURL command to create a user. Remember to include the Content-Type header. ```bash curl -X POST \ 'https://api.api4com.com/api/v1/users' \ -H "Content-Type: application/json" ``` -------------------------------- ### Retrieve Credit Balance with Python Source: https://developers.api4com.com/operations/Credit.balance.html A Python example using the requests library to get the credit balance. It sends a GET request with the necessary Content-Type header and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/credits/balance' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Confirm User with Python Requests Source: https://developers.api4com.com/operations/Users.confirm__get_users_confirm.html This Python example uses the 'requests' library to send a GET request for user confirmation. It includes the required headers and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/users/confirm' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Example Response JSON Source: https://developers.api4com.com/operations/Account.findFinancialAccount.html This is an example of the JSON response structure for financial account data. ```JSON { "status": "ACTIVE", "company": "Api4Com", "name": "Administrador da Conta", "email": "contato@api4com.com", "phone": "4833328530", "mobilePhone": "48999999999", "personType": "FISICA", "cpfCnpj": "71875911000100", "address": "Rua dos Sonhos", "addressNumber": "123", "addressComplement": "Apto 420", "addressProvince": "Bairro dos Sonhos", "addressCity": "Florianópolis", "addressState": "SC", "addressCountry": "BR", "addressZipCode": "88010000", "additionalEmails": "contato+1@api4com.com,contato+2@api4com.com" } ``` -------------------------------- ### Retrieve Credit Balance with cURL Source: https://developers.api4com.com/operations/Credit.balance.html Example of how to fetch the credit balance using a cURL command. This requires specifying the GET method and setting the Content-Type header. ```curl curl -X GET \ 'https://api.api4com.com/api/v1/credits/balance' \ -H "Content-Type: application/json" ``` -------------------------------- ### Create Charge JavaScript Example Source: https://developers.api4com.com/operations/Charge.createCharge.html Example of creating a charge using JavaScript's fetch API. This snippet demonstrates making a POST request and handling the JSON response. ```javascript fetch('https://api.api4com.com/api/v1/charges', {method:'POST',headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### cURL Request to Get Account Data Source: https://developers.api4com.com/operations/Account.findAccount.html Example of how to retrieve account data using cURL. This command sends a GET request to the /accounts endpoint with the necessary headers. ```curl curl -X GET \ 'https://api.api4com.com/api/v1/accounts' \ -H "Content-Type: application/json" ``` -------------------------------- ### Login User Request Body Example Source: https://developers.api4com.com/operations/Users.loginUser.html This is an example of the JSON request body required to log in a user. It includes the user's email and password. ```json { "email": "suporte@api4com.com", "password": "PwDLooL" } ``` -------------------------------- ### Get Extension by ID using Python Source: https://developers.api4com.com/operations/Extension.findByIdAndDomain.html This Python example uses the `requests` library to send a GET request for extension information. It prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/extensions/{id}' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Create Charge cURL Example Source: https://developers.api4com.com/operations/Charge.createCharge.html Example of creating a charge using cURL. Remember to include your authentication token in the request headers. ```curl curl -X POST \ 'https://api.api4com.com/api/v1/charges' \ -H "Content-Type: application/json" ``` -------------------------------- ### Create Charge Python Example Source: https://developers.api4com.com/operations/Charge.createCharge.html Example of creating a charge using Python's requests library. This snippet shows how to send a POST request with JSON headers. ```python import requests url = 'https://api.api4com.com/api/v1/charges' headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### Create Account using Python Source: https://developers.api4com.com/operations/Account.signup.html This Python example uses the requests library to send a POST request for account creation. It includes the required JSON content type header. ```python import requests url = 'https://api.api4com.com/api/v1/accounts/signup' headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### Create User JavaScript Example Source: https://developers.api4com.com/operations/Users.createUser.html This JavaScript snippet demonstrates how to create a user using the Fetch API. It sends a POST request with JSON data. ```javascript fetch('https://api.api4com.com/api/v1/users', {method:'POST',headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Create Charge PHP Example Source: https://developers.api4com.com/operations/Charge.createCharge.html Example of creating a charge using PHP with cURL. This code sets up the URL, method, and headers for the POST request. ```php 'application/json', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### Create User PHP Example Source: https://developers.api4com.com/operations/Users.createUser.html This PHP script shows how to create a user using cURL. It sets the necessary headers and sends the POST request. ```php 'application/json', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### cURL Request to Fetch Financial Data Source: https://developers.api4com.com/operations/Account.findFinancialAccount.html Example of how to make a GET request to the financial accounts endpoint using cURL. ```cURL curl -X GET \ 'https://api.api4com.com/api/v1/accounts/financial' \ -H "Content-Type: application/json" ``` -------------------------------- ### Requesting Paginated Data Source: https://developers.api4com.com/pagination.html This example demonstrates how to make a GET request to retrieve paginated data, specifying the page number and limit. ```APIDOC ## GET /api/v1/calls ### Description Retrieves a list of calls with pagination support. ### Method GET ### Endpoint /api/v1/calls ### Query Parameters - **page** (integer) - Optional - The page number to retrieve. Defaults to 1. - **limit** (integer) - Optional - The maximum number of items per page. Defaults to 100. Maximum value is 1000. ### Request Example ```javascript const axios = require('axios'); const token = ''; const url = 'https://api.api4com.com/api/v1/calls'; const config = { headers: { Authorization: token }, params: { page: 1, filter: { limit: 100 } } }; axios.get(url, config).then(response => { console.log(response.data); }).catch(error => { console.error(error); }); ``` ### Response #### Success Response (200) - **data** (array) - An array of call objects. - **meta** (object) - Pagination metadata. - **totalItemCount** (integer) - The total number of items available. - **totalPageCount** (integer) - The total number of pages available. - **itemsPerPage** (integer) - The number of items per page. - **currentPage** (integer) - The current page number. - **nextPage** (integer) - The number of the next page. Omitted if on the last page. - **previousPage** (integer) - The number of the previous page. #### Response Example ```json { "data": [ { "id": "3b46c0c6-5acc-4dfb-9ceb-14e37f1d3040", "domain": "user.api4com.com", "call_type": "outbound", "started_at": "2025-01-01T00:00:00.000Z", "ended_at": "2025-01-01T00:01:00.000Z", "from": "1000", "to": "4833328530", "duration": 60, "hangup_cause": "NORMAL_CLEARING", "record_url": "https://listener.api4com.com/files/listen/2cde1761-93c3-45da-94b4-910177dc7dc0.mp3", "email": "user@domain.com", "first_name": "User", "last_name": "Name", "BINA": "4833328530", "minute_price": 0.08, "call_price": 0.08, "metadata": {} }, ... ], "meta": { "totalItemCount": 300, "totalPageCount": 3, "itemsPerPage": 100, "currentPage": 2, "nextPage": 3, "previousPage": 1 } } ``` ``` -------------------------------- ### Create Access Token using Python Source: https://developers.api4com.com/operations/Users.createAccessToken.html This Python example uses the 'requests' library to create an access token. It configures the URL and headers for the POST request and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/users/accessTokens' headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### Make a Call Source: https://developers.api4com.com/integration-api4com-webphone.html This section provides instructions and a JavaScript code example for initiating a call using the API. It specifies the necessary payload and headers, including authorization and call details. ```APIDOC ## Realizando uma chamada Para realizar uma chamada, utilize o seguinte código: ### JavaScript ```javascript const axios = require('axios'); const url = 'https://api.api4com.com/api/v1/dialer'; const config = { headers: { 'Authorization': '' } }; const payload = { extension: '1000', phone: '+554833328530', metadata: { gateway: 'integration-test', userId: 123, entityId: 456 } }; axios.post(url, payload, config).then(response => { console.log(response.data); }).catch(error => { console.error(error); }); ``` ### Resposta de sucesso (JSON) ```json { "id": "bdf199fa-f85b-4378-80cd-0ac28c1355e9", "message": "successfull" } ``` **Importante:** * O campo `Authorization` deve ser preenchido com o token de acesso gerado. * O campo `extension` deve ser preenchido com o número do ramal do usuário que irá realizar a chamada, neste caso, o número do seu ramal, que você guardou ao instalar o Webphone. * O campo `phone` deve ser preenchido com o número de telefone que você deseja ligar. * O campo `metadata` deve ser preenchido com os dados que você deseja enviar para o webhook. ``` -------------------------------- ### Python Example for Listing Extensions Source: https://developers.api4com.com/operations/Extension.find__get_extensions.html This Python script utilizes the `requests` library to fetch extensions. It includes the required 'Content-Type' header and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/extensions' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Login User with Python Requests Source: https://developers.api4com.com/operations/Users.loginUser.html This Python example uses the requests library to log in a user. It sends a POST request with the appropriate headers and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/users/login' headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### List Users with JavaScript Source: https://developers.api4com.com/operations/Users.findUsers.html Fetch user data using the JavaScript fetch API. This example logs the JSON response to the console. It requires a Content-Type header. ```javascript fetch('https://api.api4com.com/api/v1/users', {headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Example User Integration Response Source: https://developers.api4com.com/integration-api4com-webphone.html This JSON structure represents a successful response when configuring a user integration with webhook capabilities. ```json { "id": 123, "gateway": "integration-test", "webhook": true, "webhookConstraint": { "metadata": { "gateway": "integration-test" } }, "metadata": { "webhookUrl": "https://seu-webhook.com/callback", "webhookVersion": "v1.4", "webhookTypes": ["channel-hangup"] } } ``` -------------------------------- ### Account Signup Request Body Example Source: https://developers.api4com.com/operations/Account.signup.html This JSON object represents the required body for the account signup request. Ensure all fields are correctly populated. ```json { "email": "suporte@api4com.com", "password": "PwDLooL", "organization_name": "Api4Com - API de Voz", "phone": "4833328530", "domain": "suporte.api4com.com" } ``` -------------------------------- ### Update Financial Account using Python Source: https://developers.api4com.com/operations/Account.updateFinancialAccount.html This Python example uses the requests library to update financial account details. It sends a PUT request with the appropriate headers. ```Python import requests url = 'https://api.api4com.com/api/v1/accounts/financial' headers = { 'Content-Type': 'application/json' } response = requests.put(url, headers=headers) print(response.json()) ``` -------------------------------- ### Configure Webhook Source: https://developers.api4com.com/integration-api4com-webphone.html This section details how to configure a user integration via the API to enable webhook functionality. It includes a JavaScript example for creating the integration with specified webhook settings. ```APIDOC ## Configuração do Webhook Para configurar o Webhook é necessário criar uma Integração de Usuário via API. Segue um exemplo de como criar uma Integração de Usuário: ### JavaScript ```javascript const axios = require('axios'); const url = 'https://api.api4com.com/api/v1/integrations'; const config = { headers: { 'Authorization': '' } }; const payload = { gateway: 'integration-test', webhook: true, webhookConstraint: { metadata: { gateway: 'integration-test' } }, metadata: { webhookUrl: 'https://seu-webhook.com/callback', webhookVersion: 'v1.4', webhookTypes: ['channel-hangup'] } }; axios.patch(url, payload, config).then(response => { console.log(response.data); }).catch(error => { console.error(error); }); ``` ### Resposta de sucesso (JSON) ```json { "id": 123, "gateway": "integration-test", "webhook": true, "webhookConstraint": { "metadata": { "gateway": "integration-test" } }, "metadata": { "webhookUrl": "https://seu-webhook.com/callback", "webhookVersion": "v1.4", "webhookTypes": ["channel-hangup"] } } ``` **Importante:** * O campo `gateway` deve ser preenchido com o nome do seu gateway. * O campo `webhookUrl` deve ser preenchido com a URL do seu webhook. * Somente as chamadas que atenderem as restrições do webhook serão enviadas para o webhook, ou seja, somente aquelas que possuam o mesmo valor no campo `metadata`. ``` -------------------------------- ### Update User with Python Source: https://developers.api4com.com/operations/Users.updateUser.html This Python example uses the requests library to send a PATCH request for updating user details. It includes the required headers and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/users' headers = { 'Content-Type': 'application/json' } response = requests.patch(url, headers=headers) print(response.json()) ``` -------------------------------- ### Update Financial Account using cURL Source: https://developers.api4com.com/operations/Account.updateFinancialAccount.html This example demonstrates how to update financial account details using a cURL command. Ensure the Content-Type header is set to application/json. ```cURL curl -X PUT \ 'https://api.api4com.com/api/v1/accounts/financial' \ -H "Content-Type: application/json" ``` -------------------------------- ### SIP Webphone Login and Integration Example Source: https://developers.api4com.com/sip-architecture.html This HTML and JavaScript code demonstrates how to initialize and configure a SIP Webphone for login. It includes settings for transport, authentication, and user agent, and sets up event listeners for call handling. Ensure you have the 'libwebphone.js' library included. ```html Webphone SIP

Controle do registro SIP do Ramal


Status do registro SIP

Discagem e controle da Chamada

Controle do Áudio da Chamada

Configuração dos Dispositivos de Áudio

``` -------------------------------- ### Update User with JavaScript Source: https://developers.api4com.com/operations/Users.updateUser.html This JavaScript example demonstrates how to update user information using the fetch API. It sends a PATCH request with a JSON content type and processes the JSON response. ```javascript fetch('https://api.api4com.com/api/v1/users', {method:'PATCH',headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Python Requests for Account Data Source: https://developers.api4com.com/operations/Account.findAccount.html Example of retrieving account data using the Python requests library. This code sends a GET request and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/accounts' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Python Request to Create Financial Account Source: https://developers.api4com.com/operations/Account.createFinancialAccount.html This Python example uses the requests library to send a POST request for creating a financial account. It includes the required headers and prints the JSON response. ```Python import requests url = 'https://api.api4com.com/api/v1/accounts/financial' headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### Create Account using cURL Source: https://developers.api4com.com/operations/Account.signup.html Use this cURL command to send a POST request to the account signup endpoint. Ensure the Content-Type header is set to application/json. ```bash curl -X POST \ 'https://api.api4com.com/api/v1/accounts/signup' \ -H "Content-Type: application/json" ``` -------------------------------- ### JavaScript Request to Create Financial Account Source: https://developers.api4com.com/operations/Account.createFinancialAccount.html This JavaScript example demonstrates how to use the fetch API to create a financial account. It sends a POST request with JSON data and logs the response. ```JavaScript fetch('https://api.api4com.com/api/v1/accounts/financial', {method:'POST',headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Get Logged-in User Data (cURL) Source: https://developers.api4com.com/operations/Users.findMe.html Use this cURL command to make a GET request to the /users/me endpoint. Ensure the Content-Type header is set to application/json. ```bash curl -X GET \ 'https://api.api4com.com/api/v1/users/me' \ -H "Content-Type: application/json" ``` -------------------------------- ### Get Next Available Extension Source: https://developers.api4com.com/operations/Extension.getNextAvailable.html Use the GET method on the /extensions/next-available endpoint to find the next available extension number. This endpoint does not require any additional parameters. ```APIDOC ## GET /extensions/next-available ### Description Retrieves the next available extension number for the account. This number can be used to create a new extension. ### Method GET ### Endpoint /extensions/next-available ### Parameters This endpoint does not require any path or query parameters. ### Request Body This endpoint does not accept a request body. ### Response #### Success Response (200) - **ramal** (string) - The next available extension number. ### Response Example ```json { "ramal": "string" } ``` ``` -------------------------------- ### Get Next Available Extension (cURL) Source: https://developers.api4com.com/operations/Extension.getNextAvailable.html Use this cURL command to make a GET request to the /extensions/next-available endpoint. Ensure the Content-Type header is set to application/json. ```bash curl -X GET \ 'https://api.api4com.com/api/v1/extensions/next-available' \ -H "Content-Type: application/json" ``` -------------------------------- ### Get Extension by ID using PHP Source: https://developers.api4com.com/operations/Extension.findByIdAndDomain.html This PHP script uses cURL to perform a GET request for extension details. It sets the necessary headers and outputs the response. ```php 'application/json', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### Create Account using JavaScript Source: https://developers.api4com.com/operations/Account.signup.html This JavaScript snippet demonstrates how to use the fetch API to create a new account. It sends a POST request with a JSON content type. ```javascript fetch('https://api.api4com.com/api/v1/accounts/signup', {method:'POST',headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Get Extension by ID using cURL Source: https://developers.api4com.com/operations/Extension.findByIdAndDomain.html Use this cURL command to make a GET request to retrieve extension details. Ensure you replace `{id}` with the actual extension ID. ```bash curl -X GET \ 'https://api.api4com.com/api/v1/extensions/{id}' \ -H "Content-Type: application/json" ``` -------------------------------- ### Get Logged-in User Data Source: https://developers.api4com.com/operations/Users.findMe.html Use the GET method on the /users/me endpoint to retrieve the data of the logged-in user. The user's access token must be sent in the Authorization header. ```APIDOC ## GET /users/me ### Description Retrieves the data of the currently logged-in user. ### Method GET ### Endpoint /users/me ### Parameters #### Headers - **Authorization** (string) - Required - The access token of the user. ### Response #### Success Response (200) - **uuid** (string) - Unique identifier of the user. - **name** (string) - Name of the user. - **email** (string) - Email of the user. - **phone** (string) - Phone number of the user. - **role** (string) - Role of the user. - **emailVerified** (boolean) - Indicates if the user's email has been verified. - **createdAt** (string) - The date and time the user was created. - **updatedAt** (string) - The date and time the user was last updated. - **lastLoginAt** (string) - The date and time of the user's last login. ### Response Example ```json { "uuid": "616f411f-61e2-4f25-b3f6-75c872771818", "name": "Api4Com API de Voz", "email": "suporte@api4com.com", "phone": "4833328530", "role": "ADMIN", "emailVerified": true, "createdAt": "2021-01-01T00:00:00Z", "updatedAt": "2021-01-01T00:00:00Z", "lastLoginAt": "2021-01-01T00:00:00Z" } ``` ``` -------------------------------- ### Get Next Available Extension (PHP) Source: https://developers.api4com.com/operations/Extension.getNextAvailable.html This PHP script uses cURL to make a GET request to retrieve the next available extension. It sets the necessary headers and prints the response. ```php 'application/json', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### PHP cURL Request for Financial Data Source: https://developers.api4com.com/operations/Account.findFinancialAccount.html Example of retrieving financial account data using cURL in PHP. ```PHP 'application/json', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### List Extensions Source: https://developers.api4com.com/operations/Extension.find__get_extensions.html Use the GET method on the /extensions route to list all extensions for the account. This endpoint supports filtering. ```APIDOC ## GET /extensions ### Description Retrieves a list of extensions for the account. Supports filtering. ### Method GET ### Endpoint /extensions ### Parameters #### Query Parameters - **filter** (string) - Required - JSON-encoded string for filtering, e.g., `{"where":{"something":"value"}}`. See [Loopback Querying](https://loopback.io/doc/en/lb3/Querying-data.html#using-stringified-json-in-rest-queries) for details. ### Response #### Success Response (200) - **id** (integer) - Unique identifier of the extension - **domain** (string) - Account domain - **ramal** (string) - Extension number - **senha** (string) - Extension password - **bina** (string) - Bina number - **first_name** (string) - User's first name - **last_name** (string) - User's last name - **email_address** (string) - User's email address - **gravar_audio** (integer) - Indicates if extension calls should be recorded (0: No, 1: Yes) #### Response Example ```json [ { "id": 123, "domain": "suporte.api4com.com", "ramal": "1001", "senha": "PwDLooL", "bina": "4833328530", "first_name": "Silvio", "last_name": "Fernandes", "email_address": "suporte@api4com.com", "gravar_audio": 0 } ] ``` ``` -------------------------------- ### Exemplo de Integração com Restrição de Webhook Source: https://developers.api4com.com/operations/UserIntegration.overrideUpsert.html Este JSON demonstra a estrutura de uma integração configurada com um webhook e uma restrição específica. A restrição garante que apenas chamadas com metadados correspondentes sejam enviadas para o webhook. ```json { "id": 1, "gateway": "integration-code", "webhook": true, "webhookConstraint": { "gateway": "integration-code" }, "metadata": { "api_token": "123456" } } ``` -------------------------------- ### Python Requests for Financial Data Source: https://developers.api4com.com/operations/Account.findFinancialAccount.html Shows how to get financial account information using the requests library in Python. ```Python import requests url = 'https://api.api4com.com/api/v1/accounts/financial' headers = { 'Content-Type': 'application/json' } response = requests.get(url, headers=headers) print(response.json()) ``` -------------------------------- ### Exemplo de Requisição JavaScript para Atualizar Integração Source: https://developers.api4com.com/operations/UserIntegration.overrideUpsert.html Este código JavaScript utiliza a API Fetch para enviar uma requisição PATCH à rota /integrations. Ele processa a resposta JSON e a exibe no console. ```javascript fetch('https://api.api4com.com/api/v1/integrations', {method:'PATCH',headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Find Account Source: https://developers.api4com.com/operations/Account.findAccount.html Retrieve your account data using the GET /accounts endpoint. This method does not require additional parameters. ```APIDOC ## GET /accounts ### Description To display your account data, use the `GET` method on the `/accounts` route. This method does not require additional parameters. This method returns an object with the account data, including: * `uuid`: Unique account identifier * `domain`: Account domain * `name`: Account name * `email`: Account contact email * `phone`: Account contact phone * `createdAt`: Account creation date * `updatedAt`: Date of the last account update **Important**: * To access the account data, you must include the authentication token in the request header. ### Method GET ### Endpoint /accounts ### Response #### Success Response (200) - **uuid** (string) - Unique account identifier - **domain** (string) - Account domain - **name** (string) - Account name - **email** (string) - Account contact email - **phone** (string) - Account contact phone - **createdAt** (string) - Account creation date - **updatedAt** (string) - Date of the last account update #### Response Example ```json { "uuid": "616f411f-61e2-4f25-b3f6-75c872771818", "domain": "suporte.api4com.com", "name": "Api4Com API de Voz", "email": "suporte@api4com.com", "phone": "4833328530", "createdAt": "2021-01-01T00:00:00Z", "updatedAt": "2021-01-01T00:00:00Z" } ``` ``` -------------------------------- ### Create Access Token using cURL Source: https://developers.api4com.com/operations/Users.createAccessToken.html Use this cURL command to create an access token. Ensure the 'Content-Type' header is set to 'application/json'. ```bash curl -X POST \ 'https://api.api4com.com/api/v1/users/accessTokens' \ -H "Content-Type: application/json" ``` -------------------------------- ### Python Requests Library Request to Create Extension Source: https://developers.api4com.com/operations/Extension.postNextAvailable.html This Python example uses the 'requests' library to make a POST request for creating an extension. It includes the required headers and prints the JSON response. ```python import requests url = 'https://api.api4com.com/api/v1/extensions/next-available' headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### Get Credit Balance Source: https://developers.api4com.com/operations/Credit.balance.html Retrieves the current credit balance of the account. Authentication is required via a token in the request header. ```APIDOC ## GET /credits/balance ### Description To consult the credit balance of your account, use the `GET` method on the `/credit/balance` route. This method does not require additional parameters. ### Method GET ### Endpoint /credits/balance ### Parameters This endpoint does not require any path or query parameters. ### Request Body This endpoint does not accept a request body. ### Response #### Success Response (200) Returns an object with the credit balance data: - **status** (string) - Request status - **message** (string) - Success message - **balance** (string) - Credit balance ### Response Example ```json { "status": "200", "message": "seu saldo é de R$ 9,99", "balance": "9,99" } ``` ``` -------------------------------- ### Get Credit Balance Source: https://developers.api4com.com/operations/Credit.balance.html Use this method to query your current credit balance. Ensure your authentication token is included in the request headers. ```http GET /credits/balance ``` -------------------------------- ### Create Account using PHP Source: https://developers.api4com.com/operations/Account.signup.html This PHP script utilizes cURL to perform a POST request for account signup. It sets the necessary headers and returns the response. ```php 'application/json', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### List All Access Tokens Source: https://developers.api4com.com/operations/Users.findAllAccessToken.html To list all access tokens, use the GET method on the /users/accessTokens route. This method requires the `filter` parameter for searching. ```APIDOC ## GET /users/accessTokens ### Description Retrieves a list of all access tokens associated with the user. ### Method GET ### Endpoint /users/accessTokens ### Parameters #### Query Parameters - **filter** (string) - Optional - Filter criteria for the search. This should be a JSON-encoded string (e.g., `{"where":{"something":"value"}}`). Refer to https://loopback.io/doc/en/lb3/Querying-data.html#using-stringified-json-in-rest-queries for more details. ### Response #### Success Response (200) - **id** (string) - Unique identifier of the access token. - **ttl** (number) - Time-to-live of the access token. - **created** (string) - Creation date of the access token. ### Response Example ```json { "id": "string", "ttl": 0, "created": "string" } ``` ### Request Example ```json { "filter": "Test" } ``` ``` -------------------------------- ### List Users with cURL Source: https://developers.api4com.com/operations/Users.findUsers.html Use this cURL command to make a GET request to the /users endpoint. Ensure the Content-Type header is set to application/json. ```bash curl -X GET \ 'https://api.api4com.com/api/v1/users' \ -H "Content-Type: application/json" ``` -------------------------------- ### Create Access Token using PHP Source: https://developers.api4com.com/operations/Users.createAccessToken.html This PHP script shows how to create an access token using cURL. It sets the necessary URL, method, and headers for the POST request. ```php 'application/json', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### Exemplo de Requisição Python para Criar Ramal Source: https://developers.api4com.com/operations/Extension.create__post_extensions.html Este código Python utiliza a biblioteca requests para enviar uma requisição POST e criar um ramal. Ele define os cabeçalhos necessários e imprime a resposta JSON. ```python import requests url = 'https://api.api4com.com/api/v1/extensions' headers = { 'Content-Type': 'application/json' } response = requests.post(url, headers=headers) print(response.json()) ``` -------------------------------- ### Confirm User Source: https://developers.api4com.com/operations/Users.confirm__get_users_confirm.html Use the GET method on the /users/confirm route to confirm a user. This method requires uid, token, and optionally redirect parameters. ```APIDOC ## GET /users/confirm ### Description Confirms a new user by validating their ID and token. Optionally redirects the user to a specified URL upon successful confirmation. ### Method GET ### Endpoint /users/confirm ### Parameters #### Query Parameters - **uid** (string) - Required - The ID of the user to confirm. - **token** (string) - Required - The confirmation token provided to the user. - **redirect** (string) - Optional - The URL to redirect the user to after confirmation. ### Responses #### Success Response (204) No Content. Indicates the user was successfully confirmed. ### Example #### cURL ``` curl -X GET \ 'https://api.api4com.com/api/v1/users/confirm?uid=user123&token=abcdef123456' \ -H "Content-Type: application/json" ``` ``` -------------------------------- ### Exemplo de Requisição Python para Atualizar Integração Source: https://developers.api4com.com/operations/UserIntegration.overrideUpsert.html Este código Python utiliza a biblioteca requests para enviar uma requisição PATCH à API de integrações. Ele define os cabeçalhos necessários e imprime a resposta JSON. ```python import requests url = 'https://api.api4com.com/api/v1/integrations' headers = { 'Content-Type': 'application/json' } response = requests.patch(url, headers=headers) print(response.json()) ``` -------------------------------- ### Confirm User with cURL Source: https://developers.api4com.com/operations/Users.confirm__get_users_confirm.html Use this cURL command to send a GET request to confirm a user. Ensure the 'Content-Type' header is set to 'application/json'. ```curl curl -X GET \ 'https://api.api4com.com/api/v1/users/confirm' \ -H "Content-Type: application/json" ``` -------------------------------- ### Exemplo de Requisição JavaScript (Fetch API) para Criar Ramal Source: https://developers.api4com.com/operations/Extension.create__post_extensions.html Este exemplo demonstra como criar um ramal usando a Fetch API em JavaScript. Ele envia uma requisição POST com o cabeçalho Content-Type apropriado e processa a resposta JSON. ```javascript fetch('https://api.api4com.com/api/v1/extensions', {method:'POST',headers:{'Content-Type':'application/json'}}) .then(response => response.json()) .then(data => console.log(data)); ```