NAV Navbar
HTTP Node.JS Python Ruby
  • Overview v1.1
  • Authentication
  • Operators
  • Visitors
  • Chats
  • Messages
  • 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

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

    All API calls expect you to send a bearer token in Authorization 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 an 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 the app interface
    » jobTitle string false Job title of the operator
    » role string true 'operator' - a generic operator, 'admin' - an operator with advanced administrative permissions
    » lastLoginAt string(date-time) false Time of the 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 set manually or automatically last time
    » 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 the app interface
    » jobTitle body string false Job title of the operator
    » role body string true 'operator' - a generic operator, 'admin' - an 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 an 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 an 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 the app interface
    » jobTitle string false Job title of the operator
    » role string true 'operator' - a generic operator, 'admin' - an operator with advanced administrative permissions
    » lastLoginAt string(date-time) false Time of the 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 set manually or automatically last time
    » 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 the app interface
    » jobTitle body string false Job title of the operator
    » role body string true 'operator' - a generic operator, 'admin' - an 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 an 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 an 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.

    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 the most recent to the least).

    Parameters

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

    Example responses

    {
      "result": [
        {
          "id": "59747c3ff77948220136b7cd",
          "widgetId": "11111111-2222-eeee-bbbb-aaaaaa777777",
          "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 an internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result [Visitor] true Contains one page of entities
    » id string true Visitor ID
    » widgetId string true Visitor ID assigned by the widget
    » sourceHost string false Website where the chat widget is installed
    » name string false Name of the visitor. Initially, a name is likely to include identified geolocation and a visitor number. However, if IP geolocation is unsuccessful, a 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 have associated with the visitor. This data is displayed in visitor's info panel along with the rest of the information
    » consents object false Stores information of what consents have been received from the visitor
    »» emailMarketing boolean false Whether the email marketing consent is granted
    » 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 source
    »» medium string false UTM medium
    »» term string false UTM term
    »» campaign string false UTM campaign
    »» content string false UTM content
    » browser object false Browser information
    »» name string false Browser name
    »» version string false Browser version
    » os object false OS information
    »» name string false OS name
    »» version string false OS version
    links object false URLs for next and previous page requests
    » next string false Relative URL to the next page of results if available
    » prev string false Relative URL to the 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",
        "widgetId": "11111111-2222-eeee-bbbb-aaaaaa777777",
        "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 an 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
    » widgetId string true Visitor ID assigned by the widget
    » sourceHost string false Website where the chat widget is installed
    » name string false Name of the visitor. Initially, a name is likely to include identified geolocation and a visitor number. However, if IP geolocation is unsuccessful, a 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 have associated with the visitor. This data is displayed in visitor's info panel along with the rest of the information
    » consents object false Stores information of what consents have been received from the visitor
    »» emailMarketing boolean false Whether the email marketing consent is granted
    » 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 source
    »» medium string false UTM medium
    »» term string false UTM term
    »» campaign string false UTM campaign
    »» content string false UTM content
    » browser object false Browser information
    »» name string false Browser name
    »» version string false Browser version
    » os object false OS information
    »» name string false OS name
    »» version string false OS version

    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, the response contains 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. Initially, a name is likely to include identified geolocation and a visitor number. However, if IP geolocation is unsuccessful, a 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 have associated with the visitor. This data is displayed in visitor's info panel along with the rest of the information
    » consents body object false Stores information of what consents have been received from the visitor
    »» emailMarketing body boolean false Whether the email marketing consent is granted
    » 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 source
    »» medium body string false UTM medium
    »» term body string false UTM term
    »» campaign body string false UTM campaign
    »» content body string false UTM content

    Example responses

    {
      "updated": {
        "id": "59747c3ff77948220136b7cd",
        "widgetId": "11111111-2222-eeee-bbbb-aaaaaa777777",
        "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, the resulting object is returned in the response
    404 Not Found Requested entity has not been found
    500 Internal Server Error Server was unable to process the request due to an 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
    » widgetId string true Visitor ID assigned by the widget
    » sourceHost string false Website where the chat widget is installed
    » name string false Name of the visitor. Initially, a name is likely to include identified geolocation and a visitor number. However, if IP geolocation is unsuccessful, a 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 have associated with the visitor. This data is displayed in visitor's info panel along with the rest of the information
    » consents object false Stores information of what consents have been received from the visitor
    »» emailMarketing boolean false Whether the email marketing consent is granted
    » 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 source
    »» medium string false UTM medium
    »» term string false UTM term
    »» campaign string false UTM campaign
    »» content string false UTM content
    » browser object false Browser information
    »» name string false Browser name
    »» version string false Browser version
    » os object false OS information
    »» name string false OS name
    »» version string false OS version

    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 an 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 the 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. Do the following to get a complete list of visitor's chats:

    1. Retrieve the last chat. Take note of links.more in the response.
    2. Retrieve all other chats by calling API URLs you found at links.more of the first response.

    Parameters

    Parameter In Type Required Description
    visitorId path string true ID of the visitor
    eventTypes query array false An array of event types to include in the response. Ignored if a 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",
        "startPage": {
          "url": "https://example.com/some-page",
          "title": "Example.com | Home page"
        },
        "initiator": "visitor",
        "events": [
          [
            {
              "type": "visitor-message",
              "timestamp": "2018-09-25T13:14:01Z",
              "params": {
                "text": "Hello! How do I do this thing?"
              }
            },
            {
              "type": "operator-message",
              "timestamp": "2018-09-25T13:14:13Z",
              "params": {
                "operatorId": "123abc123abc123abc123abc",
                "text": "Hello! To do this thing please do that thing and follow instructions on the screen."
              }
            }
          ]
        ],
        "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 an 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
    » startPage object false Details of the page where the chat was initiated
    »» url string true URL of the page
    »» title string true Page title or name
    » initiator string false Initiator of the chat
    » events [ChatEvent] false List of the chat events
    »» type string true Type of the chat event (i.e., a chat event discriminator)
    »» timestamp string(date-time) true Datetime of the chat event
    » 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 Related API URLs
    » 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 the visitor ID and the 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",
        "startPage": {
          "url": "https://example.com/some-page",
          "title": "Example.com | Home page"
        },
        "initiator": "visitor",
        "events": [
          [
            {
              "type": "visitor-message",
              "timestamp": "2018-09-25T13:14:01Z",
              "params": {
                "text": "Hello! How do I do this thing?"
              }
            },
            {
              "type": "operator-message",
              "timestamp": "2018-09-25T13:14:13Z",
              "params": {
                "operatorId": "123abc123abc123abc123abc",
                "text": "Hello! To do this thing please do that thing and follow instructions on the screen."
              }
            }
          ]
        ],
        "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 an 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
    » startPage object false Details of the page where the chat was initiated
    »» url string true URL of the page
    »» title string true Page title or name
    » initiator string false Initiator of the chat
    » events [ChatEvent] false List of the chat events
    »» type string true Type of the chat event (i.e., a chat event discriminator)
    »» timestamp string(date-time) true Datetime of the chat event
    » 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 Related API URLs
    » 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

    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": "2020-02-21T14:09:36Z"
        }
      ]
    }
    

    Responses

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

    Response Schema

    Status Code 200

    Name Type Required Description
    result [ChatEvent] true Abstract base for all chat events.
    » type string true Type of the chat event (i.e., a chat event discriminator)
    » timestamp string(date-time) true Datetime of the chat event

    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": "2020-02-21T14:09:36Z"
      }
    }
    

    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 an internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result ChatEvent true Contains an entity matching request's criteria
    » type string true Type of the chat event (i.e., a chat event discriminator)
    » timestamp string(date-time) true Datetime of the chat event

    Update a Chat Event delivery status.

    Code samples

    PUT 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: 'PUT',
    
      headers: headers
    })
    .then(function(res) {
        return res.json();
    }).then(function(body) {
        console.log(body);
    });
    
    
    import requests
    headers = {
      'Accept': 'application/json'
    }
    
    r = requests.put('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.put 'https://app.chaport.com/api/v1/visitors/:visitorId/chats/:chatId/events/:eventId',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

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

    Updates a chat event delivery status.

    Example responses

    {
      "result": {
        "type": "string",
        "timestamp": "2020-02-21T14:09:36Z"
      }
    }
    

    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 an internal error

    Response Schema

    Status Code 200

    Name Type Required Description
    result ChatEvent true Contains an entity matching request's criteria
    » type string true Type of the chat event (i.e., a chat event discriminator)
    » timestamp string(date-time) true Datetime of the chat event

    Messages

    Messages API allows you to send messages on behalf of visitors and opens up the possibility of integrating Chaport with any chatbot of your choice.

    Send a Message

    Code samples

    POST https://app.chaport.com/api/v1/messages HTTP/1.1
    Host: app.chaport.com
    Content-Type: application/json
    Accept: application/json
    
    
    const request = require('node-fetch');
    const inputBody = '{
      "visitorId": "stringstringstringstring",
      "language": "string",
      "externalVisitorId": "string",
      "platform": "facebook",
      "platformVisitorId": "12378421",
      "chatEvent": {
        "type": "visitor-message",
        "params": {
          "text": "Help me!"
        }
      }
    }';
    const headers = {
      'Content-Type':'application/json',
      'Accept':'application/json'
    
    };
    
    fetch('https://app.chaport.com/api/v1/messages',
    {
      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/messages', 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/messages',
      params: {
      }, headers: headers
    
    p JSON.parse(result)
    
    

    POST /messages

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

    Body parameter

    {
      "visitorId": "stringstringstringstring",
      "language": "string",
      "externalVisitorId": "string",
      "platform": "facebook",
      "platformVisitorId": "12378421",
      "chatEvent": {
        "type": "visitor-message",
        "params": {
          "text": "Help me!"
        }
      }
    }
    

    Parameters

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

    Example responses

    {
      "id": "def123def123def123def123",
      "created": true,
      "visitor": {
        "id": "cbc543cbc543cbc543cbc543",
        "created": false
      },
      "chat": {
        "id": 91032841204,
        "created": true
      }
    }
    

    Responses

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

    Response Schema

    Status Code 200

    Name Type Required Description
    id string true Message chat event ID
    created boolean false Whether the chat event was created or not
    visitor object false Properties of the associated visitor
    » id string false Visitor ID
    » created boolean false Whether a visitor had to be created or not
    chat object false Properties of the associated chat
    » id integer false Chat ID
    » created boolean false Whether a new chat had to be created or not

    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 and update your subscriptions. Using Hooks API you can subscribe to the following events:

    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",
          "essential": true,
          "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 an 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 Event notifications are sent to this URL
    » event string true Name of the event related to this subscription
    » essential boolean false Whether if Chaport should wait for a successful callback response before marking the notification as processed. It applies only to chat.newEvent.* sent to the visitors originating from non-website channels. At any time for any given event, not more than 1 webhook should be essential.
    » 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",
      "essential": true
    }';
    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. See the list of supported events.

    Body parameter

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

    Parameters

    Parameter In Type Required Description
    body body Hook true Request body
    » targetUrl body string true Event notifications are sent to this URL
    » event body string true Name of the event related to this subscription
    » essential body boolean false Whether if Chaport should wait for a successful callback response before marking the notification as processed. It applies only to chat.newEvent.* sent to the visitors originating from non-website channels. At any time for any given event, not more than 1 webhook should be essential.

    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 an 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",
        "essential": true,
        "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 an 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 Event notifications are sent to this URL
    » event string true Name of the event related to this subscription
    » essential boolean false Whether if Chaport should wait for a successful callback response before marking the notification as processed. It applies only to chat.newEvent.* sent to the visitors originating from non-website channels. At any time for any given event, not more than 1 webhook should be essential.
    » 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",
      "essential": true
    }';
    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",
      "essential": true
    }
    

    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 Event notifications are sent to this URL
    » event body string true Name of the event related to this subscription
    » essential body boolean false Whether if Chaport should wait for a successful callback response before marking the notification as processed. It applies only to chat.newEvent.* sent to the visitors originating from non-website channels. At any time for any given event, not more than 1 webhook should be essential.

    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 an 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 an internal error

    Response Schema

    Status Code 200

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

    Events

    This section lists currently existing events that you can subscribe to using Hooks API.

    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": "/api/v1/visitors/123abc123abc123abc123abc/chats"
    }';
    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}

    Pass "event" equal to "chat.started" when creating a Hook.

    This event fires when a new chat is started. Please note, that if the chat is renewed (i.e., one of the participants sends a new message shortly after the chat was marked as finished) this event doesn't fire again.

    Body parameter

    {
      "link": "/api/v1/visitors/123abc123abc123abc123abc/chats"
    }
    

    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

    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": "/api/v1/visitors/123abc123abc123abc123abc/chats"
    }';
    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}

    Pass "event" equal to "chat.finished" when creating a Hook.

    This event fires after a chat is idle for about 10 minutes. Please note, that any chat can be renewed (i.e., restarted) shortly after it was finished, consequently this event may fire multiple times for some chats.

    Body parameter

    {
      "link": "/api/v1/visitors/123abc123abc123abc123abc/chats"
    }
    

    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

    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": "/api/v1/visitors/123abc123abc123abc123abc"
    }';
    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}

    Pass "event" equal to "visitor.created" when creating a Hook.

    This event fires when a new visitor starts a chat.

    Body parameter

    {
      "link": "/api/v1/visitors/123abc123abc123abc123abc"
    }
    

    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

    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": "/api/v1/visitors/123abc123abc123abc123abc",
      "extras": {
        "fields": [
          "name",
          "email"
        ]
      }
    }';
    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}

    Pass "event" equal to "visitor.updated" when creating a Hook.

    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": "/api/v1/visitors/123abc123abc123abc123abc",
      "extras": {
        "fields": [
          "name",
          "email"
        ]
      }
    }
    

    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 Operator Sent a Message

    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": "/api/v1/visitors/123abc123abc123abc123abc/chats/123123123123/events/cba321cba321cba321cba321",
      "extras": {
        "operatorId": "123abc123abc123abc123abc",
        "visitorId": "789dfe789dfe789dfe789dfe",
        "chatId": 12389012374583
      }
    }';
    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}

    Pass "event" equal to "chat.newEvent.operatorMessage" when creating a Hook.

    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": "/api/v1/visitors/123abc123abc123abc123abc/chats/123123123123/events/cba321cba321cba321cba321",
      "extras": {
        "operatorId": "123abc123abc123abc123abc",
        "visitorId": "789dfe789dfe789dfe789dfe",
        "chatId": 12389012374583
      }
    }
    

    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",
      "startPage": {
        "url": "https://example.com/some-page",
        "title": "Example.com | Home page"
      },
      "initiator": "visitor",
      "events": [
        [
          {
            "type": "visitor-message",
            "timestamp": "2018-09-25T13:14:01Z",
            "params": {
              "text": "Hello! How do I do this thing?"
            }
          },
          {
            "type": "operator-message",
            "timestamp": "2018-09-25T13:14:13Z",
            "params": {
              "operatorId": "123abc123abc123abc123abc",
              "text": "Hello! To do this thing please do that thing and follow instructions on the screen."
            }
          }
        ]
      ],
      "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
    startPage object false Details of the page where the chat was initiated
    » url string true URL of the page
    » title string true Page title or name
    initiator string false Initiator of the chat
    events [ChatEvent] false List of the chat events
    » type string true Type of the chat event (i.e., a chat event discriminator)
    » timestamp string(date-time) true Datetime of the chat event
    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",
      "essential": true,
      "createdAt": "2017-10-12T10:47:31.873Z"
    }
    

    Properties

    Name Type Required Description
    id string false Event Subscription ID
    targetUrl string true Event notifications are sent to this URL
    event string true Name of the event related to this subscription
    essential boolean false Whether if Chaport should wait for a successful callback response before marking the notification as processed. It applies only to chat.newEvent.* sent to the visitors originating from non-website channels. At any time for any given event, not more than 1 webhook should be essential.
    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 the app interface
    jobTitle string false Job title of the operator
    role string true 'operator' - a generic operator, 'admin' - an operator with advanced administrative permissions
    lastLoginAt string(date-time) false Time of the 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 set manually or automatically last time
    realStatus string false Real status of the operator taking operator Online presence into consideration

    Visitor

    {
      "id": "59747c3ff77948220136b7cd",
      "widgetId": "11111111-2222-eeee-bbbb-aaaaaa777777",
      "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
    widgetId string true Visitor ID assigned by the widget
    sourceHost string false Website where the chat widget is installed
    name string false Name of the visitor. Initially, a name is likely to include identified geolocation and a visitor number. However, if IP geolocation is unsuccessful, a 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 have associated with the visitor. This data is displayed in visitor's info panel along with the rest of the information
    consents object false Stores information of what consents have been received from the visitor
    » emailMarketing boolean false Whether the email marketing consent is granted
    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 source
    » medium string false UTM medium
    » term string false UTM term
    » campaign string false UTM campaign
    » content string false UTM content
    browser object false Browser information
    » name string false Browser name
    » version string false Browser version
    os object false OS information
    » name string false OS name
    » version string false OS version

    ChatEvent

    {
      "type": "string",
      "timestamp": "2020-02-21T14:09:36Z"
    }
    

    Properties

    Name Type Required Description
    type string true Type of the chat event (i.e., a chat event discriminator)
    timestamp string(date-time) true Datetime of the chat event

    EmailRequestChatEvent

    {
      "type": "email-request",
      "timestamp": "2017-08-28T08:24:56.899Z"
    }
    

    Properties

    Name Type Required Description
    type string true Equals to email-request
    timestamp string(date-time) true Datetime of the chat event

    OperatorChangeChatEvent

    {
      "type": "operator-change",
      "timestamp": "2017-08-28T08:24:56.899Z",
      "params": {
        "operatorId": "123abc123abc123abc123abc",
        "targetOperatorId": "321cba321cba321cba321cba"
      }
    }
    

    Properties

    Name Type Required Description
    type string true Equals to operator-change
    timestamp string(date-time) true Datetime of the chat event
    params object false Parameters specific to operator-change event
    » operatorId string false ID of the transferring operator. If at the time this operator is assigned to the chat, this assignment is removed
    » targetOperatorId string false ID of the operator to be assigned to the chat.

    OperatorInviteChatEvent

    {
      "type": "operator-invite",
      "timestamp": "2017-08-28T08:24:56.899Z",
      "params": {
        "operatorId": "123abc123abc123abc123abc",
        "targetOperatorId": "321cba321cba321cba321cba"
      }
    }
    

    Properties

    Name Type Required Description
    type string true Equals to operator-invite
    timestamp string(date-time) true Datetime of the chat event
    params object false Parameters specific to a operator-invite event
    » operatorId string false ID of the inviting operator.
    » targetOperatorId string false ID of the operator being invited.

    OperatorMessageChatEvent

    {
      "type": "operator-message",
      "timestamp": "2017-08-28T08:24:56.899Z",
      "params": {
        "operatorId": "123abc123abc123abc123abc",
        "text": "You can find whatever your are looking for wherever you are looking at."
      }
    }
    

    Properties

    Name Type Required Description
    type string true Equals to operator-message
    timestamp string(date-time) true Datetime of the chat event
    params object false Parameters specific to operator's message
    » text string false Text of the message
    » operatorId string false ID of the authoring operator

    TriggerMessageChatEvent

    {
      "type": "trigger-message",
      "timestamp": "2017-08-28T08:24:56.899Z",
      "params": {
        "text": "Hey! How can I help you?"
      }
    }
    

    Properties

    Name Type Required Description
    type string true Equals to trigger-message
    timestamp string(date-time) true Datetime of the chat event
    params object false Parameters specific to trigger messages
    » text string false Text of the message

    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 Equals to visitor-message
    timestamp string(date-time) true Datetime of the chat event
    params object false Parameters specific to visitor's message
    » text string false Text of the message

    VisitorMutedChatEvent

    {
      "type": "visitor-muted",
      "timestamp": "2017-08-28T08:24:56.899Z",
      "params": {
        "operatorId": "123abc123abc123abc123abc",
        "mute": true
      }
    }
    

    Properties

    Name Type Required Description
    type string true Equals to visitor-muted
    timestamp string(date-time) true Datetime of the chat event
    params object false Parameters specific to visitor-ban event.
    » operatorId string false ID of the operator banning/unbanning the visitor
    » mute boolean false true if visitor is banned, false if the ban is lifted.

    VisitorOpenedPageChatEvent

    {
      "type": "visitor-opened-page",
      "timestamp": "2017-08-28T08:24:56.899Z",
      "params": {
        "url": "https://your-website.com/opened-page",
        "title": "HTML title of the opened page"
      }
    }
    

    Properties

    Name Type Required Description
    type string true Equals to visitor-opened-page
    timestamp string(date-time) true Datetime of the chat event
    params object false Parameters specific to open-page chat events
    » url string false URL of the opened page
    » title string false HTML title of the opened page

    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.