### Retrieve Lead List API Responses Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Example responses for the GET /{domain}/api/v1/leads endpoint. ```json { "code": "ok", "numFound": 1, "leads": [ { "id": 414857091, "lead_no": 273763, "requester_id": 63216680, "ticket_source_end_status": 1, "assignee_id": 1, "ticket_priority": "Normal", "ticket_source": "Voice Out", "is_overdue": null, "subject": "Cuộc gọi ra cho khách hàng loi.tranquang", "created_at": "2024-05-03T15:28:40Z", "updated_at": "2024-05-03T15:28:40Z", "duedate": null, "service_id": 2005289, "incident_id": null, "satisfaction": null, "satisfaction_at": null, "satisfaction_content": null, "campaign_id": null, "automessage_id": null, "source_detail_id": 127, "convert_by": null, "convert_at": null, "convert_type": null, "unqualified_reasons": null, "last_lead_status_id": null, "lead_status_id": 525, "estimated_closed_date": null } ] } ``` ```json { "error": "Invalid request" } ``` -------------------------------- ### Retrieve Lead Statuses API Responses Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Example responses for the GET /{domain}/api/v1/lead/status endpoint. ```json { "code": "ok", "data": [ {"id": 525, "label": "Tương tác mới" , "status_type": 1}, {"id": 557, "label": "Đang liên hệ" , "status_type": 0}, {"id": 558, "label": "Comming" , "status_type": 0}, {"id": 643, "label": "Trạng thái demo" , "status_type": 0}, {"id": 527, "label": "Lead Converted1" , "status_type": 2}, {"id": 528, "label": "Lead Unqualified", "status_type": 3} ] } ``` ```json { "error": "Invalid request" } ``` -------------------------------- ### Ticket API Response and Request Examples Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/phieu-ghi Examples of successful API responses and the structure of parameters for updating a ticket. ```json { "code": "ok", "ticket": { "updated_at": "2023-03-29 17:18:40", "ticket_subject": "Test", "ticket_no": 7043, "created_at": "2023-03-29 13:25:31", "ticket_id": 381440615 } } ``` ```json { "ticket": { "ticket_subject": "Test", "ticket_comment": { "body": "Comment", "is_public": 1, "author_id": 124734559 }, "ticket_priority": "Hight", "ticket_source": "Voice", "custom_fields": [ { "id": "6068", "value": "106902" } ] } } ``` -------------------------------- ### List Customers Response Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/khach-hang Example JSON response for a successful request to list customers. ```json { "code": "ok", "numFound": 3, "contacts": [ { "id": 165027003, "created_at": "2023-04-14T09:43:24Z", "updated_at": "2023-04-14T09:43:24Z", "phone_no": "0334992975", "username": "0334992975" }, ... ] } ``` -------------------------------- ### ZNS API Response Examples Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/tin-nhan-zalo-zns Examples of successful and error responses when interacting with the ZNS API. ```json { "status": "OK", "ticket": { "ticketId": "297002" } } ``` ```json { "code": "errors", "errors": { "template_id": [ "The selected template id is invalid." ] } } ``` -------------------------------- ### API Response Examples Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/deal Standard response formats for successful requests and validation errors. ```json { "code": "ok", "deal": { "updated_at": "2024-03-21 15:04:04", "subject": "Test referer url", "created_at": "2024-03-21 15:04:04", "id": 414856013, "requester_id": 63215969 } } ``` ```json { "error": "Invalid request" } ``` -------------------------------- ### Create Ticket Request Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/phieu-ghi Examples for creating a new ticket using cURL or a JSON body. ```powershell curl --location 'https://api.caresoft.vn/{{domain}}/api/v1/tickets' \ --header 'Authorization: Bearer {{apiToken}}' \ --header 'Content-Type: application/json' \ --data '{ "ticket": { "phone": "0900000001", "username": "Khách hàng Demo", "service_id": 12, "ticket_subject": "Test create ticket from API", "ticket_comment": "Coment create ticket from Api ", "ref_url": "https://caresoft.vn?utm=xtest", "is_public": 1 } }' ``` ```json { "ticket": { "phone": "0900000001", "username": "Khách hàng Demo", "service_id": 12, "ticket_subject": "Test create ticket from API", "ticket_comment": "Coment create ticket from Api ", "ref_url": "https://caresoft.vn?utm=xtest", "duedate":"2023-06-01 20:00:00", "is_public": 1 } } ``` -------------------------------- ### GET /{domain}/api/v1/deal/unqualified-reasons Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/deal Retrieves a list of reasons why a lead might be marked as unqualified. ```APIDOC ## GET /{domain}/api/v1/deal/unqualified-reasons ### Description Retrieves a list of reasons why a lead might be marked as unqualified. ### Method GET ### Endpoint /{domain}/api/v1/deal/unqualified-reasons ### Response #### Success Response (200) - **code** (string) - Status code - **data** (array) - List of unqualified reasons #### Response Example { "code": "ok", "data": [ { "id": 193, "label": "No need" } ] } ``` -------------------------------- ### Call In - Start Event Source: https://docs.caresoft.vn/danh-muc/webhook This event is triggered when an inbound call begins. ```APIDOC ## POST /events/call_in/start ### Description This endpoint receives notifications for the start of an inbound call. ### Method POST ### Endpoint /events/call_in/start ### Request Body - **object** (string) - Required - Indicates the event source, should be 'call_in'. - **action** (string) - Required - Indicates the specific event, should be 'call_in_start'. - **call_info** (object) - Required - Contains detailed information about the call. - **event_name** (string) - Required - The name of the event, 'call_in_start'. - **call_id** (string) - Required - Unique identifier for the call. - **account_id** (integer) - Required - The ID of the account. - **direction** (string) - Required - The direction of the call, should be 'inbound'. - **caller** (string) - Required - The phone number of the caller. - **called** (string) - Required - The phone number being called. - **event_time** (integer) - Required - The time the event occurred in milliseconds. ### Request Example ```json { "object": "call_in", "action": "call_in_start", "call_info": { "event_name": "call_in_start", "call_id": "in_call_789", "account_id": 1001, "direction": "inbound", "caller": "+1-555-123-4567", "called": "+1-800-987-6543", "event_time": 1678888000000 } } ``` ### Response This endpoint typically returns a success acknowledgment, e.g., an empty JSON object or a status message. #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Get Unqualified Lead Reasons Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Retrieves a list of configured IDs and labels for unqualified leads. ```json { "code": "ok", "data": [ { "id": 176, "label": "No need" }, { "id": 177, "label": "Not the decision maker" }, { "id": 182, "label": "No budget" }, { "id": 217, "label": "Lead unqualified" } ] } ``` ```json { "error": "Invalid request" } ``` -------------------------------- ### GET /{domain}/api/v1/deal/pipelines Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/deal Retrieves a list of all deal pipelines and their associated stages. ```APIDOC ## GET /{domain}/api/v1/deal/pipelines ### Description Retrieves a list of all deal pipelines and their associated stages. ### Method GET ### Endpoint /{domain}/api/v1/deal/pipelines ### Response #### Success Response (200) - **code** (string) - Status code - **data** (array) - List of pipelines #### Response Example { "code": "ok", "data": [ { "id": 41, "label": "Sale pipeline", "stages": [ { "id": 296, "stage_name": "Tư vấn triển khai", "probability": 50 } ] } ] } ``` -------------------------------- ### GET /{domain}/lead/labels Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Retrieves a list of all available lead labels. ```APIDOC ## GET /{domain}/lead/labels ### Description Retrieves a list of lead labels configured in the system. ### Method GET ### Endpoint /{domain}/lead/labels ### Parameters #### Path Parameters - **domain** (string) - Required - The domain identifier for the request. ### Response #### Success Response (200) - **code** (string) - Status code indicator. - **data** (array) - List of lead label objects. - **id** (integer) - Unique identifier for the label. - **label** (string) - The label name. - **created_at** (string) - Timestamp of creation. - **updated_at** (string) - Timestamp of last update. #### Response Example { "code": "ok", "data": [ { "id": 17, "label": "5", "created_at": "2023-10-03 17:11:01", "updated_at": "2023-10-03 17:11:01" }, { "id": 11, "label": "Cold", "created_at": "2023-10-02 11:13:17", "updated_at": "2023-10-02 11:13:17" }, { "id": 22, "label": "Freezing@2", "created_at": "2023-10-25 14:22:14", "updated_at": "2023-10-25 14:22:14" } ] } ``` -------------------------------- ### Get Lead Labels Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Retrieves a list of lead labels including their creation and update timestamps. ```json { "code": "ok", "data": [ { "id": 17, "label": "5", "created_at": "2023-10-03 17:11:01", "updated_at": "2023-10-03 17:11:01" }, { "id": 11, "label": "Cold", "created_at": "2023-10-02 11:13:17", "updated_at": "2023-10-02 11:13:17" }, { "id": 22, "label": "Freezing@2", "created_at": "2023-10-25 14:22:14", "updated_at": "2023-10-25 14:22:14" } ] } ``` ```json { "error": "Invalid request" } ``` -------------------------------- ### Zalo Service Data Structure Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/dich-vu Example JSON object representing the Zalo service configuration. ```json { "service_id": 6205009, "service_name": "Dota2", "service_type": "Zalo", "type": 10, "detail": { "oa_id": "1881674073797784908", "active": 1, "description": "Dota2 VN community Share Funny moment", "name": "Dota2" } } ``` -------------------------------- ### GET /{domain}/api/v1/lead/unqualified-reason Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Retrieves a list of configured IDs and labels for lead unqualified reasons. ```APIDOC ## GET /{domain}/api/v1/lead/unqualified-reason ### Description Retrieves the list of IDs and labels for unqualified reasons that have been configured for leads. ### Method GET ### Endpoint /{domain}/api/v1/lead/unqualified-reason ### Parameters #### Path Parameters - **domain** (string) - Required - The domain identifier for the request. ### Response #### Success Response (200) - **code** (string) - Status code indicator. - **data** (array) - List of unqualified reason objects. - **id** (integer) - Unique identifier for the reason. - **label** (string) - The display label for the reason. #### Response Example { "code": "ok", "data": [ { "id": 176, "label": "No need" }, { "id": 177, "label": "Not the decision maker" }, { "id": 182, "label": "No budget" }, { "id": 217, "label": "Lead unqualified" } ] } ``` -------------------------------- ### GET /campaign/list Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/smart-dialer Retrieves a list of configured campaigns on the system. Supports filtering by date, status, and pagination. ```APIDOC ## GET /{domain}/api/v1/campaign/list ### Description Retrieves a list of configured campaigns on the system. Supports filtering by date, status, and pagination. ### Method GET ### Endpoint `https://dialer-api.caresoft.vn/{domain}/api/v1/campaign/list` ### Parameters #### Query Parameters - **date_from** (DateTime YYYY-MM-DD HH:mm:ss) - Optional - Start date for campaign creation filter. - **date_to** (DateTime YYYY-MM-DD HH:mm:ss) - Optional - End date for campaign creation filter. - **status** (Int) - Optional - Filter campaigns by status (0: Draff, 1: New, 2: Ready, 3: Running, 4: Pause, 5: Finish). - **page** (int) - Optional - The page number for pagination. Defaults to 1. - **count** (int) - Optional - The number of records per request. Defaults to 25, maximum 1000. - **campaign_id** (Int) - Optional - Retrieve details for a specific campaign ID. ### Request Example (No request body example provided for this endpoint) ### Response #### Success Response (200) - **numFound** (string) - The total number of campaigns found. - **data** (array) - An array of campaign objects. - **campaign_id** (int) - The unique identifier for the campaign. - **name** (string) - The name of the campaign. - **schedule_start** (string|null) - The scheduled start time of the campaign. - **schedule_stop** (string|null) - The scheduled end time of the campaign. - **statusType** (string) - The textual representation of the campaign status. - **actionType** (string) - The type of action for the campaign (e.g., AUTODIAL). - **status** (int) - The numerical status code of the campaign (0: Draff, 1: New, 2: Ready, 3: Running, 4: Pause, 5: Finish). - **action** (int) - The type of campaign action (1: Preview, 2: Predictive Call, 3: Autocall). #### Response Example ```json { "numFound": "3", "data": [ { "campaign_id": 5674, "name": "123456", "schedule_start": null, "schedule_stop": null, "statusType": "DRAFF", "actionType": "AUTODIAL", "status": 0, "action": 3 }, { "campaign_id": 5323, "name": "TestAT", "schedule_start": "2022-09-26 00:00:00", "schedule_stop": "2022-09-26 23:59:59", "statusType": "FINISHED", "actionType": "AUTODIAL", "status": 5, "action": 3 }, { "campaign_id": 5320, "name": "2409 at", "schedule_start": "2022-09-24 00:00:00", "schedule_stop": "2022-09-24 23:59:59", "statusType": "DRAFF", "actionType": "AUTODIAL", "status": 0, "action": 3 } ] } ``` #### Error Response (400) - **error** (string) - Description of the error. #### Error Response Example ```json { "error": "Invalid request" } ``` ``` -------------------------------- ### GET /{domain}/api/v1/deal/{dealId} Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/deal Retrieves the detailed information of a specific deal based on the provided dealId. ```APIDOC ## GET /{domain}/api/v1/deal/{dealId} ### Description Lấy chi tiết 1 deal theo tham số dealID được tạo từ bước 1 hoặc được khai thác từ quá trình đồng bộ. ### Method GET ### Endpoint /{domain}/api/v1/deal/{dealId} ### Parameters #### Path Parameters - **domain** (string) - Required - The domain identifier for the Caresoft instance. - **dealId** (integer) - Required - The unique identifier of the deal. ### Response #### Success Response (200) - **deal** (object) - The object containing detailed deal information including conversion data, pipeline status, and order product details. #### Response Example { "deal": { "account_id": 8187, "id": 474845380, "deal_no": 13241, "subject": "Test Deal", "created_at": "2024-03-16 02:22:55", "value": 1000, "order_products": [ { "name": "Boots", "sku": "2", "unit_price": 50000, "quantity": 1, "total_amount": 45000 } ] } } ``` -------------------------------- ### HTML Click-to-Call Implementation Source: https://docs.caresoft.vn/danh-muc/tich-hop-thoai/tich-hop-goi-ra-su-dung-click-to-call-tren-web Example HTML structure demonstrating how to open the call window and listen for post-call messages. ```html

