Subiz API

Chats

Chats Overview

{
  "id": "57399d78c556f51000fbe6ac",
String

Conversation ID

  "visitor": {
  "visitor": { ... }
Object

Visitor

    "id": "2houqq4caoo7k8iegwu1462934106805",
String

Visitor ID

    "name": "Hung Nguyen",
String

Visitor displayed name

    "email": "hung@subiz.com",
String (Email)

The visitor email ID

    "phone": "0987654321",
String

The phone number of the visitor (if available)

    "banned": 0
Integer (Int64)

Whether the visitor is currently banned or not

  },
  "type": "chat",
String

Type of conversation (offline message, chat)

  "started_by": "agent",
String

Was chat created by visitors, agent or trigger?

  "session": {
  "session": { ... }
Object

Session

    "id": "z18ADtqDjx1SnINs1KpyUHmO",
String

Session ID

    "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36",
String

User-agent

    "browser_name": "Chrome",
String

Browser Name

    "browser_version": "50.0.2661",
String

Browser Version

    "city": "Houston",
String

City Name

    "country_code": "US",
String

Country Code

    "country_name": "United States",
String

Country Name

    "ip": "98.201.104.185",
String

IP address of visitor

    "platform": "Linux",
String

OS

    "start_time": "2016-05-11T07:39:46.299Z",
String (Date-time)

Start Time

    "end_time": "2016-05-11T07:54:24.221Z"
String (Date-time)

End Time

  },
  "count": 90,
Integer (Int64)

Number of messages

  "duration": 1123,
Integer

Chat duration (seconds)

  history: [
Array

Return chat messages which are sorted by date

    {
    { ... }
Object

Event

      "type": "message",
String
      "text": "Hello",
String
      "user_type": "visitor",
String
      "time": "2016-05-11T07:40:11.482Z"
String
    }
  ]
  "tags": [
    "Shoe",
    "Watch"
  ],
Array

Tags associated with the chat

  "rating": "good",
String

Chat rating

  visited_pages: [
Array

All navigated pages of customer during chat (Applied for Subiz integrated domains only)

    {
    { ... }
Object

Page

      "time": "2016-05-16T10:14:24.57Z",
String (Date-time)
      "previous_url": "https://subiz.com/",
String (Url)
      "title": "Live chat solution for website | Free Trial | Pricing Plans",
String
      "url": "https://subiz.com/pricing.html"
String (Url)
    }
  ]
  "department": {
  "department": { ... }
Object

Department

    "id": "57306014af717600012ede78",
String

Department ID

    "name": "Marketing"
String

Department Name

  }
}

List all chats

Open in API Explorer
GET /chats

Allows an owner/administrator account to list all chats (conversation)

Example Request

Format:
curl --request GET \
  --url 'https://api.subiz.com/v1/chats?page=1&per_page=100&visitor_id=2houqq4caoo7k8iegwu1462934106805&visitor_name=Hung%2BNguyen&visitor_email=hung%2540subiz.com&visitor_phone=0987654321&chat_type=chat' \
  --header 'accept: application/json' \
  --header 'api-key: YOUR API KEY HERE'
require 'uri'
require 'net/http'

url = URI("https://api.subiz.com/v1/chats?page=1&per_page=100&visitor_id=2houqq4caoo7k8iegwu1462934106805&visitor_name=Hung%2BNguyen&visitor_email=hung%2540subiz.com&visitor_phone=0987654321&chat_type=chat")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["accept"] = 'application/json'
request["api-key"] = 'YOUR API KEY HERE'

response = http.request(request)
puts response.read_body
var http = require("https");

