Subiz API

Webhooks

Webhooks Overview

{
  "event_name": "chat_ended",
String

Event Name

  "url": "https://www.yourdomain.com/subiz_callback.php",
String (Url)

Callback URL

  "secret": "mysecret",
String

Secret Key

  "created_at": "2016-05-20T02:45:46.920Z"
String (Date-time)

Creation date of the webhook

}

List all webhooks

Open in API Explorer
GET /webhooks

Example Request

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

url = URI("https://api.subiz.com/v1/webhooks")

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/webhooks",
  "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/webhooks", 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/webhooks",
  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/webhooks"

	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))

}

Responses

200 Success

OK

Webhooks List webhooks
[
  "event_name": "chat_ended",
String

Event Name

  "url": "https://www.yourdomain.com/subiz_callback.php",
String (Url)

Callback URL

  "secret": "mysecret",
String

Secret Key

  "created_at": "2016-05-20T02:45:46.920Z"
String (Date-time)

Creation date of the webhook

]

Create a webhook

Open in API Explorer
POST /webhooks

Example Request

Format:
curl --request POST \
  --url https://api.subiz.com/v1/webhooks \
  --header 'accept: application/json' \
  --header 'api-key: YOUR API KEY HERE' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form event_name=offline_message \
  --form url=https://www.yourdomain.com/subiz_callback.php \
  --form secret=mysecret
require 'uri'
require 'net/http'

url = URI("https://api.subiz.com/v1/webhooks")

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

request = Net::HTTP::Post.new(url)
request["accept"] = 'application/json'
request["api-key"] = 'YOUR API KEY HERE'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"event_name\"\r\n\r\noffline_message\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n"

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

var options = {
  "method": "POST",
  "hostname": "api.subiz.com",
  "port": null,
  "path": "/v1/webhooks",
  "headers": {
    "accept": "application/json",
    "api-key": "YOUR API KEY HERE",
    "content-type": "multipart/form-data; boundary=---011000010111000001101001"
  }
};

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.write("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"event_name\"\r\n\r\noffline_message\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n");
req.end();
import http.client

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

payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"event_name\"\r\n\r\noffline_message\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n"

headers = {
    'accept': "application/json",
    'api-key': "YOUR API KEY HERE",
    'content-type': "multipart/form-data; boundary=---011000010111000001101001"
    }

conn.request("POST", "/v1/webhooks", payload, 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/webhooks",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"event_name\"\r\n\r\noffline_message\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "api-key: YOUR API KEY HERE",
    "content-type: multipart/form-data; boundary=---011000010111000001101001"
  ),
));

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

curl_close($curl);

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

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

func main() {

	url := "https://api.subiz.com/v1/webhooks"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"event_name\"\r\n\r\noffline_message\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("accept", "application/json")
	req.Header.Add("api-key", "YOUR API KEY HERE")
	req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")

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

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

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

}

Form Data Parameters

Name Type Required Description Example
event_name String Required

Event Name

offline_message
url String (url) Required

Callback URL

https://www.yourdomain.com/subiz_callback.php
secret String Required

Secret key

mysecret

Responses

201 Success

Created

Webhooks Webhook
{
  "event_name": "chat_ended",
String

Event Name

  "url": "https://www.yourdomain.com/subiz_callback.php",
String (Url)

Callback URL

  "secret": "mysecret",
String

Secret Key

  "created_at": "2016-05-20T02:45:46.920Z"
String (Date-time)

Creation date of the webhook

}

Retrieve a webhook

Open in API Explorer
GET /webhooks/{event_name}

Example Request

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

url = URI("https://api.subiz.com/v1/webhooks/chat_ended")

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/webhooks/chat_ended",
  "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/webhooks/chat_ended", 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/webhooks/chat_ended",
  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/webhooks/chat_ended"

	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
event_name String Required

Event Name

chat_ended

Responses

200 Success

OK

Webhooks Webhook
{
  "event_name": "chat_ended",
String

Event Name

  "url": "https://www.yourdomain.com/subiz_callback.php",
String (Url)

Callback URL

  "secret": "mysecret",
String

Secret Key

  "created_at": "2016-05-20T02:45:46.920Z"
String (Date-time)

Creation date of the webhook

}

Update a webhook

Open in API Explorer
PUT /webhooks/{event_name}

Example Request

Format:
curl --request PUT \
  --url 'https://api.subiz.com/v1/webhooks/%7Bevent_name%7D?event_name=chat_ended' \
  --header 'accept: application/json' \
  --header 'api-key: YOUR API KEY HERE' \
  --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
  --form url=https://www.yourdomain.com/subiz_callback.php \
  --form secret=mysecret
require 'uri'
require 'net/http'

url = URI("https://api.subiz.com/v1/webhooks/%7Bevent_name%7D?event_name=chat_ended")

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

request = Net::HTTP::Put.new(url)
request["accept"] = 'application/json'
request["api-key"] = 'YOUR API KEY HERE'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n"

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

var options = {
  "method": "PUT",
  "hostname": "api.subiz.com",
  "port": null,
  "path": "/v1/webhooks/%7Bevent_name%7D?event_name=chat_ended",
  "headers": {
    "accept": "application/json",
    "api-key": "YOUR API KEY HERE",
    "content-type": "multipart/form-data; boundary=---011000010111000001101001"
  }
};

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.write("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n");
req.end();
import http.client

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

payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n"

headers = {
    'accept': "application/json",
    'api-key': "YOUR API KEY HERE",
    'content-type': "multipart/form-data; boundary=---011000010111000001101001"
    }

conn.request("PUT", "/v1/webhooks/%7Bevent_name%7D?event_name=chat_ended", payload, 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/webhooks/%7Bevent_name%7D?event_name=chat_ended",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n",
  CURLOPT_HTTPHEADER => array(
    "accept: application/json",
    "api-key: YOUR API KEY HERE",
    "content-type: multipart/form-data; boundary=---011000010111000001101001"
  ),
));

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

curl_close($curl);

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

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

func main() {

	url := "https://api.subiz.com/v1/webhooks/%7Bevent_name%7D?event_name=chat_ended"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"url\"\r\n\r\nhttps://www.yourdomain.com/subiz_callback.php\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"secret\"\r\n\r\nmysecret\r\n-----011000010111000001101001--\r\n")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("accept", "application/json")
	req.Header.Add("api-key", "YOUR API KEY HERE")
	req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")

	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
event_name String Required

Event Name

chat_ended

Form Data Parameters

Name Type Required Description Example
url String (url) Optional

Callback URL

https://www.yourdomain.com/subiz_callback.php
secret String Optional

Secret Key

mysecret

Responses

200 Success

OK

Webhooks Webhook
{
  "event_name": "chat_ended",
String

Event Name

  "url": "https://www.yourdomain.com/subiz_callback.php",
String (Url)

Callback URL

  "secret": "mysecret",
String

Secret Key

  "created_at": "2016-05-20T02:45:46.920Z"
String (Date-time)

Creation date of the webhook

}

Delete a webhook

Open in API Explorer
DELETE /webhooks/{event_name}

Example Request

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

url = URI("https://api.subiz.com/v1/webhooks/chat_ended")

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/webhooks/chat_ended",
  "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/webhooks/chat_ended", 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/webhooks/chat_ended",
  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/webhooks/chat_ended"

	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
event_name String Required

Event Name

chat_ended

Responses

204 Success

Webhook deleted successful

(Empty Response)