### Install Asterisk Widget Request Example Source: https://developers.kommo.com/reference/installing-the-widget-into-the-account This JSON object demonstrates the required fields for installing the 'asterisk' widget, including login, password, phone mappings, and script path. ```json { "login": "example", "password": "eXaMp1E", "phones": { 504141: "1039" }, "script_path": "https://example.com/" } ``` -------------------------------- ### Install Widget into Account (JSON) Source: https://developers.kommo.com/reference/installing-the-widget-into-the-account Use this example to install a widget into your account. It includes the necessary request body structure with widget settings. Ensure the `widget_code` in the URL and the `RAW_BODY` content are correctly specified. ```json { "id": 123XXX, "code": "asterisk", "version": "1.1.6", "rating": "0", "settings_template": [ { "key": "login", "name": "Login", "type": "text", "is_required": true }, { "key": "password", "name": "Password", "type": "pass", "is_required": true }, { "key": "phones", "name": "Phone numbers", "type": "users", "is_required": true }, { "key": "script_path", "name": "Script path", "type": "text", "is_required": true } ], "is_lead_source": false, "is_work_with_dp": false, "is_crm_template": false, "client_uuid": null, "is_active_in_account": true, "pipeline_id": null, "settings": { "login": "example", "password": "eXaMp1E", "phones": { "504141": "1039" }, "script_path": "https://example.com/" }, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/widgets/asterisk" } } } ``` -------------------------------- ### Widget Installation and Support Configuration Source: https://developers.kommo.com/docs/widgets-tutorial Configure whether the widget requires installation and provide support contact information. Set 'installation' to true if setup is managed within Kommo, or false if managed externally via API. ```json "installation": true, "support": { "link": "https://kommo.com", "email": "support@kommo.com" } }, ``` -------------------------------- ### Get List Element Example Source: https://developers.kommo.com/reference/get-list-element This example demonstrates a successful response when retrieving a list element. It includes all standard fields and custom field values. ```json { "id": 123XXX, "name": "Element", "created_by": 222XYZ, "updated_by": 222XXX, "created_at": 1589390333, "updated_at": 1590683336, "is_deleted": null, "custom_fields_values": [ { "field_id": 123456, "field_name": "SKU", "field_code": "SKU", "field_type": "text", "values": [ { "value": "Passed value" } ] }, { "field_id": 1234567, "field_name": "Description", "field_code": "DESCRIPTION", "field_type": "textarea", "values": [ { "value": "Description" } ] }, { "field_id": 2345678, "field_name": "Price", "field_code": "PRICE", "field_type": "numeric", "values": [ { "value": "12" } ] }, { "field_id": 3456789, "field_name": "Group", "field_code": "GROUP", "field_type": "category", "values": [ { "value": "Devices", "enum_id": 5555 } ] } ], "catalog_id": 12345, "account_id": XXXXXX, "_links": { "self": { "href": "https://example.kommo.com/api/v4/catalogs/12345/elements/987654" } } } ``` -------------------------------- ### API Recipe: Get Leads with Pagination Source: https://developers.kommo.com/changelog?page=2 Example recipe for retrieving leads with pagination. ```javascript const leads = new Kommo.Leads(); leads.list({ "limit": 50, "page": 1 }); ``` -------------------------------- ### Install Widget Source: https://developers.kommo.com/reference/installing-the-widget-into-the-account This method allows installing the widget into the account. ```APIDOC ## POST /api/v4/widgets/{widget_code} ### Description This method allows installing the widget into the account. ### Method POST ### Endpoint /api/v4/widgets/{widget_code} ### Parameters #### Path Parameters - **widget_code** (string) - Required - Widget code #### Header Parameters - **Content-Type** (string) - Optional - Request header. Default: application/json #### Request Body - **RAW_BODY** (string) - Required - JSON string representing the widget settings. ### Request Example ```json { "RAW_BODY": "{\"login\": \"example\", \"password\": \"eXaMp1E\", \"phones\": { \"504141\": \"1039\" }, \"script_path\": \"https://example.com/\"}" } ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the installed widget. - **code** (string) - The code of the widget. - **version** (string) - The version of the widget. - **rating** (string) - The rating of the widget. - **settings_template** (array) - An array of objects defining the widget's settings structure. - **is_lead_source** (boolean) - Indicates if the widget is a lead source. - **is_work_with_dp** (boolean) - Indicates if the widget works with DP. - **is_crm_template** (boolean) - Indicates if the widget is a CRM template. - **client_uuid** (string|null) - The client UUID if applicable. - **is_active_in_account** (boolean) - Indicates if the widget is active in the account. - **pipeline_id** (string|null) - The pipeline ID if applicable. - **settings** (object) - An object containing the widget's current settings. - **_links** (object) - An object containing links related to the widget. #### Response Example ```json { "id": 123XXX, "code": "asterisk", "version": "1.1.6", "rating": "0", "settings_template": [ { "key": "login", "name": "Login", "type": "text", "is_required": true }, { "key": "password", "name": "Password", "type": "pass", "is_required": true }, { "key": "phones", "name": "Phone numbers", "type": "users", "is_required": true }, { "key": "script_path", "name": "Script path", "type": "text", "is_required": true } ], "is_lead_source": false, "is_work_with_dp": false, "is_crm_template": false, "client_uuid": null, "is_active_in_account": true, "pipeline_id": null, "settings": { "login": "example", "password": "eXaMp1E", "phones": { "504141": "1039" }, "script_path": "https://example.com/" }, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/widgets/asterisk" } } } ``` #### Error Responses - **400** - Bad Request: Invalid data given. Details are available in the response. - **401** - Unauthorized: User is not authorized. - **404** - Not Found: Widget was not found. ``` -------------------------------- ### Get Companies List Example Source: https://developers.kommo.com/reference/companies-list This example demonstrates a successful request to retrieve a list of companies. It shows the structure of the response, including pagination links, embedded company data, and individual company details. ```json { "_page": 1, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/companies" } }, "_embedded": { "companies": [ { "id": XXXXXX, "name": "United", "responsible_user_id": XXXXXX, "group_id": 0, "created_by": XXXXX, "updated_by": XXXXXX, "created_at": 1686670709, "updated_at": 1686670709, "closest_task_at": null, "is_deleted": false, "custom_fields_values": null, "account_id": XXXX123, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/companies/406320" } }, "_embedded": { "tags": [] } }, { "id": 510XXX, "name": "Kommo", "responsible_user_id": 837XYZ, "group_id": 0, "created_by": 0, "updated_by": 0, "created_at": 1686754687, "updated_at": 1686754687, "closest_task_at": null, "is_deleted": false, "custom_fields_values": null, "account_id": XYZ11263, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/companies/510864" } }, "_embedded": { "tags": [] } }, { "id": 597XXX, "name": "Atme Co.", "responsible_user_id": 0, "group_id": -1, "created_by": 0, "updated_by": 0, "created_at": 1686836351, "updated_at": 1686836351, "closest_task_at": null, "is_deleted": false, "custom_fields_values": null, "account_id": 3136XXXX, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/companies/597516" } }, "_embedded": { "tags": [] } } ] } } ``` -------------------------------- ### self.get_install_status() Source: https://developers.kommo.com/docs/script-js Returns the installation status of the widget as a string. Possible statuses are 'install', 'installed', and 'not_configured'. ```APIDOC ## self.get_install_status() ### Description Retrieves the current installation status of the widget. ### Returns * (string) - The installation status. Possible values are 'install', 'installed', or 'not_configured'. ``` -------------------------------- ### Get Widget Installation Status Source: https://developers.kommo.com/docs/script-js Returns the installation status of the widget as a string. Possible values are 'install' (inactive), 'installed' (active), and 'not_configured' (tour completed, settings not filled). ```javascript self.get_install_status() ``` -------------------------------- ### API Recipe: Get and Refresh Access Token Source: https://developers.kommo.com/changelog?page=2 Example recipe for OAuth2 flows to get and refresh access tokens. ```javascript const oauth = new Kommo.OAuth2({ "client_id": "YOUR_CLIENT_ID", "client_secret": "YOUR_CLIENT_SECRET", "redirect_uri": "YOUR_REDIRECT_URI" }); // Get access token oauth.getAccessToken("AUTHORIZATION_CODE"); // Refresh access token oauth.refreshAccessToken("REFRESH_TOKEN"); ``` -------------------------------- ### onInstall Source: https://developers.kommo.com/docs/script-js An optional callback function that is executed once when the widget is installed. It is suitable for initialization logic, such as creating initial data or performing environment checks. Errors in `onInstall` do not halt the installation process. ```APIDOC ## onInstall ### Description An optional callback that is called once when the widget is installed. Used for initialization logic like creating initial data or checking the environment. An error in `onInstall` does not interrupt the installation process. ### Method Signature ```javascript onInstall: function() { // Your initialization code here } ``` ``` -------------------------------- ### Get Tasks API Response Example Source: https://developers.kommo.com/reference/edit-tasks This example demonstrates the structure of a successful response when retrieving tasks. It includes links and embedded task data. ```json { "_links": { "self": { "href": "https://example.kommo.com/api/v4/tasks" } }, "_embedded": { "tasks": [ { "id": 4745251, "updated_at": 1588760725, "request_id": "0", "_links": { "self": { "href": "https://example.kommo.com/api/v4/tasks/4745251" } } }, { "id": 4747929, "updated_at": 1588760725, "request_id": "1", "_links": { "self": { "href": "https://example.kommo.com/api/v4/tasks/4747929" } } } ] } } ``` -------------------------------- ### Create Product and Link to Lead with JavaScript Source: https://developers.kommo.com/recipes/creating-a-product-and-adding-it-to-a-lead This script demonstrates creating a catalog element (product) with a specified name and price, then linking it to a lead. It requires Kommo API credentials and specific IDs. Ensure the 'axios' library is installed. ```javascript const axios = require('axios'); const subdomain = ''; const token = ''; const listId = ''; const elementName = ''; const elementPrice = ''; const leadId = ''; let elementId; const catalogBaseUri = `https://${subdomain}.kommo.com/api/v4/catalogs/${listId}/elements`; const leadsBaseUri = `https://${subdomain}.kommo.com/api/v4/leads/${leadId}/link`; const headers = { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json', }; const elementBody = [ { name: elementName, custom_fields_values: [ { field_code: 'PRICE', values: [ { value: elementPrice, }, ], }, ], }, ]; const addElement = async () => { try { const response = await axios.post(catalogBaseUri, elementBody, { headers }); if(!response.data._embedded.elements || response.data._embedded.elements.length === 0){ console.error('No elements returned from API.'); return null; } const newElement = response.data._embedded.elements[0]; elementId = newElement.id; console.log('Catalog element added with ID:', elementId); return newElement; } catch (error) { console.error('Error adding catalog element:', error.response?.data || error.message); } }; const linkElement = async () => { await addElement(); const linkBody = [ { to_entity_id: parseInt(elementId, 10), to_entity_type: 'catalog_elements', metadata: { catalog_id: parseInt(listId, 10), quantity: 8, }, }, ]; try { const response = await axios.post(leadsBaseUri, linkBody, { headers }); const linkedElement = response.data; console.log('Element linked to lead successfully'); return linkedElement._embedded.links; } catch (error) { console.error('Error linking element to lead:', error.response?.data || error.message); } }; linkElement(); ``` -------------------------------- ### onInstall Callback Function Source: https://developers.kommo.com/docs/script-js An optional callback called once during widget installation. Useful for initialization logic like creating initial data or checking the environment. Errors here do not interrupt installation. ```javascript onInstall: function() { } ``` -------------------------------- ### OpenAPI Definition for Get Loss Reason Source: https://developers.kommo.com/reference/loss-reason-by-id This OpenAPI definition outlines the GET request for retrieving a loss reason by ID, including parameters, responses, and example payloads. ```json { "openapi": "3.1.0", "info": { "title": "kommo-api-references", "version": "1.0" }, "servers": [ { "url": "https://{subdomain}.kommo.com", "variables": { "subdomain": { "default": "subdomain" } } } ], "components": { "securitySchemes": { "sec0": { "type": "oauth2", "flows": {} } } }, "security": [ { "sec0": [] } ], "paths": { "/api/v4/leads/loss_reasons/{id}": { "get": { "description": "", "operationId": "get_apiv4leadsloss_reaso-1", "responses": { "200": { "description": "Request is successful", "content": { "application/json": { "schema": { "type": "object", "properties": {} }, "examples": { "Request is successful": { "summary": "Request is successful", "value": { "id": 1234567, "name": "Insufficient budget", "sort": 100000, "created_at": 1742819648, "updated_at": 1742819648, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/leads/loss_reasons/1234567" } } } } } } } }, "404": { "description": "Loss reason not found", "content": { "application/json": { "schema": { "type": "object", "properties": {} }, "examples": { "Loss reason not found": { "summary": "Loss reason not found", "value": { "title": "Not Found", "type": "https://httpstatus.es/404", "status": 404, "detail": "Loss reason not found" } } } } } } }, "parameters": [ { "in": "path", "name": "id", "schema": { "type": "string" }, "required": true, "description": "Loss reason ID" } ], "summary": "Copy of " } } }, "x-readme": { "headers": [], "explorer-enabled": true, "proxy-enabled": true }, "x-readme-fauxas": true } ``` -------------------------------- ### API Recipe: Create Product and Link to Lead Source: https://developers.kommo.com/changelog?page=2 Example recipe for creating a product and linking it to a lead. ```javascript const products = new Kommo.Products(); const leads = new Kommo.Leads(); const productId = products.create({ "name": "Product A", "price": 100 }); leads.linkProduct(1, productId, { "quantity": 2 }); ``` -------------------------------- ### Add Leads Request Example Source: https://developers.kommo.com/reference/adding-leads This example demonstrates the structure for adding one or more leads. It includes basic lead information and custom field values. ```json [ { "name": "Example Lead 1", "created_by": 10618939, "price": 9000, "status_id": 65625139, "pipeline_id": 8244687, "custom_fields_values": [ { "field_id": 1551478, "values": [ { "value": 124 } ] } ] }, { "name": "Example Lead 2", "price": 1800 } ] ``` -------------------------------- ### Create Sources Response Example Source: https://developers.kommo.com/reference/add-sources This example shows a successful response after creating sources. It includes the total number of items created and detailed information for each source, such as its ID, name, and pipeline association. ```json { "_total_items": 2, "_embedded": { "sources": [ { "id": 17619939, "name": "chat", "pipeline_id": 5867030, "external_id": "kchat01", "services": [], "default": false, "origin_code": "kommo.ext.30470678", "request_id": "0", "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/sources/17619939" } } }, { "id": 17619943, "name": "test_chat", "pipeline_id": 5884544, "external_id": "kchat04", "services": [], "default": false, "origin_code": "kommo.ext.30470678", "request_id": "1", "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/sources/17619943" } } } ] } } ``` -------------------------------- ### Get Company by ID - Request Example Source: https://developers.kommo.com/reference/get-company This example demonstrates a successful request to retrieve company data by its ID. The `id` parameter is required in the path, and the `with` parameter can be used to include additional related data. ```json { "id": 123XYZ, "name": "United", "responsible_user_id": 837XXXX, "group_id": 0, "created_by": 837XXXX, "updated_by": 837XXXX, "created_at": 1686670709, "updated_at": 1686670709, "closest_task_at": null, "is_deleted": false, "custom_fields_values": null, "account_id": 3123123, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/companies/406320" } }, "_embedded": { "tags": [] } } ``` -------------------------------- ### Run Development Server with Docker Source: https://developers.kommo.com/docs/skeleton Start the Kommo widget development server using the 'make run-dev' command. ```bash make run-dev ``` -------------------------------- ### Incoming Leads Form Request Example Source: https://developers.kommo.com/reference/incoming-leads-form This example demonstrates how to structure a request to create a new lead using the incoming leads form. It includes essential fields like source name, source UID, pipeline ID, and creation timestamp. ```json { "request_id": "456", "source_name": "Asme Co.", "source_uid": "a1fee7c0fc436088e64ba2e8822ba2b3", "pipeline_id": 6950551, "created_at": 1510261200 ``` -------------------------------- ### Get Custom Fields Source: https://developers.kommo.com/reference/get-list-custom-field This example demonstrates how to retrieve a list of all custom fields using the Kommo API. ```APIDOC ## GET /api/v4/contacts/custom_fields ### Description Retrieves a list of all custom fields. ### Method GET ### Endpoint /api/v4/contacts/custom_fields ### Parameters #### Query Parameters - **entity_type** (string) - Optional - Filter custom fields by entity type (e.g., contacts, companies, deals). ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the custom field. - **name** (string) - The name of the custom field. - **type** (string) - The data type of the custom field (e.g., text, number, select). - **is_editable** (boolean) - Indicates if the custom field can be edited. - **is_predefined** (boolean) - Indicates if the custom field is a predefined system field. - **entity_type** (string) - The entity type this custom field belongs to. - **_links** (object) - Contains links to related resources. - **self** (object) - **href** (string) - URL for the custom field. #### Response Example ```json { "_embedded": { "custom_fields": [ { "id": 1, "name": "Customer ID", "type": "text", "is_editable": true, "is_predefined": false, "entity_type": "contacts", "_links": { "self": { "href": "https://example.kommo.com/api/v4/contacts/custom_fields/1" } } } ] } } ``` ``` -------------------------------- ### Get Event by ID - OpenAPI Definition Source: https://developers.kommo.com/reference/get-event This OpenAPI definition describes the GET /api/v4/events/{id} endpoint. It includes parameters for filtering and expanding the response, as well as example responses for successful requests and error conditions. ```json { "openapi": "3.1.0", "info": { "title": "kommo-api-references", "version": "1.0" }, "servers": [ { "url": "https://{subdomain}.kommo.com", "variables": { "subdomain": { "default": "subdomain" } } } ], "components": { "securitySchemes": { "sec0": { "type": "oauth2", "flows": {} } } }, "security": [ { "sec0": [] } ], "paths": { "/api/v4/events/{id}": { "get": { "summary": "Getting an event by its ID", "description": "This method allows getting a particular event data by its ID.", "operationId": "get-event", "parameters": [ { "name": "with", "in": "query", "description": "This parameter takes a string which may consist of several values separated by commas. You can find them in the WITH table", "schema": { "type": "string" } }, { "name": "id", "in": "path', "description": "Event ID", "schema": { "type": "string" }, "required": true } ], "responses": { "200": { "description": "200", "content": { "application/json": { "examples": { "Request successful": { "value": "{\n \"id\": \"01pz58t6p04ymgsgfbmfyfy1mf\",\n \"type\": \"lead_added\",\n \"entity_id\": 0000000,\n \"entity_type\": \"lead\",\n \"created_by\": XXXXXXX,\n \"created_at\": 1888888888,\n \"value_after\": [\n {\n \"note\": {\n \"id\": 123XXXX\n }\n }\n ],\n \"value_before\": [],\n \"account_id\": 321XXXX,\n \"_links\": {\n \"self\": {\n \"href\": \"https://example.kommo.com/api/v4/events/01pz58t6p04ymgsgfbmfyfy1mf\"\n }\n },\n \"_embedded\": {\n \"entity\": {\n \"id\": 555XXX,\n \"_links\": {\n \"self\": {\n \"href\": \"https://example.kommo.com/api/v4/leads/0000000\"\n }\n }\n }\n }\n}" } } } } }, "401": { "description": "401", "content": { "application/json": { "examples": { "User is not authorized": { "value": "{}" } }, "schema": { "type": "object", "properties": {} } } } }, "402": { "description": "402", "content": { "text/plain": { "examples": { "Unpaid account": { "value": "" } } } } } }, "deprecated": false } } }, "x-readme": { "headers": [], "explorer-enabled": true, "proxy-enabled": true }, "x-readme-fauxas": true } ``` -------------------------------- ### OpenAPI Definition for Get Field Group Source: https://developers.kommo.com/reference/get-a-fields-group-by-id This OpenAPI definition outlines the GET request for retrieving a specific custom field group by its ID and entity type. It includes parameters, responses for success and errors, and example payloads. ```json { "openapi": "3.1.0", "info": { "title": "kommo-api-references", "version": "1.0" }, "servers": [ { "url": "https://{subdomain}.kommo.com", "variables": { "subdomain": { "default": "subdomain" } } } ], "components": { "securitySchemes": { "sec0": { "type": "oauth2", "flows": {} } } }, "security": [ { "sec0": [] } ], "paths": { "/api/v4/{entity_type}/custom_fields/groups/{id}": { "get": { "description": "", "operationId": "get_apiv4{entity_type}custom_fieldsgroups{id}", "responses": { "200": { "description": "", "content": { "application/json": { "examples": { "The request is successful": { "summary": "The request is successful", "value": { "id": "leads_52311712151892", "name": "Field group", "is_predefined": false, "type": "custom_field_group", "fields": [ 782240 ], "entity_type": "leads", "sort": 4, "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/leads/custom_fields/groups/leads_52311712151892" } } } } } } } }, "401": { "description": "Unauthorized", "content": { "application/json": { "examples": { "User is not authorized": { "value": "{}", "summary": "User is not authorized" } } } } }, "404": { "description": "Not Found", "content": { "application/json": { "examples": { "Field group not found": { "value": "{}", "summary": "Field group not found" } } } } } }, "parameters": [ { "in": "path", "name": "entity_type", "schema": { "type": "string", "default": "" }, "required": true, "description": "Type of the entity. Might be: leads/contacts/comapnies" }, { "in": "path", "name": "id", "schema": { "type": "string", "default": "" }, "required": true, "description": "ID of the field group" } ] } } }, "x-readme": { "headers": [], "explorer-enabled": true, "proxy-enabled": true }, "x-readme-fauxas": true } ``` -------------------------------- ### Widget Localization Example (pt.json) Source: https://developers.kommo.com/docs/widgets-tutorial Defines widget name, descriptions, and tour text in Portuguese. Ensure all localization files share the same structure. ```json { "widget":{ "name":"Meu widget", "short_description":"Descrição curta", "description":"Descrição completa", "tour_description":"Descrição de tour" } } ``` -------------------------------- ### Get a list of lists Source: https://developers.kommo.com/reference/get-lists This example demonstrates a successful response when retrieving a list of lists. It includes pagination information and details about the embedded lists. ```json { "_page": 1, "_links": { "self": { "href": "https://example.kommo.com/api/v4/catalogs?page=1&limit=50" }, "next": { "href": "https://example.kommo.com/api/v4/catalogs?page=2&limit=50" } }, "_embedded": { "catalogs": [ { "id": 1111XXXX, "name": "Regular list", "created_by": 1234567, "updated_by": 1234567, "created_at": 1590742040, "updated_at": 1590742040, "sort": 10, "type": "regular", "can_add_elements": true, "can_show_in_cards": false, "can_link_multiple": true, "can_be_deleted": true, "sdk_widget_code": null, "account_id": 7654321, "_links": { "self": { "href": "https://example.kommo.com/api/v4/catalogs/1111XXXX" } } }, { "id": 222XXX, "name": "Products", "created_by": 777XYZ, "updated_by": 777XYZ1, "created_at": 1589390310, "updated_at": 1590742040, "sort": 20, "type": "products", "can_add_elements": true, "can_show_in_cards": false, "can_link_multiple": true, "can_be_deleted": false, "sdk_widget_code": null, "account_id": 1234567, "_links": { "self": { "href": "https://example.kommo.com/api/v4/catalogs/222XXX" } } } ] } } ``` -------------------------------- ### Widget Localization Example (en.json) Source: https://developers.kommo.com/docs/widgets-tutorial Defines widget name, descriptions, and tour text in English. Ensure all localization files share the same structure. ```json { "widget":{ "name":"My Widget", "short_description":"Short description", "description":"Full description", "tour_description":"Tour description" } } ``` -------------------------------- ### Get Account Info (200 OK) Source: https://developers.kommo.com/docs/http-codes Example of a successful response when retrieving account information. This indicates the request was received, understood, and accepted. ```json { "id": 123123123, "name": "yourname", "subdomain": "yourdomain", "created_at": 1739794993, "created_by": 0, "updated_at": 17234645, "updated_by": 0, "current_user_id": 123423, "country": "NL", "currency": "EUR", "currency_symbol": "€", "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/account" } } } ``` -------------------------------- ### Load Preloaded Data Example (SDK) Source: https://developers.kommo.com/docs/card-sdk Implement `loadPreloadedData` to fetch and resolve data for a widget tab. This example uses `crm_post` to retrieve product information from a custom API. ```javascript loadPreloadedData: function () { return new Promise(_.bind(function (resolve, reject) { self.crm_post( 'http://my.sdk.api.com/sdk_back/', {}, function (msg) { resolve(msg); }, 'json' ); }), this); } ``` -------------------------------- ### Get Leads with Long-lived Token (PHP) Source: https://developers.kommo.com/docs/long-lived-token This PHP code uses Guzzle HTTP client to make a GET request to fetch leads from your Kommo account with a long-lived token. Ensure you have Guzzle installed via Composer and replace the subdomain and token placeholders. ```php request('GET', 'https://$PASTE_YOUR_SUBDOMAIN_HERE$.kommo.com/api/v4/leads', [ 'headers' => [ 'accept' => 'text/plain', 'authorization' => 'Bearer $PASTE_YOUR_TOKEN_HERE$', ], ]); echo $response->getBody(); ``` -------------------------------- ### Install Placeholder with Options Source: https://developers.kommo.com/docs/widgets-tutorial Installs a placeholder in a specified div, optionally excluding an element. It renders a settings base template with provided parameters. ```javascript installPlaceholder(wrapDiv, exception = null) { let params = { prefix: this.widget.config.prefix, langs: this.widget.i18n("settings"), active: false, }; if (exception !== null) { params.exception = exception; } wrapDiv.prepend(this.render("settings.base", params)); $("#kommo-settings").fadeIn(300); this.widget.loader.displaySaveBtn(this.widget.params.widget_code); return this.widget.loader.hide(); } ``` -------------------------------- ### Get Widgets List Source: https://developers.kommo.com/reference/widgets-list Retrieves an aggregated list of public widgets installed on the account as well as widgets added by the current user. Supports pagination. ```APIDOC ## GET /api/v4/widgets ### Description This method returns an aggregated list of public widgets installed on the account as well as widgets added by the current user. ### Method GET ### Endpoint /api/v4/widgets ### Parameters #### Query Parameters - **page** (integer) - Optional - Page of response - **limit** (integer) - Optional - The number of entities returned in the response of one request (limit – 250) ### Response #### Success Response (200) - **_page** (integer) - The current page number of the response. - **_links** (object) - Contains links for pagination (self, next). - **_embedded** (object) - Contains the list of widgets. - **widgets** (array) - An array of widget objects. - **id** (integer) - The unique identifier of the widget. - **code** (string) - The code or name of the widget (e.g., "facebook"). - **version** (string) - The version of the widget. - **rating** (string) - The rating of the widget. - **settings_template** (array) - An array of settings templates for the widget. - **is_lead_source** (boolean) - Indicates if the widget is a lead source. - **is_work_with_dp** (boolean) - Indicates if the widget works with DP. - **is_crm_template** (boolean) - Indicates if the widget is a CRM template. - **client_uuid** (null) - Client UUID, if applicable. - **is_active_in_account** (boolean) - Indicates if the widget is active in the account. - **pipeline_id** (null) - Pipeline ID, if applicable. - **_links** (object) - Contains links related to the widget (self). #### Response Example { "_page": 1, "_links": { "self": { "href": "https://example.kommo.com/api/v4/widgets?limit=2&page=1" }, "next": { "href": "https://example.kommo.com/api/v4/widgets?limit=2&page=2" } }, "_embedded": { "widgets": [ { "id": 333XXX, "code": "facebook", "version": "0.0.13", "rating": "2,8", "settings_template": [ { "key": "fb", "name": "custom", "type": "custom", "is_required": false } ], "is_lead_source": false, "is_work_with_dp": false, "is_crm_template": false, "client_uuid": null, "is_active_in_account": false, "pipeline_id": null, "_links": { "self": { "href": "https://example.kommo.com/api/v4/widgets/facebook" } } }, { "id": 000XYZ, "code": "wechat", "version": "1.1.12", "rating": "3,4", "settings_template": [ { "key": "wechat", "name": "custom", "type": "custom", "is_required": false } ], "is_lead_source": false, "is_work_with_dp": false, "is_crm_template": false, "client_uuid": null, "is_active_in_account": false, "pipeline_id": null, "_links": { "self": { "href": "https://example.kommo.com/api/v4/widgets/wechat" } } } ] } } #### Error Response (401) - **User is not authorized** #### Response Example {} ``` -------------------------------- ### Update Source Example Source: https://developers.kommo.com/reference/update-source This example demonstrates updating a source. It shows the structure of a successful response when a source is updated. ```json { "id": 17619939, "name": "chat", "pipeline_id": 5867030, "external_id": "kchat01", "services": [], "default": true, "origin_code": "kommo.ext.30470678", "_links": { "self": { "href": "https://subdomain.kommo.com/api/v4/sources/17619939" } } } ```