var options = {
  "method": "GET",
  "hostname": "api.subiz.com",
  "port": null,
  "path": "/v1/chats?page=1&per_page=100&visitor_id=2houqq4caoo7k8iegwu1462934106805&visitor_name=Hung%2BNguyen&visitor_email=hung%2540subiz.com&visitor_phone=0987654321&chat_type=chat",
  "headers": {
    "accept": "application/json",
    "api-key": "YOUR API KEY HERE"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("api.subiz.com")

headers = {
    'accept': "application/json",
    'api-key': "YOUR API KEY HERE"
    }

conn.request("GET", "/v1/chats?page=1&per_page=100&visitor_id=2houqq4caoo7k8iegwu1462934106805&visitor_name=Hung%2BNguyen&visitor_email=hung%2540subiz.com&visitor_phone=0987654321&chat_type=chat", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.subiz.com/v1/chats?page=1&per_page=100&visitor_id=2houqq4caoo7k8iegwu1462934106805&visitor_name=Hung%2BNguyen&visitor_email=hung%2540subiz.com&visitor_phone=0987654321&chat_type=chat",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "api-key: YOUR API KEY HERE"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.subiz.com/v1/chats?page=1&per_page=100&visitor_id=2houqq4caoo7k8iegwu1462934106805&visitor_name=Hung%2BNguyen&visitor_email=hung%2540subiz.com&visitor_phone=0987654321&chat_type=chat"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("accept", "application/json")
	req.Header.Add("api-key", "YOUR API KEY HERE")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Query Parameters

Name Type Required Description Example
page Integer (int64) Optional

The current page of resources.

1
per_page Integer Optional

The resources included on one page of data

100
visitor_id String Optional

Filter chats by specified visitor id

2houqq4caoo7k8iegwu1462934106805
visitor_name String Optional

Filter chats by visitor name

Hung+Nguyen
visitor_email String (email) Optional

Filter chats by visitor email

hung%40subiz.com
visitor_phone String Optional

Filter chats by visitor phone

0987654321
chat_type String Optional

Filter chats by chat type

chat

Responses

200 OK

Returns all ended chats.

Chats List chats
[
  "id": "57399d78c556f51000fbe6ac",
String

Conversation ID

  "visitor": {
  "visitor": { ... }
Object

Visitor

    "id": "2houqq4caoo7k8iegwu1462934106805",
String

Visitor ID

    "name": "Hung Nguyen",
String

Visitor displayed name

    "email": "hung@subiz.com",
String (Email)

The visitor email ID

    "phone": "0987654321",
String

The phone number of the visitor (if available)

    "banned": 0
Integer (Int64)

Whether the visitor is currently banned or not

  },
  "type": "chat",
String

Type of conversation (offline message, chat)

  "started_by": "agent",
String

Was chat created by visitors, agent or trigger?

  "session": {
  "session": { ... }
Object

Session

    "id": "z18ADtqDjx1SnINs1KpyUHmO",
String

Session ID

    "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36",
String

User-agent

    "browser_name": "Chrome",
String

Browser Name

    "browser_version": "50.0.2661",
String

Browser Version

    "city": "Houston",
String

City Name

    "country_code": "US",
String

Country Code

    "country_name": "United States",
String

Country Name

    "ip": "98.201.104.185",
String

IP address of visitor

    "platform": "Linux",
String

OS

    "start_time": "2016-05-11T07:39:46.299Z",
String (Date-time)

Start Time

    "end_time": "2016-05-11T07:54:24.221Z"
String (Date-time)

End Time

  },
  "count": 90,
Integer (Int64)

Number of messages

  "duration": 1123,
Integer

Chat duration (seconds)

  history: [
Array

Return chat messages which are sorted by date

    {
    { ... }
Object

Event

      "type": "message",
String
      "text": "Hello",
String
      "user_type": "visitor",
String
      "time": "2016-05-11T07:40:11.482Z"
String
    }
  ]
  "tags": [
    "Shoe",
    "Watch"
  ],
Array

Tags associated with the chat

  "rating": "good",
String

Chat rating

  visited_pages: [
Array

All navigated pages of customer during chat (Applied for Subiz integrated domains only)

    {
    { ... }
Object

Page

      "time": "2016-05-16T10:14:24.57Z",
String (Date-time)
      "previous_url": "https://subiz.com/",
String (Url)
      "title": "Live chat solution for website | Free Trial | Pricing Plans",
String
      "url": "https://subiz.com/pricing.html"
String (Url)
    }
  ]
  "department": {
  "department": { ... }
Object

Department

    "id": "57306014af717600012ede78",
String

Department ID

    "name": "Marketing"
String

Department Name

  }
]

Retrieve a chat

Open in API Explorer
GET /chats/{chat_id}

Fetches chat information by ID

Example Request

Format:
curl --request GET \
  --url https://api.subiz.com/v1/chats/5732e1db6a45291901c9a102 \
  --header 'accept: application/json' \
  --header 'api-key: YOUR API KEY HERE'
require 'uri'
require 'net/http'

url = URI("https://api.subiz.com/v1/chats/5732e1db6a45291901c9a102")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["accept"] = 'application/json'
request["api-key"] = 'YOUR API KEY HERE'

response = http.request(request)
puts response.read_body
var http = require("https");

var options = {
  "method": "GET",
  "hostname": "api.subiz.com",
  "port": null,
  "path": "/v1/chats/5732e1db6a45291901c9a102",
  "headers": {
    "accept": "application/json",
    "api-key": "YOUR API KEY HERE"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("api.subiz.com")

headers = {
    'accept': "application/json",
    'api-key': "YOUR API KEY HERE"
    }

conn.request("GET", "/v1/chats/5732e1db6a45291901c9a102", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.subiz.com/v1/chats/5732e1db6a45291901c9a102",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "api-key: YOUR API KEY HERE"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.subiz.com/v1/chats/5732e1db6a45291901c9a102"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("accept", "application/json")
	req.Header.Add("api-key", "YOUR API KEY HERE")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Path Parameters

Name Type Required Description Example
chat_id String (string) Required

Conversation ID

5732e1db6a45291901c9a102

Responses

200 OK

OK

Chats Chat
{
  "id": "57399d78c556f51000fbe6ac",
String

Conversation ID

  "visitor": {
  "visitor": { ... }
Object

Visitor

    "id": "2houqq4caoo7k8iegwu1462934106805",
String

Visitor ID

    "name": "Hung Nguyen",
String

Visitor displayed name

    "email": "hung@subiz.com",
String (Email)

The visitor email ID

    "phone": "0987654321",
String

The phone number of the visitor (if available)

    "banned": 0
Integer (Int64)

Whether the visitor is currently banned or not

  },
  "type": "chat",
String

Type of conversation (offline message, chat)

  "started_by": "agent",
String

Was chat created by visitors, agent or trigger?

  "session": {
  "session": { ... }
Object

Session

    "id": "z18ADtqDjx1SnINs1KpyUHmO",
String

Session ID

    "user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36",
String

User-agent

    "browser_name": "Chrome",
String

Browser Name

    "browser_version": "50.0.2661",
String

Browser Version

    "city": "Houston",
String

City Name

    "country_code": "US",
String

Country Code

    "country_name": "United States",
String

Country Name

    "ip": "98.201.104.185",
String

IP address of visitor

    "platform": "Linux",
String

OS

    "start_time": "2016-05-11T07:39:46.299Z",
String (Date-time)

Start Time

    "end_time": "2016-05-11T07:54:24.221Z"
String (Date-time)

End Time

  },
  "count": 90,
Integer (Int64)

Number of messages

  "duration": 1123,
Integer

Chat duration (seconds)

  history: [
Array

Return chat messages which are sorted by date

    {
    { ... }
Object

Event

      "type": "message",
String
      "text": "Hello",
String
      "user_type": "visitor",
String
      "time": "2016-05-11T07:40:11.482Z"
String
    }
  ]
  "tags": [
    "Shoe",
    "Watch"
  ],
Array

Tags associated with the chat

  "rating": "good",
String

Chat rating

  visited_pages: [
Array

All navigated pages of customer during chat (Applied for Subiz integrated domains only)

    {
    { ... }
Object

Page

      "time": "2016-05-16T10:14:24.57Z",
String (Date-time)
      "previous_url": "https://subiz.com/",
String (Url)
      "title": "Live chat solution for website | Free Trial | Pricing Plans",
String
      "url": "https://subiz.com/pricing.html"
String (Url)
    }
  ]
  "department": {
  "department": { ... }
Object

Department

    "id": "57306014af717600012ede78",
String

Department ID

    "name": "Marketing"
String

Department Name

  }
}

Delete a chat

Open in API Explorer
DELETE /chats/{chat_id}

Lets an agent delete a chat.

Example Request

Format:
curl --request DELETE \
  --url https://api.subiz.com/v1/chats/5732e1db6a45291901c9a102 \
  --header 'accept: application/json' \
  --header 'api-key: YOUR API KEY HERE'
require 'uri'
require 'net/http'

url = URI("https://api.subiz.com/v1/chats/5732e1db6a45291901c9a102")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Delete.new(url)
request["accept"] = 'application/json'
request["api-key"] = 'YOUR API KEY HERE'

response = http.request(request)
puts response.read_body
var http = require("https");

var options = {
  "method": "DELETE",
  "hostname": "api.subiz.com",
  "port": null,
  "path": "/v1/chats/5732e1db6a45291901c9a102",
  "headers": {
    "accept": "application/json",
    "api-key": "YOUR API KEY HERE"
  }
};

var req = http.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
import http.client

conn = http.client.HTTPSConnection("api.subiz.com")

headers = {
    'accept': "application/json",
    'api-key': "YOUR API KEY HERE"
    }

conn.request("DELETE", "/v1/chats/5732e1db6a45291901c9a102", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.subiz.com/v1/chats/5732e1db6a45291901c9a102",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "api-key: YOUR API KEY HERE"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"net/http"
	"io/ioutil"
)

func main() {

	url := "https://api.subiz.com/v1/chats/5732e1db6a45291901c9a102"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("accept", "application/json")
	req.Header.Add("api-key", "YOUR API KEY HERE")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}

Path Parameters

Name Type Required Description Example
chat_id String (string) Required

Conversation ID

5732e1db6a45291901c9a102

Responses

204 No Content

Successfully deleted the Chat

(Empty Response)