From Bright Pattern Documentation
Jump to: navigation, search
Line 32: Line 32:
  
 
The cookie is valid until next user login into any wallboard (one cookie per user).
 
The cookie is valid until next user login into any wallboard (one cookie per user).
 +
=== Example ===
 +
curl -v https://kelly.bugfocus.com/statsapi/auth -X POST -H "Content-Type: application/json" -d '{"tenant_url" : "kelly.bugfocus.com","username" : "statsapi","password" : "<passsword>"}';
  
 +
Result:
 +
<syntaxhighlight lang="JSON" line='line'>
 +
{
 +
  "token" : "552B7CF9-B2D7-4966-A446-CEAFB1028AD8",
 +
  "privileges" : [ ],
 +
  "user_id" : "3F540B8B-5BBB-477B-B8FB-C6BF400795C3"
 +
}
 +
</syntaxhighlight>
  
 
== Create subscription ==
 
== Create subscription ==
Line 102: Line 112:
 
*409 – limit of active subscriptions exceeded for tenant
 
*409 – limit of active subscriptions exceeded for tenant
 
*200 – OK subscription was created
 
*200 – OK subscription was created
 +
===Example===
 +
curl -v https://kelly.bugfocus.com/statsapi/subscription -X POST -H "Content-Type: application/json" -H "Cookie: X-BP-SESSION-ID=80AB9288-C5D7-4F06-9679-5F03195F90F8" -d '{"1":{"service_grids":[{"id":"1","columns":[{"id":"1","statName":"name"},{"id":"2","statName":"in_ewt"},{"id":"3","statName":"in_max_wait_time"}]}]}}'
  
 +
results in 200 OK
  
 
== Delete subscription ==
 
== Delete subscription ==
Line 168: Line 181:
 
     }
 
     }
 
  }
 
  }
 +
===Example===
 +
curl -v https://kelly.bugfocus.com/statsapi/subscription/data -X GET -H "Cookie: X-BP-SESSION-ID=80AB9288-C5D7-4F06-9679-5F03195F90F8"
  
 +
Result:
 +
<syntaxhighlight lang="JSON" line='line'>
 +
{"1":{
 +
  "service_grids":[
 +
      {"id":"1",
 +
      "values":[
 +
        {"1":"Customer Service","2":"200","3":"0"},
 +
        {"1":"Customer Service Chat","2":"200","3":"0"}
 +
        ]
 +
        }
 +
      ]
 +
  }
 +
}
 +
</syntaxhighlight>
  
 
== Get dispositions ==
 
== Get dispositions ==

Revision as of 22:19, 28 May 2020

• 5.19 • 5.2 • 5.3 • 5.8

API Description

Authenticate

Authenticate user on server. In case of successful authentication the server sets session cookies.

Note that the user must have "Access Realtime Stats API", "View real-time agent metrics", and "View real-time service metrics", as well as to be assigned supervisor of the corresponding teams.

URI

https://{host:port}/statsapi/auth

HTTP Method

POST

Body

{
    "tenant_url" : "<tenant_url>",
    "username" : "<username>",
    "password" : "<password>"
}

Response

  • 401 – Unauthorized
  • 200 – OK
{
    "token": <token>
}

The token has the same value that is set in the server cookie. The cookie can also be supplied manually on a request using Cookie header.

Cookie: X-BP-SESSION-ID=88d41319-cb02-4d9a-a1f3-bd2611cd7f68

The cookie is valid until next user login into any wallboard (one cookie per user).

Example

curl -v https://kelly.bugfocus.com/statsapi/auth -X POST -H "Content-Type: application/json" -d '{"tenant_url" : "kelly.bugfocus.com","username" : "statsapi","password" : "<passsword>"}';

Result:

1{
2  "token" : "552B7CF9-B2D7-4966-A446-CEAFB1028AD8",
3  "privileges" : [ ],
4  "user_id" : "3F540B8B-5BBB-477B-B8FB-C6BF400795C3"
5}

Create subscription

Creates subscription for specific set of metrics. Each client can have only one active subscription.

URI

https://{host:port}/statsapi/subscription

HTTP Method

POST

Body

