Objective
Create keys and authenticate to use the 8x8 Analytics for Contact Center API.
Applies To
- 8x8 Analytics for Contact Center
- Historical Metrics API
- Real-Time Metrics API
Procedure
Create an API Key for Analytics for Contact Center
- Log in to 8x8 Admin Console.
- Select API Keys.
- Select Create App.
- Enter a name for the app.
- For API Products, select Analytics for Contact Center.
- Select Save.
OAuth Authentication for 8x8 XCaaS APIs
- Request an access token from the 8x8 Authorization Server using Basic Authorization with your key and secret as the username and password, respectively.
- Combine and then encode your client credentials as a Base64 string.
- Make a POST request to the 8x8 Authorization Server using your encoded credentials string in the Authorization header.
- Obtain your access token from the server response.
Example Request (cURL)
In this example, we have provided cURL with the key and secret (cURL will generate the Authorization header).
curl --request POST --url https://api.8x8.com/oauth/v2/token -u 'key:secret' --header 'Content-type: application/x-www-form-urlencoded' --data grant_type=client_credentials
In this example, we have manually encoded the client credentials as a Base64 string and added the Authorization header.
curl --request POST \ --url https://api.8x8.com/oauth/v2/token \ --header 'Authorization: Basic am9**********w=='\ --header 'Content-type: application/x-www-form-urlencoded' \ --data grant_type=client_credentials
Example Response
{ "access_token": "ey***********************Bw", "token_type": "BearerToken", "api_product_list": "[analytics realtime-api]", "status": "approved", "scope": "", "refresh_token_expires_in": "0", "expires_in": "1799", "refresh_count": "0", "developer.email": "deprecated", "issued_at": "1696345119513", "client_id": "deprecated", "api_product_list_json": [ "analytics realtime-api" ] }
In the Example Response, the access token is ey***********************Bw and the indicated expiration time is indicated by "expires_in": "1799" (seconds).
Example Request & Response (Postman)
8x8 Analytics For Contact Center Request
Use the access token as the Bearer Token when making requests to the 8x8 Analytics For Contact Center API.
If the API is used for a multitenant customer the requests should contain "X-Tenant-Info" header variable where needs to specify the desired tenantId. The "X-Tenant-Info" header is not mandatory in case of a single tenant customer.
This example uses the fictional tenant name mytenantname01.
These examples use the eu region in the URL, you will need to use the correct region for your Tenant.
Example Request to Get Real-time metrics Queue Statistics (cURL)
curl --location 'https://api.8x8.com/eu/analytics/cc/v5/realtime-metrics/queues' \ --header 'accept: application/json' \ --header 'X-Tenant-Info: mytenantname01' \ --header 'Authorization: Bearer ey***********************Bw'