Skip to content

Returns ticket analytics for the authenticated account

POST
/analytics
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.

Media type application/json
object
metric
required

Aggregation to compute

string
Allowed values: count avg_resolution_time avg_response_time avg_first_reply_time
group_by

Ticket field to group by.

string
""
Allowed values: "" status priority creator assignee customer_organization
from
required

Start date, either YYYY-MM-DD or a relative day offset such as -30d.

string
to

Optional end date, either YYYY-MM-DD or a relative day offset such as -1d. Defaults to the current date if omitted.

string
filters

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
id

Filter by exact ticket ID.

string
title

Filter by exact ticket title.

string
status

Filter by status (validated server-side).

string
Allowed values: open pending on-hold solved closed
priority

Filter by priority (validated server-side).

string
Allowed values: low medium high urgent
creator

Filter by exact creator email.

string
assignee

Filter by exact assignee email.

string
customer_organization

Filter by exact customer organization ID.

string
team

Filter by exact team value.

string
updated_at

Include tickets updated after this value (YYYY-MM-DD or -Xd).

string
Examples

Count tickets by status for last 30 days

{
"metric": "count",
"group_by": "status",
"from": "-30d"
}

Analytics results

Media type application/json
object
data
required
Array<object>

Only the property for the requested metric is present; group_value is present only when group_by is set.

object
group_value

Present only when grouped

string
ticket-count
integer format: int64
avg-resolution-time-sec
number format: double
avg-response-time-sec
number format: double
avg-first-reply-sec
number format: double
meta
required
object
metric
string
group-by
string
from
string
to
string
filters
object
key
additional properties
One of:
string
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": {}
}
}

Invalid request

Media type application/problem+json

RFC 9457 problem details response emitted by the shared Gin error middleware.

object
type

Optional URI reference identifying the problem type.

string
title
string
status
integer
detail
string
instance
string
code
string
requestId

Request correlation ID when available.

string
Examples
{
"title": "Bad Request",
"status": 400,
"detail": "from must be specified",
"code": "missing_from",
"instance": "/analytics",
"requestId": "4f7f9d77-97a4-4ac3-8d09-9c5643ed6e53"
}

Unauthorized (missing/invalid token)

Media type application/problem+json

RFC 9457 problem details response emitted by the shared Gin error middleware.

object
type

Optional URI reference identifying the problem type.

string
title
string
status
integer
detail
string
instance
string
code
string
requestId

Request correlation ID when available.

string
Example
{
"title": "Bad Request",
"status": 400,
"detail": "from must be specified",
"instance": "/analytics",
"code": "missing_from"
}

Forbidden

Media type application/problem+json

RFC 9457 problem details response emitted by the shared Gin error middleware.

object
type

Optional URI reference identifying the problem type.

string
title
string
status
integer
detail
string
instance
string
code
string
requestId

Request correlation ID when available.

string
Example
{
"title": "Bad Request",
"status": 400,
"detail": "from must be specified",
"instance": "/analytics",
"code": "missing_from"
}

Internal error while querying analytics

Media type application/problem+json

RFC 9457 problem details response emitted by the shared Gin error middleware.

object
type

Optional URI reference identifying the problem type.

string
title
string
status
integer
detail
string
instance
string
code
string
requestId

Request correlation ID when available.

string
Example
{
"title": "Bad Request",
"status": 400,
"detail": "from must be specified",
"instance": "/analytics",
"code": "missing_from"
}