Skip to main content
GET
/
api
/
v2
/
platform
/
organisation
/
analytics
Get Analytics
curl --request GET \
  --url http://localhost:3001/api/v2/platform/organisation/analytics/ \
  --header 'Authorization: <api-key>' \
  --header 'Org-Handle: <org-handle>'
{
  "status_code": 200,
  "message": "Analytics fetched successfully",
  "data": {
    "total_calls": 1250,
    "completed_calls": 987,
    "failed_calls": 143,
    "avg_duration_seconds": 145.3,
    "total_tasks": 1350,
    "task_status_breakdown": {
      "pending": 45,
      "running": 12,
      "completed": 1180,
      "failed": 113
    }
  }
}
{
  "status_code": 200,
  "message": "Analytics fetched successfully",
  "data": {
    "total_calls": 1250,
    "completed_calls": 987,
    "failed_calls": 143,
    "avg_duration_seconds": 145.3,
    "total_tasks": 1350,
    "task_status_breakdown": {
      "pending": 45,
      "running": 12,
      "completed": 1180,
      "failed": 113
    }
  }
}

Get Analytics

Retrieve call analytics and task status for your organization. Provides insights into call outcomes, success rates, average durations, and task execution summaries. Optionally filter by a specific space using the space_token query parameter.
Prerequisites: Make sure you have your API Token and Org-Handle ready. See Authentication for details.

Headers

NameTypeRequiredDescription
AuthorizationstringYesAPI Key format: Token <token>
Org-HandlestringYesOrganization domain handle
You can get the Org-Handle by hitting the Get All Organizations API. The domain_handle field in the response is your Org-Handle.

Query Parameters

NameTypeRequiredDescription
space_tokenstringNoFilter analytics for a specific space. If omitted, returns org-wide analytics
If space_token is provided, analytics are scoped to that space only. If not provided, analytics aggregate across all contact spaces in the organization.

Response Fields

FieldTypeDescription
status_codeintegerHTTP status code
messagestringResponse message
dataobjectAnalytics data

Analytics Data Fields

FieldTypeDescription
total_callsintegerTotal number of calls made
completed_callsintegerNumber of successfully completed calls
failed_callsintegerNumber of failed calls
avg_duration_secondsnumberAverage call duration in seconds
total_tasksintegerTotal number of tasks across all runs
task_status_breakdownobjectBreakdown of tasks by status

Task Status Breakdown Fields

FieldTypeDescription
pendingintegerNumber of tasks awaiting execution
runningintegerNumber of tasks currently executing
completedintegerNumber of successfully completed tasks
failedintegerNumber of failed tasks

Common Error Codes

Status CodeDescription
200Success - Analytics fetched successfully
400Bad Request - Missing required headers
401Unauthorized - Invalid or missing API token
403Forbidden - Invalid organization handle
404Not Found - Organization not found
500Internal Server Error - Server-side error

Code Examples

const axios = require('axios');

const headers = {
  'Authorization': 'Token your-api-token',
  'Org-Handle': 'your-org-handle'
};

// Get org-wide analytics
const getAnalytics = async (spaceToken = null) => {
  const params = spaceToken ? { space_token: spaceToken } : {};
  const response = await axios.get(
    'https://unpod.dev/api/v2/platform/organisation/analytics/',
    { headers, params }
  );
  const data = response.data.data;
  console.log(`Total calls: ${data.total_calls}`);
  console.log(`Completed: ${data.completed_calls}`);
  console.log(`Failed: ${data.failed_calls}`);
  console.log(`Avg duration: ${data.avg_duration_seconds}s`);
  return data;
};

// Get org-wide analytics
getAnalytics();

// Get analytics for a specific space
getAnalytics('8KZAMRAHSXXXXXXMAYNASMJC');

Best Practices

  1. Space Scoping: Use the space_token filter to get analytics for individual campaigns or spaces
  2. Success Rate: Calculate success rate as completed_calls / total_calls * 100 for performance tracking
  3. Task Breakdown: Monitor task_status_breakdown to detect stuck or failed tasks requiring attention
  4. Scheduled Reports: Call this endpoint on a schedule to build trend dashboards
  5. Org-Handle: Ensure the correct organization handle is included for accurate scoping
  6. Security: Keep API tokens secure and rotate them regularly

Authorizations

Authorization
string
header
required

Format: Token

Headers

Org-Handle
string
required

Organization domain handle

Example:

"unpod"

Query Parameters

space_token
string
Example:

"8KZRTQP7BNW5XEDLORYUHMJC"

Response

Analytics data