Returns ticket analytics for the authenticated account
const url = 'https://api.muninx.com/analytics';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"metric":"count","group_by":"status","from":"-30d"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.muninx.com/analytics \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "metric": "count", "group_by": "status", "from": "-30d" }'Computes aggregated ticket metrics scoped to the authenticated tenant.
Requests are automatically filtered by the caller’s role: customers are scoped to creator = <user email>, and agents to assignee = <user email>.
Results are limited to 100 rows.
Time-based metrics are returned in seconds (avg-resolution-time-sec, avg-response-time-sec, avg-first-reply-sec).
Empty result sets are returned as a single empty result object.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”object
Aggregation to compute
Ticket field to group by.
Start date, either YYYY-MM-DD or a relative day offset such as -30d.
Optional end date, either YYYY-MM-DD or a relative day offset such as -1d. Defaults to the current date if omitted.
Supported string filters are combined with AND. Equality is used by default (key = value).
status and priority are normalized and validated server-side.
updated_at is handled as updated_at > value and supports YYYY-MM-DD or -Xd.
Requests are automatically scoped by role: customers are constrained to their own tickets (creator), agents are constrained to tickets they own (assignee).
object
Filter by exact ticket ID.
Filter by exact ticket title.
Filter by status (validated server-side).
Filter by priority (validated server-side).
Filter by exact creator email.
Filter by exact assignee email.
Filter by exact customer organization ID.
Filter by exact team value.
Include tickets updated after this value (YYYY-MM-DD or -Xd).
Examples
Count tickets by status for last 30 days
{ "metric": "count", "group_by": "status", "from": "-30d"}Average response time excluding zeroes, recent updates only
{ "metric": "avg_response_time", "group_by": "", "from": "-30d", "filters": { "updated_at": "-1d" }}Solved tickets per agent updated in last 30 days
{ "metric": "count", "group_by": "assignee", "from": "-60d", "filters": { "status": "solved", "updated_at": "-30d" }}Average first reply time for the past week
{ "metric": "avg_first_reply_time", "group_by": "", "from": "-7d", "filters": { "status": "open" }}Average resolution time grouped by priority
{ "metric": "avg_resolution_time", "group_by": "priority", "from": "-90d"}Responses
Section titled “ Responses ”Analytics results
object
Only the property for the requested metric is present; group_value is present only when group_by is set.
object
Present only when grouped
Examples
Count by status example
{ "data": [ { "group_value": "Open", "ticket-count": 42 }, { "group_value": "Pending", "ticket-count": 17 }, { "group_value": "Solved", "ticket-count": 95 } ], "meta": { "metric": "count", "group-by": "status", "from": "-30d", "to": "", "filters": {} }}Single-row average example
{ "data": [ { "avg-response-time-sec": 23 } ], "meta": { "metric": "avg_response_time", "group-by": "", "from": "-30d", "to": "", "filters": { "updated_at": "-1d" } }}Invalid request
RFC 9457 problem details response emitted by the shared Gin error middleware.
object
Optional URI reference identifying the problem type.
Request correlation ID when available.
Examples
{ "title": "Bad Request", "status": 400, "detail": "from must be specified", "code": "missing_from", "instance": "/analytics", "requestId": "4f7f9d77-97a4-4ac3-8d09-9c5643ed6e53"}{ "title": "Bad Request", "status": 400, "detail": "Unsupported metric", "code": "unsupported_metric", "instance": "/analytics"}{ "title": "Bad Request", "status": 400, "detail": "group_by must be one of: status, priority, creator, assignee, customer_organization", "code": "unsupported_group_by", "instance": "/analytics"}{ "title": "Bad Request", "status": 400, "detail": "filter must be one of: id, title, status, priority, creator, assignee, customer_organization, team, updated_at", "code": "unsupported_filter", "instance": "/analytics"}Unauthorized (missing/invalid token)
RFC 9457 problem details response emitted by the shared Gin error middleware.
object
Optional URI reference identifying the problem type.
Request correlation ID when available.
Example
{ "title": "Bad Request", "status": 400, "detail": "from must be specified", "instance": "/analytics", "code": "missing_from"}Forbidden
RFC 9457 problem details response emitted by the shared Gin error middleware.
object
Optional URI reference identifying the problem type.
Request correlation ID when available.
Example
{ "title": "Bad Request", "status": 400, "detail": "from must be specified", "instance": "/analytics", "code": "missing_from"}Internal error while querying analytics
RFC 9457 problem details response emitted by the shared Gin error middleware.
object
Optional URI reference identifying the problem type.
Request correlation ID when available.
Example
{ "title": "Bad Request", "status": 400, "detail": "from must be specified", "instance": "/analytics", "code": "missing_from"}