Introduction
Insights User API is used to create/update/view a User record in the Insights section.
We can use this User to start a new conversation which can be a two-way Sms or Chat over a WebSocket connection.
For accessing each of the below API, we need to set the below Headers:
We can use this User to start a new conversation which can be a two-way Sms or Chat over a WebSocket connection.
For accessing each of the below API, we need to set the below Headers:
Headers
Content-Type - application/json
Chat-API-Key - Required
(You can get the Chat-API-Key by signing in with the administrator credentials navigate to `domain-name/chat/installation`)
(You can get the Chat-API-Key by signing in with the administrator credentials navigate to `domain-name/chat/installation`)
Below are the different APIs:
Show User
Returns json data about a single user.
URL
URL
/api/v1/insights/users/:user_id
Method
GET
URL Params
user_id=[integer]
Data Params
None
Success Response
Code: 200
Content:
{ "user": { "id": "8c18a3fa-d536-466c-a833-fd106586f9c7", "name": "API testing", "email": "[email protected]", "phone_number": "+12025550777", "first_seen_at": "2020-10-10T14:21:56.806Z", "last_seen_at": "2020-12-18T04:22:36.571Z", "signed_up_on": "2020-10-06T16:20:05.252+00:00", "visits_count": 19, "timezone": "Asia/Calcutta", "browser_language": "English", "referrer_url": "", "custom_attributes": {}, "user_identifier": "0b18eb30-7051-4124-acb2-17a1f8cdabf8", "online_status": "offline", "total_open_conversations": 0 }, "additional_info": { "total_conversations": 0 }, "technology": { "device_info": "macOS 10.14.0", "browser_info": "Unknown Browser 0.0", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0)" }, "recent_activities": [ { "id": "ec1f42c5-d139-458d-9d14-d21ced763e1f", "page_url": null, "page_title": null, "visited_at": "2020-12-18T16:20:05.480Z" }, { "id": "2773960d-05b8-4d2b-9960-1842345f1a3d", "page_url": "https://www.google.com/", "page_title": "Google", "visited_at": "2020-12-18T16:20:05.479Z" } ], "conversations": [], "chat_permissions": { "allow_widget_conversation": true, "allow_sms_conversation": true } }
Error Response
Code: 404
Content:
Content:
{ "error": "User not found" }
Sample Call
http://<subdomain>.neetohelp.com.neetohelp.net/api/v1/insights/users/8c18a3fa-d536-466c-a833-fd106586f9c2
Create User
Creates an insight User
URL
URL
/api/v1/insights/users
Method
POST
URL Params
None
Data Params
Name Type Required Description name string Optional Name. email string Optional Email. phone_number string Optional Phone Number with country code. custom_attributes json Optional Any other columns which are absent in the API can be sent here in JSON format. user_identifier string Mandatory Unique Identifier for the User.
Example
{ "user": { "name": "API testing", "email": "[email protected]", "phone_number": "+12025550777", "custom_attributes": { "product_name": "ABC", "product_price": "245", "order_number": "IHJOID001", "Date_of_birth": "24 July 1988" }, "user_identifier": "IHJ0044", "started_at": "2021-4-12", "note": "Note for the user.", "conversation": { "token": "IHJOID0011", // Unique token. It can be the order id. "note": "Conversation note for order IHJOID0011" // Note for the conversation. } } }
Success Response
Code: 200
Content:
{ "user": { "id": "abd32644-5be0-421b-81bd-78cb244633b8", "email": "[email protected]", "name": "API testing", "phone_number": "+12025550777", "profile_url": "http://spinkart.neetochat.com/admin/insights/abd32644-5be0-421b-81bd-78cb244633b8", "conversation_url": "http://spinkart.neetochat.com/admin/widget/inbox/all?id=9d470df9-7edb-4fd2-8861-94e0024d1bb0" // If the request contains conversation params, then it will create the conversation and returns the URL } }
Error Response
Code: 422
Content:
Content:
{"errors":["User identifier can't be blank"]}
Sample Call
http://<subdomain>.neetohelp.com/api/v1/insights/users
Update User
Updates an insight User
URL
URL
/api/v1/insights/users/:user_id
Method
PATCH
URL Params
user_id=[integer]
Data Params
Name Type Required Description name string Optional Name. email string Optional Email. phone_number string Optional Phone Number with country code. custom_attributes json Optional Any other columns which are absent in the API can be sent here in JSON format. user_identifier string Mandatory Unique Identifier for the User.
Example:
{ "user": { "name": "API testing", "email": "[email protected]", "phone_number": "+12025550777", "custom_attributes": { "product_name": "ABC", "product_price": "245", "order_number": "IHJOID001", "Date_of_birth": "24 July 1988" }, "user_identifier": "IHJ0044", "started_at": "2021-4-12", "note": "Note for the user.", "conversation": { "token": "IHJOID0011", // Unique token. It can be the order id. "note": "Conversation note for order IHJOID0011" // Note for the conversation. } } }
Success Response
Code: 200
Content:
{ "user": { "id": "abd32644-5be0-421b-81bd-78cb244633b8", "email": "[email protected]", "name": "API testing", "phone_number": "+12025550777", "profile_url": "http://spinkart.neetochat.com/admin/insights/abd32644-5be0-421b-81bd-78cb244633b8", /* If the request contains different conversation token, then it will create the conversation and returns the URL. If it contains the previously created conversation token then it will return the previously created conersation URL. */ "conversation_url": "http://spinkart.neetochat.com/admin/widget/inbox/all?id=9d470df9-7edb-4fd2-8861-94e0024d1bb0" } }
Error Response
Code: 422
Content:
Content:
{"errors":["User identifier can't be blank"]}
Sample Call
http://<subdomain>.neetohelp.com/api/v1/insights/users/abd32644-5be0-421b-81bd-78cb244633b8