CRM

``` -------------------------------- ### System and Connectivity Events Source: https://docs.caresoft.vn/danh-muc/tich-hop-thoai/tich-hop-kenh-thoai-tren-ung-dung-web-voice-api Functions to handle system initialization, device status, and socket connectivity. ```APIDOC ## System and Connectivity Events ### Description Handles initialization, device type detection, and socket reconnection logic. ### Methods - `csInitComplete()`: Triggered when system is ready. - `csInitError(errorCode)`: Triggered on initialization failure. - `csNotifyReconnecting(retry, maxRetry)`: Triggered during socket reconnection attempts. - `csOndisconnected()`: Triggered when socket connection is permanently lost. - `csShowDeviceType(type)`: Triggered when device type changes (1: Browser, 2: IP Phone logged in, 4: IP Phone no login). ``` -------------------------------- ### Get Campaign Call Log Details Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/smart-dialer Use this GET request to retrieve a detailed list of calls made within a campaign. It includes information such as called number, start and end times, and call status codes. ```http GET /{domain}/api/v1/smartdialer/call-log-details ``` -------------------------------- ### API Endpoint: Get Ticket List (V1) Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/phieu-ghi Use this endpoint to retrieve a list of tickets. A 'created_since' or 'updated_since' parameter is mandatory. The API applies specific logic to date ranges if only a start date is provided or if the range exceeds 31 days. ```http GET {{domain}}/api/v1/tickets ``` -------------------------------- ### HTML Button to Open Widget Source: https://docs.caresoft.vn/danh-muc/nhung-live-chat-ticket-form/nhung-live-chat-vao-website/caresoft-live-chat-sdk-api-ho-tro-tuong-tac-widget An example of how to trigger the 'open-widget' action using an HTML button's `onclick` event. ```html ``` -------------------------------- ### Connect to Agent Source: https://docs.caresoft.vn/chatbot/tich-hop-he-thong-khac/the-json-api Initiate a transfer to a live agent. An empty array for 'connect_to_list_agent' connects to all available agents. ```json { "connect_to_list_agent": [] } ``` -------------------------------- ### Get Detailed Chat Messages API Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/chat/danh-sach-tin-nhan-chat Use this GET endpoint to retrieve a list of detailed chat messages. You must provide a start_time_since parameter. The conversation_type parameter can be used to filter by chat type (Live Chat, Messenger/Instagram, Zalo). ```HTTP GET {{domain}}/api/v1/chats/messages ``` -------------------------------- ### Get List of Departments Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/bo-phan Use this endpoint to retrieve a list of all configured departments on the system. Ensure proper authentication headers are included. ```json { "code": "ok", "groups": [ { "group_id": 12153, "group_name": "Default Group", "created_at": "2020-10-01 02:48:15" }, { "group_id": 12945, "group_name": "Kinh doanh", "created_at": "2021-10-27 14:55:31" }, { "group_id": 14181, "group_name": "Chăm sóc khách hàng", "created_at": "2023-03-21 09:33:23" } ] } ``` -------------------------------- ### GET /api/v1/lead/status Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Retrieves a list of configured lead statuses. ```APIDOC ## GET /{domain}/api/v1/lead/status ### Description Retrieves a list of configured lead statuses on the system. ### Method GET ### Endpoint `/{domain}/api/v1/lead/status` ### Parameters No parameters are required for this endpoint. ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **code** (string) - Status code, 'ok' for success. - **data** (array) - An array of lead status objects. - **id** (integer) - The unique identifier for the lead status. - **label** (string) - The name of the lead status. - **status_type** (integer) - The type of status: 1 for initial, 0 for intermediate, 2 for converted, 3 for unqualified. #### Response Example ```json { "code": "ok", "data": [ {"id": 525, "label": "Tương tác mới", "status_type": 1}, {"id": 557, "label": "Đang liên hệ", "status_type": 0}, {"id": 558, "label": "Comming", "status_type": 0}, {"id": 643, "label": "Trạng thái demo", "status_type": 0}, {"id": 527, "label": "Lead Converted1", "status_type": 2}, {"id": 528, "label": "Lead Unqualified", "status_type": 3} ] } ``` #### Error Response (400) - **error** (string) - Description of the error. #### Error Response Example ```json { "error": "Invalid request" } ``` ``` -------------------------------- ### GET /api/v1/cities Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/khach-hang/thong-tin-tinh-huyen-xa Retrieves a list of all provinces and cities in Vietnam. ```APIDOC ## GET /api/v1/cities ### Description Retrieves a list of all provinces and cities in Vietnam. This data includes the status of administrative units. ### Method GET ### Endpoint {{domain}}/api/v1/cities ### Parameters #### Headers - **Authorization** (String) - Required - Authentication information. ### Response #### Success Response (200) - **code** (String) - Request status. - **numFound** (Integer) - Number of records found. - **data** (Array) - List of provinces/cities. - **id** (String) - Province/City ID. - **name** (String) - Name of the province/city. - **type** (String) - Administrative classification. - **status** (Integer) - Usage status (0: inactive, 1: active). #### Response Example { "code": "ok", "data": [ { "id": "01", "name": "Thành phố Hà Nội", "type": "Thành phố Trung ương", "status": 1 } ] } ``` -------------------------------- ### GET /api/v1/organizations/custom_fields Source: https://docs.caresoft.vn/thong-tin-chung/truong-dong-custom-fields Retrieves the list of custom fields defined for organizations. ```APIDOC ## GET /api/v1/organizations/custom_fields ### Description Retrieves the list of custom fields defined for organizations. ### Method GET ### Endpoint {{domain}}/api/v1/organizations/custom_fields ``` -------------------------------- ### Initialize CareSoft Connection Source: https://docs.caresoft.vn/danh-muc/tich-hop-thoai/tich-hop-kenh-thoai-tren-ung-dung-web-voice-api Call this function to establish a connection with the CareSoft switchboard. Replace 'token' and 'domain' with your actual credentials obtained in step 1. ```javascript csInit(token, domain); ``` -------------------------------- ### GET /api/v1/contacts/custom_fields Source: https://docs.caresoft.vn/thong-tin-chung/truong-dong-custom-fields Retrieves the list of custom fields defined for contacts. ```APIDOC ## GET /api/v1/contacts/custom_fields ### Description Retrieves the list of custom fields defined for contacts. ### Method GET ### Endpoint {{domain}}/api/v1/contacts/custom_fields ``` -------------------------------- ### GET /api/v1/tickets/custom_fields Source: https://docs.caresoft.vn/thong-tin-chung/truong-dong-custom-fields Retrieves the list of custom fields defined for tickets. ```APIDOC ## GET /api/v1/tickets/custom_fields ### Description Retrieves the list of custom fields available for tickets, including their IDs, codes, labels, types, and possible values. ### Method GET ### Endpoint {{domain}}/api/v1/tickets/custom_fields ### Response #### Success Response (200) - **code** (string) - Status code - **custom_fields** (array) - List of custom field objects #### Response Example { "code": "ok", "custom_fields": [ { "custom_field_id": 5164, "code": "PHANLOAI", "custom_field_lable": "Phân loại phiếu ghi", "type": "Single drop-down list", "values": [ { "id": 89496, "code": "TIENTRINHDEAL", "lable": "Tiến trình Leads", "parent_value_id": -1 } ] } ] } ``` -------------------------------- ### Retrieve Unqualified Reasons Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/deal Fetches a list of reasons why a lead might be marked as unqualified. ```json { "code": "ok", "data": [ { "id": 193, "label": "No need" }, { "id": 194, "label": "Not the decision maker" }, { "id": 195, "label": "No budget" }, { "id": 196, "label": "Not the right timing" }, { "id": 197, "label": "Other" } ] } ``` ```json { "error": "Invalid request" } ``` -------------------------------- ### GET /api/v1/leads Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Retrieves a list of leads with optional filtering parameters. ```APIDOC ## GET /{domain}/api/v1/leads ### Description Retrieves a list of leads with optional filtering parameters. ### Method GET ### Endpoint `/{domain}/api/v1/leads` ### Parameters #### Query Parameters - **requester_id** (integer) - Optional - ID of the requester. - **assignee_id** (integer) - Optional - ID of the assignee. - **service_id** (integer) - Optional - ID of the service. - **page** (integer) - Optional - Page number (defaults to 1). - **count** (integer) - Optional - Number of records per page (defaults to 50, max 500). - **created_since** (Time TZ) - Optional - Filter leads created since this date and time (e.g., 2024-06-01T00:00:00Z). - **created_to** (Time TZ) - Optional - Filter leads created until this date and time (e.g., 2024-06-01T00:00:00Z). - **updated_since** (Time TZ) - Optional - Filter leads updated since this date and time (e.g., 2024-06-01T00:00:00Z). - **updated_to** (Time TZ) - Optional - Filter leads updated until this date and time (e.g., 2024-06-01T00:00:00Z). - **convert_since** (Time TZ) - Optional - Filter leads converted to deal since this date and time (e.g., 2024-06-01T00:00:00Z). - **convert_to** (Time TZ) - Optional - Filter leads converted to deal until this date and time (e.g., 2024-06-01T00:00:00Z). - **status_ids** (string) - Optional - Comma-separated lead status IDs (e.g., 12 or 12,34,56). - **convert_type** (integer) - Optional - Conversion status from lead to deal (1: Converted to Lead, 2: Unqualified). ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **code** (string) - Status code, 'ok' for success. - **numFound** (integer) - The total number of leads found. - **leads** (array) - An array of lead objects. - **id** (integer) - The unique identifier for the lead. - **lead_no** (integer) - The lead number. - **requester_id** (integer) - The ID of the requester. - **ticket_source_end_status** (integer) - The end status of the ticket source. - **assignee_id** (integer) - The ID of the assignee. - **ticket_priority** (string) - The priority of the ticket. - **ticket_source** (string) - The source of the ticket. - **is_overdue** (null) - Indicates if the ticket is overdue. - **subject** (string) - The subject of the lead. - **created_at** (string) - The date and time the lead was created (ISO 8601 format). - **updated_at** (string) - The date and time the lead was last updated (ISO 8601 format). - **duedate** (null) - The due date for the lead. - **service_id** (integer) - The ID of the associated service. - **incident_id** (null) - The ID of the associated incident. - **satisfaction** (null) - Satisfaction rating. - **satisfaction_at** (null) - The date and time of satisfaction rating. - **satisfaction_content** (null) - Content of the satisfaction feedback. - **campaign_id** (null) - The ID of the associated campaign. - **automessage_id** (null) - The ID of the associated automessage. - **source_detail_id** (integer) - Detailed ID of the source. - **convert_by** (null) - The user who converted the lead. - **convert_at** (null) - The date and time the lead was converted. - **convert_type** (null) - The type of conversion. - **unqualified_reasons** (null) - Reasons for disqualification. - **last_lead_status_id** (null) - The ID of the last lead status. - **lead_status_id** (integer) - The current ID of the lead status. - **estimated_closed_date** (null) - The estimated closed date for the lead. #### Response Example ```json { "code": "ok", "numFound": 1, "leads": [ { "id": 414857091, "lead_no": 273763, "requester_id": 63216680, "ticket_source_end_status": 1, "assignee_id": 1, "ticket_priority": "Normal", "ticket_source": "Voice Out", "is_overdue": null, "subject": "Cuộc gọi ra cho khách hàng loi.tranquang", "created_at": "2024-05-03T15:28:40Z", "updated_at": "2024-05-03T15:28:40Z", "duedate": null, "service_id": 2005289, "incident_id": null, "satisfaction": null, "satisfaction_at": null, "satisfaction_content": null, "campaign_id": null, "automessage_id": null, "source_detail_id": 127, "convert_by": null, "convert_at": null, "convert_type": null, "unqualified_reasons": null, "last_lead_status_id": null, "lead_status_id": 525, "estimated_closed_date": null } ] } ``` #### Error Response (400) - **error** (string) - Description of the error. #### Error Response Example ```json { "error": "Invalid request" } ``` ``` -------------------------------- ### POST /deals Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/deal Creates a new deal in the system with specified attributes, pipeline information, and custom fields. ```APIDOC ## POST /deals ### Description Creates a new deal record in the Caresoft system. ### Method POST ### Endpoint /deals ### Request Body - **deal** (object) - Required - The deal object containing: - **phone** (string) - Required - Customer phone number - **subject** (string) - Required - Deal subject - **value** (string) - Optional - Deal value - **probability** (int) - Optional - Probability percentage - **estimated_closed_date** (string) - Optional - Expected closing date - **deal_label** (array) - Optional - List of label IDs - **pipeline_id** (int) - Required - ID of the pipeline - **pipeline_stage_id** (string) - Required - ID of the pipeline stage - **custom_fields** (array) - Optional - List of custom field objects with id and value ### Request Example { "deal": { "phone": "0983980148", "subject": "Test referer url", "value": "233333", "probability": 23, "estimated_closed_date": "2024/03/21 23:59:59", "deal_label": [10, 11], "pipeline_id": 56, "pipeline_stage_id": "377", "custom_fields": [ { "id": "6068", "value": "106902" } ] } } ### Response #### Success Response (200) - **code** (string) - Status code - **deal** (object) - Created deal details including id, created_at, and updated_at #### Response Example { "code": "ok", "deal": { "updated_at": "2024-03-21 15:04:04", "subject": "Test referer url", "created_at": "2024-03-21 15:04:04", "id": 414856013, "requester_id": 63215969 } } ``` -------------------------------- ### POST /api/v1/lead - Create Lead Source: https://docs.caresoft.vn/danh-muc/restful-api-cua-caresoft/lead Creates a new lead with the provided information. The response includes the newly created lead's ID. ```APIDOC ## POST /{domain}/api/v1/lead ### Description Creates a new lead with the provided information. The response includes the newly created lead's ID. ### Method POST ### Endpoint `/{domain}/api/v1/lead` ### Headers - **Content-Type** (string) - Required - `application/json` - **Authorization** (string) - Required - `Bearer ` ### Request Body - **lead** (object) - Required - Object containing lead information. - **username** (text) - Optional - Customer's full name. (Not used if phone or email already exists) - **subject** (text) - Required - Subject of the lead. - **phone** (tel) - Required - Customer's phone number. - **email** (email) - Required - Customer's email address. - **service_id** (Int) - Optional - ID of the service the lead is for. - **group_id** (Int) - Optional - ID of the department receiving the lead. - **assignee_id** (Int) - Optional - ID of the assigned specialist. - **lead_status_id** (Int) - Optional - ID of the lead status (defaults to the first status if not provided). - **estimated_closed_date** (DateTime) - Optional - Estimated closing date (Format: YYYY-MM-DD HH:mm:ss). - **lead_label** (Array) - Optional - Array of label IDs for the lead (e.g., [1,2,3]). - **custom_fields** (Array) - Optional - Array of custom fields, similar to ticket creation. - **comment** (Text) - Optional - Note content. - **unqualify_reason** (Int) - Optional - ID of the reason for disqualification (only applicable if lead_status_id is a final status). ### Request Example ```json { "lead": { "phone": "0983980148", "service_id": 1244, "subject": "Test lead", "comment": "Helo world", "estimated_closed_date": "2024/03/21 23:59:59", "lead_status": 558, "lead_label_id": [ 10, 11 ], "ref_url": "https://gooogle.com?utm_content=TestREFERURL&utm_source=GANEW" } } ``` ### Response #### Success Response (200) - **code** (string) - Indicates success, typically "ok". - **lead** (object) - Object containing lead details. - **updated_at** (string) - Timestamp of the last update. - **subject** (string) - Subject of the lead. - **created_at** (string) - Timestamp of creation. - **id** (integer) - The unique ID of the created lead. - **requester_id** (integer) - The ID of the requester. #### Response Example (200) ```json { "code": "ok", "lead": { "updated_at": "2024-03-21 15:11:06", "subject": "Test referer lead", "created_at": "2024-03-21 15:11:06", "id": 414856017, "requester_id": 63215969 } } ``` #### Error Response (400) - **error** (string) - Description of the error. #### Response Example (400) ```json { "error": "Invalid request" } ``` ``` -------------------------------- ### Get Online Agent Information Source: https://docs.caresoft.vn/danh-muc/tich-hop-thoai/tich-hop-kenh-thoai-tren-ung-dung-web-voice-api Retrieves information about agents who are currently online. ```javascript getTransferAgent() ```