{
    "<app id>": {
        "stats_totals": ["statistic name" ], //array of statistics
        "service_grids": [//array of service grid definitions 
            {
                "id": "<grid Id>",
                "columns": [//array of stats for columns
                    {
                        "id": "<column id>",
                        "statName": "<statistic protocol name>|SUM", 
                        "sum_stat_names": ["<(optional)list of statistic protocol name for sum>"]
                    }
                ], 
                "order_by": "<column id>",
                "order_dir": "ASC|DESC",
                "limit": "<count of top records>",
                "filter_by": "<column id>",
                "filter_value": "<value>",
                "filter_operation": "EQ|NE|LT|GT|LE|GE"
            }
        ],
        "agent_grids": [ //array of agent grid definitions  
            {
                "id": "<grid Id>",
                "columns": [//array of stats for columns
                    {
                        "id": "<column id>",
                        "stat_name": "<statistic protocol name>|SUM", 
                        "dispositions": ["<(optional)list of dispositions>"],
                        "sum_stat_names": ["<(optional)list of statistic protocol name for sum>"]
                    }
                ], 
                "order_by": "<column id>",
                "order_dir": "ASC|DESC",
                "limit": "<count of top records>",
                "filter_by": "<column id>",
                "filter_value": "<value>",
                "filter_operation": "EQ|NE|LT|GT|LE|GE"
            }
        ]
        "chat_messages": {//top of internal chat messages  
        "filter": "<filter by message content>",
        "limit": "<count of top records>"
        },
    }
}

Response

  • 400 – Bad Request
{
    "error_code": <error code>,
    "error_message": "<error message>"
}

  • 401 – Unauthorized
  • 409 – limit of active subscriptions exceeded for tenant
  • 200 – OK subscription was created

Example

curl -v https://kelly.bugfocus.com/statsapi/subscription -X POST -H "Content-Type: application/json" -H "Cookie: X-BP-SESSION-ID=80AB9288-C5D7-4F06-9679-5F03195F90F8" -d '{"1":{"service_grids":[{"id":"1","columns":[{"id":"1","statName":"name"},{"id":"2","statName":"in_ewt"},{"id":"3","statName":"in_max_wait_time"}]}]}}'

results in 200 OK

Delete subscription

Deletes active subscription, clears data cache on server

URI

https://{host:port}/statsapi/subscription/active

HTTP Method

DELETE


Get subscription data

Gets statistics data of an active subscription.

URI

https://{host:port}/statsapi/subscription/data

HTTP Method

GET

Response

  • 401 – Unauthorized
  • 404 – Bad Request (There is no active subscription)
  • 204 –No Content (Data is not ready yet)
  • 200 – OK
{
    {
        "<app id>": {
        "stats_totals": {//array of single statistics
        "<statistic name>": <statistic value>
    }, 
    "service_grids": [//array of service grids 
        {
            "id": "<grid Id>",
            "values": [
                {
                    "<column id>": "<statistic value>"
                }
            ]
        }
    ],
    "agent_grids": [ //array of agent grids 
        {
            "id": "<grid Id>",
            "values": [
                {
                    "<column id>": "<statistic value>"
                }
            ]
        }
    ],
    "chat_messages": [
        {
            "id": "<message id>",
            "login_id": "<sender loginId>",
            "first_name": "<sender first name>",
            "last_name": "<sender last name>",
            "send_time": "<utc timestamp>",
            "is_urgent": "1|0",
            "content": "<chat message>"
        }
    ]
    }
}

Example

curl -v https://kelly.bugfocus.com/statsapi/subscription/data -X GET -H "Cookie: X-BP-SESSION-ID=80AB9288-C5D7-4F06-9679-5F03195F90F8" 

Result:

 1{"1":{
 2   "service_grids":[
 3      {"id":"1",
 4      "values":[
 5         {"1":"Customer Service","2":"200","3":"0"},
 6         {"1":"Customer Service Chat","2":"200","3":"0"}
 7         ]
 8         }
 9      ]
10   }
11}

Get dispositions

Gets disposition names for all supervised services.

URI

https://{host:port}/statsapi/cfg/dispositions

HTTP Method

GET

URL Parameters

  • agentCanSelect = 1
  • inbound = 1
  • outbound = 1
  • preview = 1

Response

  • 401 – Unauthorized
  • 200 – OK
{
    "dispositions": ["<disposition name>", ...] 
}


Get available agents

Gets "true" or "false" value for agents ready to handle a specific service.

URI

https://{tenant_url:port}/statsapi/info/check_available_agents?service={service-name}

HTTP Method

GET

Note: No authentication or subscription is needed.

Response

  • 200 – OK
{
    “availability”: [ true | false ] 
}
  • True – "Number of ready agents" > 0 for the specific service (i.e., at least one agent is available)
  • False – "Number of ready agents" is 0 for the specific service (i.e., no agent is available)


Next >