NAV Navbar
HTTP Node.JS Python Ruby
  • Overview v1.1
  • Authentication
  • Operators
  • Visitors
  • Chats
  • Chat Events
  • Hooks
  • Events
  • Schemas
  • Javascript API
  • Overview v1.1

    Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

    Base URLs:

    Authentication

    Authentication: Bearer your-access-token-goes-here

    All API calls expect you to send a bearer token in Authentication HTTP header. For now to receive a token please contact us at [email protected], later we are planning to allow bearer token retrieval from within our app. You can test your bearer token by sending a GET request to /me.json endpoint.

    Operators

    Operators API provides access to your team members.

    List Operators

    Code samples

    GET https://app.chaport.com/api/v1/operators HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/operators',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/operators', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/operators',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /operators

    Retrieves all existing operators

    Example responses

    {
      "result": [
        {
          "id": "59747c3ff77948220136b7b3",
          "email": "[email protected]",
          "name": "Jon Snow",
          "language": "en",
          "jobTitle": "The Wall supervisor",
          "role": "operator",
          "lastLoginAt": "2017-10-03T10:47:31.873Z",
          "lastActivityAt": "2017-10-03T10:47:31.873Z",
          "image": "string",
          "lastStatus": "online",
          "realStatus": "online"
        }
      ]
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result [Operator] true Contains entities matching the request criteria
    » id string true Operator ID
    » email string(email) true Email address of the operator
    » name string true Name of the operator
    » language string true Language of app interface
    » jobTitle string false Job title of the operator
    » role string true 'operator' - generic operator role, 'admin' - operator with advanced administrative permissions
    » lastLoginAt string(date-time) false Time of last login
    » lastActivityAt string(date-time) false Time of the most recent activity
    » image string false Profile image of the operator
    » lastStatus string false Status of the operator as it was last set manually or automatically
    » realStatus string false Real status of the operator taking operator Online presence into consideration

    Create an Operator

    Code samples

    POST https://app.chaport.com/api/v1/operators HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    Accept: application/json
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "email": "[email protected]",
      "name": "Jon Snow",
      "language": "en",
      "jobTitle": "The Wall supervisor",
      "role": "operator"
    }';
    const headers = {
      'Content-Type':'application/json',
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/operators',
    {
      method: 'POST',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
    
    r = requests.post('https://app.chaport.com/api/v1/operators', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json',
      'Accept' => 'application/json'
    }
    
    result = RestClient.post 'https://app.chaport.com/api/v1/operators',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST /operators

    Creates a new operator.

    Body parameter

    {
      "email": "[email protected]",
      "name": "Jon Snow",
      "language": "en",
      "jobTitle": "The Wall supervisor",
      "role": "operator"
    }
    

    Parameters

    Parameter In Type Required Description
    body body Operator true Request body
    » email body string(email) true Email address of the operator
    » name body string true Name of the operator
    » language body string true Language of app interface
    » jobTitle body string false Job title of the operator
    » role body string true 'operator' - generic operator role, 'admin' - operator with advanced administrative permissions

    Example responses

    {
      "id": "string",
      "created": true
    }
    

    Responses

    Status Meaning Description
    200 OK No description
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    id string true Contains an id of an entity
    created boolean true Whether the entity has been created or not

    Retrieve an Operator

    Code samples

    GET https://app.chaport.com/api/v1/operators/:operatorId HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/operators/:operatorId',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/operators/:operatorId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/operators/:operatorId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /operators/:operatorId

    Retrieves a single operator by id

    Parameters

    Parameter In Type Required Description
    operatorId path string true ID of the operator to be retrieved

    Example responses

    {
      "result": {
        "id": "59747c3ff77948220136b7b3",
        "email": "[email protected]",
        "name": "Jon Snow",
        "language": "en",
        "jobTitle": "The Wall supervisor",
        "role": "operator",
        "lastLoginAt": "2017-10-03T10:47:31.873Z",
        "lastActivityAt": "2017-10-03T10:47:31.873Z",
        "image": "string",
        "lastStatus": "online",
        "realStatus": "online"
      }
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result Operator true Contains an entity matching request's criteria
    » id string true Operator ID
    » email string(email) true Email address of the operator
    » name string true Name of the operator
    » language string true Language of app interface
    » jobTitle string false Job title of the operator
    » role string true 'operator' - generic operator role, 'admin' - operator with advanced administrative permissions
    » lastLoginAt string(date-time) false Time of last login
    » lastActivityAt string(date-time) false Time of the most recent activity
    » image string false Profile image of the operator
    » lastStatus string false Status of the operator as it was last set manually or automatically
    » realStatus string false Real status of the operator taking operator Online presence into consideration

    Update an Operator

    Code samples

    PUT https://app.chaport.com/api/v1/operators/:operatorId HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    Accept: application/json
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "email": "[email protected]",
      "name": "Jon Snow",
      "language": "en",
      "jobTitle": "The Wall supervisor",
      "role": "operator"
    }';
    const headers = {
      'Content-Type':'application/json',
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/operators/:operatorId',
    {
      method: 'PUT',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
    
    r = requests.put('https://app.chaport.com/api/v1/operators/:operatorId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json',
      'Accept' => 'application/json'
    }
    
    result = RestClient.put 'https://app.chaport.com/api/v1/operators/:operatorId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    PUT /operators/:operatorId

    Updates an operator

    Body parameter

    {
      "email": "[email protected]",
      "name": "Jon Snow",
      "language": "en",
      "jobTitle": "The Wall supervisor",
      "role": "operator"
    }
    

    Parameters

    Parameter In Type Required Description
    operatorId path string true ID of the operator to be updated
    body body Operator true Request body
    » email body string(email) true Email address of the operator
    » name body string true Name of the operator
    » language body string true Language of app interface
    » jobTitle body string false Job title of the operator
    » role body string true 'operator' - generic operator role, 'admin' - operator with advanced administrative permissions

    Example responses

    {
      "updated": true
    }
    

    Responses

    Status Meaning Description
    200 OK No description
    400 Bad Request Invalid or missing parameters in the request, more details in the response body
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    updated boolean true Whether the entity has been updated or not

    Delete an Operator

    Code samples

    DELETE https://app.chaport.com/api/v1/operators/:operatorId HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/operators/:operatorId',
    {
      method: 'DELETE',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.delete('https://app.chaport.com/api/v1/operators/:operatorId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.delete 'https://app.chaport.com/api/v1/operators/:operatorId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    DELETE /operators/:operatorId

    Deletes an operator

    Parameters

    Parameter In Type Required Description
    operatorId path string true ID of the operator to be deleted

    Example responses

    {
      "deleted": true
    }
    

    Responses

    Status Meaning Description
    200 OK No description
    400 Bad Request Invalid or missing parameters in the request, more details in the response body
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    deleted boolean true Whether the entity has been deleted or not

    Visitors

    Visitors API provides access to the data of your site visitors you conversed with.

    List Visitors

    Code samples

    GET https://app.chaport.com/api/v1/visitors?page=2 HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/visitors?page=2',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/visitors', params={
      'page': 2
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/visitors',
      params: {
      'page' => 'integer'
    }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /visitors

    Retrieves a list of visitors (ordered by date of the last chat from most recent to least)

    Parameters

    Parameter In Type Required Description
    page query integer true Results page number

    Example responses

    {
      "result": [
        {
          "id": "59747c3ff77948220136b7cd",
          "sourceHost": "example.com",
          "name": "London #1399",
          "language": "en",
          "lastSeen": "2017-10-03T10:47:31.873Z",
          "email": "[email protected]",
          "location": "United Kingdom, London",
          "custom": {},
          "consents": {
            "emailMarketing": true
          },
          "phone": "+44 (111) 111 11 11",
          "notes": "Asked us to notify him when the Others come. What is he talking about?",
          "utm": {
            "source": "string",
            "medium": "string",
            "term": "string",
            "campaign": "string",
            "content": "string"
          },
          "browser": {
            "name": "Chrome",
            "version": "67.0.3396.69"
          },
          "os": {
            "name": "OS X",
            "version": "10.13"
          }
        }
      ],
      "links": {
        "next": "string",
        "prev": "string"
      }
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result [Visitor] true Contains one page of entities
    » id string true Visitor ID
    » sourceHost string false Website where the chat widget is installed
    » name string false Name of the visitor. Initally name is likely to include identified geolocation and a visitor number. However if ip geolocation is unsuccessful, name may be an integer representing a visitor number only
    » language string false Reflects the language of widget UI of this visitor
    » lastSeen string(date-time) false Time when the visitor was last seen
    » email string(email) false Email address of the visitor
    » location string false Identified geo location that may include country and city (if available)
    » custom object false Can contain any custom data you want to be associated with the visitor. This data is displayed in visitor's info panel along with other information
    » consents object false Stores information of what consents have been received from the visitor
    »» emailMarketing boolean false Stores information of what consents have been received from the visitor
    » phone string false An unformatted phone number
    » notes string false Visitor-related notes left by operators
    » utm object false UTM parameters associated with the visitor
    »» source string false UTM parameters associated with the visitor
    »» medium string false UTM parameters associated with the visitor
    »» term string false UTM parameters associated with the visitor
    »» campaign string false UTM parameters associated with the visitor
    »» content string false UTM parameters associated with the visitor
    » browser object false Browser information
    »» name string false Browser information
    »» version string false Browser information
    » os object false OS information
    »» name string false OS information
    »» version string false OS information
    links object false Urls for next and previous page requests
    » next string false Relative link to a next page of results if available
    » prev string false Relative link to a previous page of results if available

    Retrieve a Visitor

    Code samples

    GET https://app.chaport.com/api/v1/visitors/:visitorId HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/visitors/:visitorId',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/visitors/:visitorId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/visitors/:visitorId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /visitors/:visitorId

    Retrieves a visitor by id

    Parameters

    Parameter In Type Required Description
    visitorId path string true ID of the visitor to be retrieved

    Example responses

    {
      "result": {
        "id": "59747c3ff77948220136b7cd",
        "sourceHost": "example.com",
        "name": "London #1399",
        "language": "en",
        "lastSeen": "2017-10-03T10:47:31.873Z",
        "email": "[email protected]",
        "location": "United Kingdom, London",
        "custom": {},
        "consents": {
          "emailMarketing": true
        },
        "phone": "+44 (111) 111 11 11",
        "notes": "Asked us to notify him when the Others come. What is he talking about?",
        "utm": {
          "source": "string",
          "medium": "string",
          "term": "string",
          "campaign": "string",
          "content": "string"
        },
        "browser": {
          "name": "Chrome",
          "version": "67.0.3396.69"
        },
        "os": {
          "name": "OS X",
          "version": "10.13"
        }
      }
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result Visitor true Contains an entity matching request's criteria
    » id string true Visitor ID
    » sourceHost string false Website where the chat widget is installed
    » name string false Name of the visitor. Initally name is likely to include identified geolocation and a visitor number. However if ip geolocation is unsuccessful, name may be an integer representing a visitor number only
    » language string false Reflects the language of widget UI of this visitor
    » lastSeen string(date-time) false Time when the visitor was last seen
    » email string(email) false Email address of the visitor
    » location string false Identified geo location that may include country and city (if available)
    » custom object false Can contain any custom data you want to be associated with the visitor. This data is displayed in visitor's info panel along with other information
    » consents object false Stores information of what consents have been received from the visitor
    »» emailMarketing boolean false Stores information of what consents have been received from the visitor
    » phone string false An unformatted phone number
    » notes string false Visitor-related notes left by operators
    » utm object false UTM parameters associated with the visitor
    »» source string false UTM parameters associated with the visitor
    »» medium string false UTM parameters associated with the visitor
    »» term string false UTM parameters associated with the visitor
    »» campaign string false UTM parameters associated with the visitor
    »» content string false UTM parameters associated with the visitor
    » browser object false Browser information
    »» name string false Browser information
    »» version string false Browser information
    » os object false OS information
    »» name string false OS information
    »» version string false OS information

    Update a Visitor

    Code samples

    PUT https://app.chaport.com/api/v1/visitors/:visitorId HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    Accept: application/json
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "sourceHost": "example.com",
      "name": "London #1399",
      "lastSeen": "2017-10-03T10:47:31.873Z",
      "email": "[email protected]",
      "custom": {},
      "consents": {
        "emailMarketing": true
      },
      "phone": "+44 (111) 111 11 11",
      "notes": "Asked us to notify him when the Others come. What is he talking about?",
      "utm": {
        "source": "string",
        "medium": "string",
        "term": "string",
        "campaign": "string",
        "content": "string"
      }
    }';
    const headers = {
      'Content-Type':'application/json',
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/visitors/:visitorId',
    {
      method: 'PUT',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
    
    r = requests.put('https://app.chaport.com/api/v1/visitors/:visitorId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json',
      'Accept' => 'application/json'
    }
    
    result = RestClient.put 'https://app.chaport.com/api/v1/visitors/:visitorId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    PUT /visitors/:visitorId

    Updates a visitor, response contains an updated visitor data

    Body parameter

    {
      "sourceHost": "example.com",
      "name": "London #1399",
      "lastSeen": "2017-10-03T10:47:31.873Z",
      "email": "[email protected]",
      "custom": {},
      "consents": {
        "emailMarketing": true
      },
      "phone": "+44 (111) 111 11 11",
      "notes": "Asked us to notify him when the Others come. What is he talking about?",
      "utm": {
        "source": "string",
        "medium": "string",
        "term": "string",
        "campaign": "string",
        "content": "string"
      }
    }
    

    Parameters

    Parameter In Type Required Description
    visitorId path string true ID of the visitor to be updated
    body body Visitor true Request body
    » sourceHost body string false Website where the chat widget is installed
    » name body string false Name of the visitor. Initally name is likely to include identified geolocation and a visitor number. However if ip geolocation is unsuccessful, name may be an integer representing a visitor number only
    » lastSeen body string(date-time) false Time when the visitor was last seen
    » email body string(email) false Email address of the visitor
    » custom body object false Can contain any custom data you want to be associated with the visitor. This data is displayed in visitor's info panel along with other information
    » consents body object false Stores information of what consents have been received from the visitor
    »» emailMarketing body boolean false Stores information of what consents have been received from the visitor
    » phone body string false An unformatted phone number
    » notes body string false Visitor-related notes left by operators
    » utm body object false UTM parameters associated with the visitor
    »» source body string false UTM parameters associated with the visitor
    »» medium body string false UTM parameters associated with the visitor
    »» term body string false UTM parameters associated with the visitor
    »» campaign body string false UTM parameters associated with the visitor
    »» content body string false UTM parameters associated with the visitor

    Example responses

    {
      "updated": {
        "id": "59747c3ff77948220136b7cd",
        "sourceHost": "example.com",
        "name": "London #1399",
        "language": "en",
        "lastSeen": "2017-10-03T10:47:31.873Z",
        "email": "[email protected]",
        "location": "United Kingdom, London",
        "custom": {},
        "consents": {
          "emailMarketing": true
        },
        "phone": "+44 (111) 111 11 11",
        "notes": "Asked us to notify him when the Others come. What is he talking about?",
        "utm": {
          "source": "string",
          "medium": "string",
          "term": "string",
          "campaign": "string",
          "content": "string"
        },
        "browser": {
          "name": "Chrome",
          "version": "67.0.3396.69"
        },
        "os": {
          "name": "OS X",
          "version": "10.13"
        }
      }
    }
    

    Responses

    Status Meaning Description
    200 OK Successfully updated, resulting object is returned in response
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    updated Visitor true Contains the body of an updated entity
    » id string true Visitor ID
    » sourceHost string false Website where the chat widget is installed
    » name string false Name of the visitor. Initally name is likely to include identified geolocation and a visitor number. However if ip geolocation is unsuccessful, name may be an integer representing a visitor number only
    » language string false Reflects the language of widget UI of this visitor
    » lastSeen string(date-time) false Time when the visitor was last seen
    » email string(email) false Email address of the visitor
    » location string false Identified geo location that may include country and city (if available)
    » custom object false Can contain any custom data you want to be associated with the visitor. This data is displayed in visitor's info panel along with other information
    » consents object false Stores information of what consents have been received from the visitor
    »» emailMarketing boolean false Stores information of what consents have been received from the visitor
    » phone string false An unformatted phone number
    » notes string false Visitor-related notes left by operators
    » utm object false UTM parameters associated with the visitor
    »» source string false UTM parameters associated with the visitor
    »» medium string false UTM parameters associated with the visitor
    »» term string false UTM parameters associated with the visitor
    »» campaign string false UTM parameters associated with the visitor
    »» content string false UTM parameters associated with the visitor
    » browser object false Browser information
    »» name string false Browser information
    »» version string false Browser information
    » os object false OS information
    »» name string false OS information
    »» version string false OS information

    Delete a Visitor

    Code samples

    DELETE https://app.chaport.com/api/v1/visitors/:visitorId HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/visitors/:visitorId',
    {
      method: 'DELETE',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.delete('https://app.chaport.com/api/v1/visitors/:visitorId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.delete 'https://app.chaport.com/api/v1/visitors/:visitorId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    DELETE /visitors/:visitorId

    Deletes a visitor along with their chats

    Parameters

    Parameter In Type Required Description
    visitorId path string true ID of the visitor to be deleted

    Example responses

    {
      "deleted": true
    }
    

    Responses

    Status Meaning Description
    200 OK No description
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    deleted boolean true Whether the entity has been deleted or not

    Chats

    Chat API provides access to your conversations.

    Retrieve a last Chat

    Code samples

    GET https://app.chaport.com/api/v1/visitors/:visitorId/chats HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/visitors/:visitorId/chats',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/visitors/:visitorId/chats', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/visitors/:visitorId/chats',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /visitors/:visitorId/chats

    Retrieves the last chat of a given visitor

    Parameters

    Parameter In Type Required Description
    visitorId path string true ID of the visitor
    eventTypes query array false An array of event types to be included in the response. Ignored if transcript is requested
    transcript query boolean false Pass true to retrieve chat events as a transcript. Only includes message events.

    Example responses

    {
      "result": {
        "id": 120904824,
        "startedAt": "2017-10-03T10:47:31.873Z",
        "initiator": "visitor",
        "events": [
          {
            "type": "string",
            "timestamp": "2018-09-05T03:44:48Z"
          }
        ],
        "stage": "engaged",
        "operators": [
          "123894abc958123894abc958"
        ]
      },
      "links": {
        "more": [
          "string"
        ]
      }
    }
    
    {
      "links": {
        "more": [
          "string"
        ]
      }
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result Chat true Contains an entity matching request's criteria
    » id integer false Chat ID
    » startedAt string(date-time) false Time when the chat was started
    » initiator string false Initiator of the chat
    » events [ChatEvent] false No description
    »» type string true No description
    »» timestamp string(date-time) true No description
    » stage string false Indicates the stage at which this chat currently is. 'initiated' - visitor started a chat, but no one replied; 'responded' - operator replied after visitor started a chat, but dialog has not progressed further; 'invited manually' - operator initiated a chat, but visitor did not reply; 'engaged' - visitor messaged after the operator either initiated a chat or replied to an initial visitor message, indicating that the visitor is successfully engaged in a conversation; 'offline' - same as 'initiated' except that all operators are offline; 'closed' - operator manually closed the chat without sending a single message.
    » operators [string] false Array of assigned Operator IDs
    links object false No description
    » more [string] false An array of relative urls to similar entities

    Response Schema

    Status Code 404

    Name Type Required Description
    links object false Urls potentially relevant to this request
    » more [string] false An array of relative urls to suggested entities

    Retrieve a Chat

    Code samples

    GET https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /visitors/:visitorId/chats/:chatId

    Retrieves a chat by given visitor ID and chat ID

    Parameters

    Parameter In Type Required Description
    visitorId path string true ID of the visitor
    chatId path string true ID of the chat
    eventTypes query array false An array of event types to be included in the response. Ignored if transcript is requested
    transcript query boolean false Pass true to retrieve chat events as a transcript. Only includes message events.

    Example responses

    {
      "result": {
        "id": 120904824,
        "startedAt": "2017-10-03T10:47:31.873Z",
        "initiator": "visitor",
        "events": [
          {
            "type": "string",
            "timestamp": "2018-09-05T03:44:48Z"
          }
        ],
        "stage": "engaged",
        "operators": [
          "123894abc958123894abc958"
        ]
      },
      "links": {
        "more": [
          "string"
        ]
      }
    }
    
    {
      "links": {
        "more": [
          "string"
        ]
      }
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result Chat true Contains an entity matching request's criteria
    » id integer false Chat ID
    » startedAt string(date-time) false Time when the chat was started
    » initiator string false Initiator of the chat
    » events [ChatEvent] false No description
    »» type string true No description
    »» timestamp string(date-time) true No description
    » stage string false Indicates the stage at which this chat currently is. 'initiated' - visitor started a chat, but no one replied; 'responded' - operator replied after visitor started a chat, but dialog has not progressed further; 'invited manually' - operator initiated a chat, but visitor did not reply; 'engaged' - visitor messaged after the operator either initiated a chat or replied to an initial visitor message, indicating that the visitor is successfully engaged in a conversation; 'offline' - same as 'initiated' except that all operators are offline; 'closed' - operator manually closed the chat without sending a single message.
    » operators [string] false Array of assigned Operator IDs
    links object false No description
    » more [string] false An array of relative urls to similar entities

    Response Schema

    Status Code 404

    Name Type Required Description
    links object false Urls potentially relevant to this request
    » more [string] false An array of relative urls to suggested entities

    Chat Events

    Chat events API allows you to send messages on behalf visitors, and opens up the possibility of integrating Chaport with any chat bot of your choice.

    Create a Chat Event

    Code samples

    POST https://app.chaport.com/api/v1/chat-events HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    Accept: application/json
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "source": "facebook",
      "senderId": "12378421",
      "chatEvent": {
        "type": "operator-message",
        "params": {
          "text": "Help is coming!",
          "operatorId": "123abc123abc123abc123abc"
        }
      }
    }';
    const headers = {
      'Content-Type':'application/json',
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/chat-events',
    {
      method: 'POST',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
    
    r = requests.post('https://app.chaport.com/api/v1/chat-events', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json',
      'Accept' => 'application/json'
    }
    
    result = RestClient.post 'https://app.chaport.com/api/v1/chat-events',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST /chat-events

    Creates a chat event, creates a visitor if it doesn't exist yet and may create a chat if necessary

    Body parameter

    {
      "source": "facebook",
      "senderId": "12378421",
      "chatEvent": {
        "type": "operator-message",
        "params": {
          "text": "Help is coming!",
          "operatorId": "123abc123abc123abc123abc"
        }
      }
    }
    

    Parameters

    Parameter In Type Required Description
    body body object false No description
    » source body string true The platform, which visitor is coming from.
    » senderId body string true Visitor's ID within source platform
    » chatEvent body ChatEvent true Operator and visitor message chat events are supported

    Example responses

    {
      "id": "string",
      "created": true,
      "visitor": {
        "id": "string",
        "created": true
      },
      "chat": {
        "id": 0,
        "created": true
      }
    }
    

    Responses

    Status Meaning Description
    200 OK No description
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    id string true No description
    created boolean false No description
    visitor object false No description
    » id string false No description
    » created boolean false No description
    chat object false No description
    » id integer false No description
    » created boolean false No description

    List Chat Events

    Code samples

    GET https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /visitors/:visitorId/chats/:chatId/events

    Retrieves all chat events from a requested chat

    Example responses

    {
      "result": [
        {
          "type": "string",
          "timestamp": "2018-09-05T03:44:48Z"
        }
      ]
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result [ChatEvent] true Contains entities matching the request criteria
    » type string true No description
    » timestamp string(date-time) true No description

    Retrieve a Chat Event

    Code samples

    GET https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events/:eventId HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events/:eventId',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events/:eventId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events/:eventId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /visitors/:visitorId/chats/:chatId/events/:eventId

    Retrieves a chat event

    Example responses

    {
      "result": {
        "type": "string",
        "timestamp": "2018-09-05T03:44:48Z"
      }
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result ChatEvent true Contains an entity matching request's criteria
    » type string true Contains an entity matching request's criteria
    » timestamp string(date-time) true Contains an entity matching request's criteria

    Hooks

    Chaport can notify your application when certain events happen. Hooks API allows you to view your event subscriptions, subscribe to these events (i.e.create hooks), unsubscribe from them or update your subscriptions.

    List REST Hooks

    Code samples

    GET https://app.chaport.com/api/v1/events/subscriptions HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/events/subscriptions',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/events/subscriptions', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/events/subscriptions',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /events/subscriptions

    Retrieves a list of existing REST hook event subscriptions

    Example responses

    {
      "result": [
        {
          "id": "59747c3ff77948220136b7aa",
          "targetUrl": "http://your-server.com/notify",
          "event": "chat.started",
          "createdAt": "2017-10-12T10:47:31.873Z"
        }
      ]
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result [Hook] true Contains entities matching the request criteria
    » id string false Event Subscription ID
    » targetUrl string true URL to which event notifications are sent
    » event string true Name of the event related to this subscription
    » createdAt string(date-time) false Time the subscription has been created

    Create a Hook

    Code samples

    POST https://app.chaport.com/api/v1/events/subscriptions HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    Accept: application/json
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "targetUrl": "http://your-server.com/notify",
      "event": "chat.started"
    }';
    const headers = {
      'Content-Type':'application/json',
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/events/subscriptions',
    {
      method: 'POST',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
    
    r = requests.post('https://app.chaport.com/api/v1/events/subscriptions', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json',
      'Accept' => 'application/json'
    }
    
    result = RestClient.post 'https://app.chaport.com/api/v1/events/subscriptions',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST /events/subscriptions

    Creates a new REST hook event subscription

    Body parameter

    {
      "targetUrl": "http://your-server.com/notify",
      "event": "chat.started"
    }
    

    Parameters

    Parameter In Type Required Description
    body body Hook true Request body
    » targetUrl body string true URL to which event notifications are sent
    » event body string true Name of the event related to this subscription

    Example responses

    {
      "id": "string",
      "created": true
    }
    

    Responses

    Status Meaning Description
    200 OK No description
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    id string true Contains an id of an entity
    created boolean true Whether the entity has been created or not

    Retrieve a Hook

    Code samples

    GET https://app.chaport.com/api/v1/events/subscriptions/:hookId HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/events/subscriptions/:hookId',
    {
      method: 'GET',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.get('https://app.chaport.com/api/v1/events/subscriptions/:hookId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.get 'https://app.chaport.com/api/v1/events/subscriptions/:hookId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    GET /events/subscriptions/:hookId

    Retrieves a REST hook event subscription by id

    Parameters

    Parameter In Type Required Description
    hookId path string true ID of the hook

    Example responses

    {
      "result": {
        "id": "59747c3ff77948220136b7aa",
        "targetUrl": "http://your-server.com/notify",
        "event": "chat.started",
        "createdAt": "2017-10-12T10:47:31.873Z"
      }
    }
    

    Responses

    Status Meaning Description
    200 OK Successful request
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result Hook true Contains an entity matching request's criteria
    » id string false Event Subscription ID
    » targetUrl string true URL to which event notifications are sent
    » event string true Name of the event related to this subscription
    » createdAt string(date-time) false Time the subscription has been created

    Update a Hook

    Code samples

    PUT https://app.chaport.com/api/v1/events/subscriptions/:hookId HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    Accept: application/json
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "targetUrl": "http://your-server.com/notify",
      "event": "chat.started"
    }';
    const headers = {
      'Content-Type':'application/json',
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/events/subscriptions/:hookId',
    {
      method: 'PUT',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
    
    r = requests.put('https://app.chaport.com/api/v1/events/subscriptions/:hookId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json',
      'Accept' => 'application/json'
    }
    
    result = RestClient.put 'https://app.chaport.com/api/v1/events/subscriptions/:hookId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    PUT /events/subscriptions/:hookId

    Updates a REST hook event subscription

    Body parameter

    {
      "targetUrl": "http://your-server.com/notify",
      "event": "chat.started"
    }
    

    Parameters

    Parameter In Type Required Description
    hookId path string true ID of the hook to be updated
    body body Hook true Request body
    » targetUrl body string true URL to which event notifications are sent
    » event body string true Name of the event related to this subscription

    Example responses

    {
      "updated": true
    }
    

    Responses

    Status Meaning Description
    200 OK No description
    400 Bad Request Invalid or missing parameters in the request, more details in the response body
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    updated boolean true Whether the entity has been updated or not

    Delete a Hook

    Code samples

    DELETE https://app.chaport.com/api/v1/events/subscriptions/:hookId HTTP/1.1
    Host: app.chaport.com
    
    Accept: application/json
    
    
    const request = require('node-fetch');
    
    const headers = {
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/events/subscriptions/:hookId',
    {
      method: 'DELETE',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.delete('https://app.chaport.com/api/v1/events/subscriptions/:hookId', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Accept' => 'application/json'
    }
    
    result = RestClient.delete 'https://app.chaport.com/api/v1/events/subscriptions/:hookId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    DELETE /events/subscriptions/:hookId

    Deletes a REST hook event subscription

    Parameters

    Parameter In Type Required Description
    hookId path string true ID of the hook to be deleted

    Example responses

    {
      "deleted": true
    }
    

    Responses

    Status Meaning Description
    200 OK No description
    400 Bad Request Invalid or missing parameters in the request, more details in the response body
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    deleted boolean true Whether the entity has been deleted or not

    Events

    Notify when Chat Started

    Code samples

    POST {$Create a Hook.request.body.targetUrl} HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "link": "string",
      "extras": {}
    }';
    const headers = {
      'Content-Type':'application/json'
    
    };
    
    fetch('{$Create a Hook.request.body.targetUrl}',
    {
      method: 'POST',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json'
    }
    
    r = requests.post('{$Create a Hook.request.body.targetUrl}', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json'
    }
    
    result = RestClient.post '{$Create a Hook.request.body.targetUrl}',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST {$Create a Hook.request.body.targetUrl}

    "chat.started": this event fires when a new chat is started.

    Please note, that if the chat is renewed (one of participants sends a new message shortly after the chat was marked as finished) this event will not fire again.

    Body parameter

    {
      "link": "string",
      "extras": {}
    }
    

    Parameters

    Parameter In Type Required Description
    body body object true Notification request body
    » link body string true A relative API request url, sending a GET request to which would return the related chat entity
    » extras body object false Provides any additional context

    Responses

    Status Meaning Description

    Notify when Chat Finished

    Code samples

    POST {$Create a Hook.request.body.targetUrl} HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "link": "string",
      "extras": {}
    }';
    const headers = {
      'Content-Type':'application/json'
    
    };
    
    fetch('{$Create a Hook.request.body.targetUrl}',
    {
      method: 'POST',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json'
    }
    
    r = requests.post('{$Create a Hook.request.body.targetUrl}', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json'
    }
    
    result = RestClient.post '{$Create a Hook.request.body.targetUrl}',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST {$Create a Hook.request.body.targetUrl}

    "chat.finished": this event fires after a chat is idle for about 10 minutes.

    Please note, that any chat can be renewed (or restarted) shortly after it was finished, consequently this event may fire multiple times for some chats.

    Body parameter

    {
      "link": "string",
      "extras": {}
    }
    

    Parameters

    Parameter In Type Required Description
    body body object true Notification request body
    » link body string true A relative API request url, sending a GET request to which would return the related chat entity
    » extras body object false Provides any additional context

    Responses

    Status Meaning Description

    Notify when Visitor Created

    Code samples

    POST {$Create a Hook.request.body.targetUrl} HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "link": "string",
      "extras": {}
    }';
    const headers = {
      'Content-Type':'application/json'
    
    };
    
    fetch('{$Create a Hook.request.body.targetUrl}',
    {
      method: 'POST',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json'
    }
    
    r = requests.post('{$Create a Hook.request.body.targetUrl}', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json'
    }
    
    result = RestClient.post '{$Create a Hook.request.body.targetUrl}',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST {$Create a Hook.request.body.targetUrl}

    "visitor.created": this event fires when a new visitor starts a chat.

    Body parameter

    {
      "link": "string",
      "extras": {}
    }
    

    Parameters

    Parameter In Type Required Description
    body body object true Notification request body
    » link body string true A relative API request url, sending a GET request to which would return the related visitor entity
    » extras body object false Provides any additional context

    Responses

    Status Meaning Description

    Notify when Visitor Updated

    Code samples

    POST {$Create a Hook.request.body.targetUrl} HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "link": "string",
      "extras": {
        "fields": [
          "name"
        ]
      }
    }';
    const headers = {
      'Content-Type':'application/json'
    
    };
    
    fetch('{$Create a Hook.request.body.targetUrl}',
    {
      method: 'POST',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json'
    }
    
    r = requests.post('{$Create a Hook.request.body.targetUrl}', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json'
    }
    
    result = RestClient.post '{$Create a Hook.request.body.targetUrl}',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST {$Create a Hook.request.body.targetUrl}

    "visitor.updated": this event fires when one or more of the following fields gets updated: name, email, phone, notes, custom and consents.

    Extras object of notification request contains a fields property containing an array of updated fields.

    Body parameter

    {
      "link": "string",
      "extras": {
        "fields": [
          "name"
        ]
      }
    }
    

    Parameters

    Parameter In Type Required Description
    body body object true Notification request body
    » link body string true A relative API request url, sending a GET request to which would return the related visitor entity
    » extras body object false Provides any additional context
    »» fields body [string] false Contains the list of fields altered by related update/updates

    Responses

    Status Meaning Description

    Notify when Message is sent by Operator

    Code samples

    POST {$Create a Hook.request.body.targetUrl} HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "link": "string",
      "extras": {
        "operatorId": "string",
        "visitorId": "string",
        "chatId": 0
      }
    }';
    const headers = {
      'Content-Type':'application/json'
    
    };
    
    fetch('{$Create a Hook.request.body.targetUrl}',
    {
      method: 'POST',
      body: inputBody,
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Content-Type': 'application/json'
    }
    
    r = requests.post('{$Create a Hook.request.body.targetUrl}', params={
    
    }, headers = headers)
    
    print r.json()
    
    
    require 'rest-client'
    require 'json'
    
    headers = {
      'Content-Type' => 'application/json'
    }
    
    result = RestClient.post '{$Create a Hook.request.body.targetUrl}',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST {$Create a Hook.request.body.targetUrl}

    "chat.newEvent.operatorMessage": this event fires when an operator sends a message to a visitor.

    Extras object of notification request contains operatorId, visitorId and chatId.

    Body parameter

    {
      "link": "string",
      "extras": {
        "operatorId": "string",
        "visitorId": "string",
        "chatId": 0
      }
    }
    

    Parameters

    Parameter In Type Required Description
    body body object true Notification request body
    » link body string true A relative API request url, sending a GET request to which would return the related chat event entity
    » extras body object false Provides any additional context
    »» operatorId body string false ID of the operator that sent this message
    »» visitorId body string false ID of the visitor this message is sent to
    »» chatId body integer false ID of the chat this message is part of

    Responses

    Status Meaning Description

    Schemas

    Chat

    {
      "id": 120904824,
      "startedAt": "2017-10-03T10:47:31.873Z",
      "initiator": "visitor",
      "events": [
        {
          "type": "string",
          "timestamp": "2018-09-05T03:44:48Z"
        }
      ],
      "stage": "engaged",
      "operators": [
        "123894abc958123894abc958"
      ]
    } 
    

    Properties

    Name Type Required Description
    id integer false Chat ID
    startedAt string(date-time) false Time when the chat was started
    initiator string false Initiator of the chat
    events [ChatEvent] false No description
    » type string true No description
    » timestamp string(date-time) true No description
    stage string false Indicates the stage at which this chat currently is. 'initiated' - visitor started a chat, but no one replied; 'responded' - operator replied after visitor started a chat, but dialog has not progressed further; 'invited manually' - operator initiated a chat, but visitor did not reply; 'engaged' - visitor messaged after the operator either initiated a chat or replied to an initial visitor message, indicating that the visitor is successfully engaged in a conversation; 'offline' - same as 'initiated' except that all operators are offline; 'closed' - operator manually closed the chat without sending a single message.
    operators [string] false Array of assigned Operator IDs

    Hook

    {
      "id": "59747c3ff77948220136b7aa",
      "targetUrl": "http://your-server.com/notify",
      "event": "chat.started",
      "createdAt": "2017-10-12T10:47:31.873Z"
    } 
    

    Properties

    Name Type Required Description
    id string false Event Subscription ID
    targetUrl string true URL to which event notifications are sent
    event string true Name of the event related to this subscription
    createdAt string(date-time) false Time the subscription has been created

    Operator

    {
      "id": "59747c3ff77948220136b7b3",
      "email": "[email protected]",
      "name": "Jon Snow",
      "language": "en",
      "jobTitle": "The Wall supervisor",
      "role": "operator",
      "lastLoginAt": "2017-10-03T10:47:31.873Z",
      "lastActivityAt": "2017-10-03T10:47:31.873Z",
      "image": "string",
      "lastStatus": "online",
      "realStatus": "online"
    } 
    

    Properties

    Name Type Required Description
    id string true Operator ID
    email string(email) true Email address of the operator
    name string true Name of the operator
    language string true Language of app interface
    jobTitle string false Job title of the operator
    role string true 'operator' - generic operator role, 'admin' - operator with advanced administrative permissions
    lastLoginAt string(date-time) false Time of last login
    lastActivityAt string(date-time) false Time of the most recent activity
    image string false Profile image of the operator
    lastStatus string false Status of the operator as it was last set manually or automatically
    realStatus string false Real status of the operator taking operator Online presence into consideration

    Visitor

    {
      "id": "59747c3ff77948220136b7cd",
      "sourceHost": "example.com",
      "name": "London #1399",
      "language": "en",
      "lastSeen": "2017-10-03T10:47:31.873Z",
      "email": "[email protected]",
      "location": "United Kingdom, London",
      "custom": {},
      "consents": {
        "emailMarketing": true
      },
      "phone": "+44 (111) 111 11 11",
      "notes": "Asked us to notify him when the Others come. What is he talking about?",
      "utm": {
        "source": "string",
        "medium": "string",
        "term": "string",
        "campaign": "string",
        "content": "string"
      },
      "browser": {
        "name": "Chrome",
        "version": "67.0.3396.69"
      },
      "os": {
        "name": "OS X",
        "version": "10.13"
      }
    } 
    

    Properties

    Name Type Required Description
    id string true Visitor ID
    sourceHost string false Website where the chat widget is installed
    name string false Name of the visitor. Initally name is likely to include identified geolocation and a visitor number. However if ip geolocation is unsuccessful, name may be an integer representing a visitor number only
    language string false Reflects the language of widget UI of this visitor
    lastSeen string(date-time) false Time when the visitor was last seen
    email string(email) false Email address of the visitor
    location string false Identified geo location that may include country and city (if available)
    custom object false Can contain any custom data you want to be associated with the visitor. This data is displayed in visitor's info panel along with other information
    consents object false Stores information of what consents have been received from the visitor
    » emailMarketing boolean false Stores information of what consents have been received from the visitor
    phone string false An unformatted phone number
    notes string false Visitor-related notes left by operators
    utm object false UTM parameters associated with the visitor
    » source string false UTM parameters associated with the visitor
    » medium string false UTM parameters associated with the visitor
    » term string false UTM parameters associated with the visitor
    » campaign string false UTM parameters associated with the visitor
    » content string false UTM parameters associated with the visitor
    browser object false Browser information
    » name string false Browser information
    » version string false Browser information
    os object false OS information
    » name string false OS information
    » version string false OS information

    ChatEvent

    {
      "type": "string",
      "timestamp": "2018-09-05T03:44:48Z"
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description

    EmailRequestChatEvent

    {
      "type": "email-request",
      "timestamp": "2018-09-05T03:44:48Z"
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description

    FileTransferChatEvent

    {
      "type": "file-transfer",
      "timestamp": "2018-09-05T03:44:48Z"
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description

    OperatorChangeChatEvent

    {
      "type": "operator-change",
      "timestamp": "2018-09-05T03:44:48Z",
      "params": {
        "operatorId": "string",
        "targetOperatorId": "string"
      }
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description
    params object false No description
    » operatorId string false No description
    » targetOperatorId string false No description

    OperatorInviteChatEvent

    {
      "type": "operator-invite",
      "timestamp": "2018-09-05T03:44:48Z",
      "params": {
        "operatorId": "string",
        "targetOperatorId": "string"
      }
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description
    params object false No description
    » operatorId string false No description
    » targetOperatorId string false No description

    OperatorMessageChatEvent

    {
      "type": "operator-message",
      "timestamp": "2018-09-05T03:44:48Z",
      "params": {
        "text": "string",
        "operatorId": "string"
      }
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description
    params object false No description
    » text string false No description
    » operatorId string false No description

    TriggerMessageChatEvent

    {
      "type": "trigger-message",
      "timestamp": "2018-09-05T03:44:48Z",
      "params": {
        "text": "string",
        "operatorId": "string"
      }
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description
    params object false No description
    » text string false No description
    » operatorId string false No description

    VisitorMessageChatEvent

    {
      "type": "visitor-message",
      "timestamp": "2017-08-28T08:24:56.899Z",
      "params": {
        "text": "Hello! I have a question regarding your application form. Can you help me?"
      }
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description
    params object false No description
    » text string false No description

    VisitorMutedChatEvent

    {
      "type": "visitor-muted",
      "timestamp": "2018-09-05T03:44:48Z"
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description

    VisitorOpenedPageChatEvent

    {
      "type": "visitor-opened-page",
      "timestamp": "2018-09-05T03:44:48Z",
      "params": {
        "url": "string",
        "title": "string"
      }
    } 
    

    Properties

    Name Type Required Description
    type string true No description
    timestamp string(date-time) true No description
    params object false No description
    » url string false No description
    » title string false No description

    Javascript API

    Javascript API Overview

    Do you want to have more control over chat widget or want to integrate Chaport closely with your user base? Read Chaport Javascript API docs.