Skip to content

Customer Service API

The customer service plugin provides a set of RESTful HTTP APIs for managing the creation, assignment, querying, and closing of customer service sessions.

All endpoint paths are prefixed with:

/customer-service/

Get all customer service sessions.

GET /customer-service/sessions
{
"code": 0,
"data": {
"sessions": [
{
"id": "cs_abc123",
"title": "After-sales inquiry",
"customer_id": "cust_001",
"customer_name": "John",
"agent_id": "agent_001",
"agent_name": "Agent Wang",
"status": "Active",
"duration": 320,
"created_at": "2024-01-15T10:30:00Z"
}
],
"total": 1
}
}
StatusDescription
WaitingWaiting — created but both parties have not yet joined
ActiveIn call — both parties are connected
EndedEnded

Get detailed information for a specific session.

GET /customer-service/sessions/{id}
ParameterTypeDescription
idstringSession ID
{
"code": 0,
"data": {
"id": "cs_abc123",
"title": "After-sales inquiry",
"customer_id": "cust_001",
"customer_name": "John",
"agent_id": "agent_001",
"agent_name": "Agent Wang",
"status": "Active",
"duration": 320,
"created_at": "2024-01-15T10:30:00Z"
}
}

Create a new customer service call session.

POST /customer-service/sessions
Content-Type: application/json
{
"title": "After-sales inquiry",
"customer_name": "John",
"description": "Regarding refund for order #12345"
}
FieldTypeRequiredDescription
titlestringYesSession title
customer_namestringYesCustomer name
descriptionstringNoSession description
{
"code": 0,
"data": {
"id": "cs_abc123",
"title": "After-sales inquiry",
"customer_id": "cust_001",
"customer_name": "John",
"status": "Waiting",
"created_at": "2024-01-15T10:30:00Z"
}
}

Close or delete a specific session. If a call is in progress, it will be forcefully terminated.

DELETE /customer-service/sessions/{id}
ParameterTypeDescription
idstringSession ID
{
"code": 0,
"message": "session closed"
}

Assign a specific customer service agent to a session.

POST /customer-service/sessions/{id}/assign
Content-Type: application/json
ParameterTypeDescription
idstringSession ID
{
"agent_id": "agent_001",
"agent_name": "Agent Wang"
}
FieldTypeRequiredDescription
agent_idstringYesAgent ID
agent_namestringYesAgent name
{
"code": 0,
"message": "agent assigned"
}

Get overall statistics for customer service calls.

GET /customer-service/stats
{
"code": 0,
"data": {
"total_sessions": 156,
"active_sessions": 3,
"waiting_sessions": 2,
"ended_sessions": 151
}
}
FieldTypeDescription
total_sessionsnumberTotal number of sessions
active_sessionsnumberNumber of active call sessions
waiting_sessionsnumberNumber of sessions waiting for connection
ended_sessionsnumberNumber of ended sessions

All endpoints return a unified error format on failure:

{
"code": -1,
"message": "session not found"
}
Error MessageDescription
session not foundSession ID does not exist
session already endedSession has ended, cannot be operated on
agent already assignedAgent has already been assigned
max sessions reachedMaximum concurrent session limit exceeded
invalid request bodyRequest body format is invalid