> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jelou.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Estadísticas de operadores

> Casos totales, atendidos, no atendidos y tiempos de respuesta de tus operadores

Usa este recurso para medir el desempeño de tu equipo de soporte: filtra por un `operatorId` puntual para un análisis individual o consulta el rango completo para una vista general del equipo.

***

## Endpoint

```
GET https://api.jelou.ai/v1/metrics/conversations/external/stats
```

***

## Autenticación

| Campo | Ubicación | Tipo | Requerido | Descripción |
| - | - | - | - | - |
| **Authorization** | Header | string | Sí | Credenciales en formato `Basic <clientId:clientSecret>`. |

***

## Parámetros de consulta

| Campo | Ubicación | Tipo | Requerido | Descripción |
| - | - | - | - | - |
| **startAt** | Query | Date | Sí | Fecha de inicio de búsqueda. |
| **endAt** | Query | Date | Sí | Fecha fin para la búsqueda. |
| **operatorId** | Query | Int | No | ID del operador cuando se desea buscar por un operador específico. |

> [!TIP]
>
> Si omites `operatorId`, la consulta agrega las estadísticas de todos los operadores dentro del rango de fechas indicado.

***

## Ejemplos de solicitud

> [tab] cURL
>
> ```bash theme={null}
> curl --request GET \
>   --url 'https://api.jelou.ai/v1/metrics/conversations/external/stats?startAt=2025-02-01&endAt=2025-02-10' \
>   --header 'Authorization: Basic <clientId:clientSecret>'
> ```

> [tab] JavaScript
>
> ```javascript theme={null}
> const axios = require('axios');
>
> axios({
>   method: 'GET',
>   url: 'https://api.jelou.ai/v1/metrics/conversations/external/stats',
>   params: {
>     startAt: '2025-02-01',
>     endAt: '2025-02-10'
>   },
>   headers: {
>     'Authorization': 'Basic <clientId:clientSecret>'
>   }
> });
> ```

***

## Respuestas

> [accordion] 200 - Respuesta exitosa
>
> ```json theme={null}
> {
>   "_id": 123456,
>   "total": 6,
>   "actual": 0,
>   "attended": 6,
>   "expired": 0,
>   "lastMessageOperator": 5,
>   "lastMessageUser": 1,
>   "lastMessageBot": 0,
>   "notAttended": 0,
>   "avgReplyTime": 50.095333333333336,
>   "avgOperatorResponseTime": 119,
>   "transfered": 0,
>   "avgConversationTime": 3738.2073333333333,
>   "operator": {
>     "id": 987654,
>     "names": "Jane Doe",
>     "email": "jane_doe@test.com",
>     "companyId": 4321
>   }
> }
> ```

> [accordion] 401 - Unauthorized
>
> ```json theme={null}
> {
>   "message": "Authentication failed"
> }
> ```

> [accordion] 422 - Unprocessable Entity
>
> ```json theme={null}
> {
>   "message": [
>     "Los valores ingresados no son correctos."
>   ],
>   "statusMessage": "failed",
>   "status": 0,
>   "error": {
>     "code": "E0422",
>     "key": "VALIDATOR_ERROR",
>     "description": "Error to be thrown when cannot process request because of incoming values",
>     "developerMessages": {
>       "es": "Los valores del request no son correctos para ser procesados.",
>       "en": "The request values are not correct for processing."
>     },
>     "clientMessages": {
>       "es": "Los valores ingresados no son correctos.",
>       "en": "The values entered are not correct."
>     }
>   },
>   "validationError": {
>     "startAt": [
>       {
>         "es": "El campo startAt es requerido",
>         "en": "The startAt field is required",
>         "pt": "O campo startAt é obrigatório"
>       }
>     ]
>   }
> }
> ```

> [accordion] 500 - Internal Server Error
>
> ```json theme={null}
> {
>   "message": ["We are having trouble processing your request. Please try again later."],
>   "statusMessage": "failed",
>   "status": 0
> }
> ```

***

## Detalle de la respuesta

| Campo | Tipo | Descripción |
| - | - | - |
| **\_id** | integer | Identificador del operador o de la agregación consultada. |
| **total** | integer | Total de casos dentro del rango de fechas. |
| **actual** | integer | Casos actuales en la bandeja. |
| **attended** | integer | Casos atendidos. |
| **expired** | integer | Casos que expiraron sin atención. |
| **lastMessageOperator** | integer | Conversaciones cuyo último mensaje lo envió el operador. |
| **lastMessageUser** | integer | Conversaciones cuyo último mensaje lo envió el usuario. |
| **lastMessageBot** | integer | Conversaciones cuyo último mensaje lo envió el canal. |
| **notAttended** | integer | Casos no atendidos. |
| **avgReplyTime** | number | Tiempo promedio de respuesta, en segundos. |
| **avgOperatorResponseTime** | number | Tiempo promedio de respuesta del operador, en segundos. |
| **transfered** | integer | Casos transferidos a otro operador o equipo. |
| **avgConversationTime** | number | Duración promedio de las conversaciones, en segundos. |
| **operator** | object | Información del operador consultado. |
| **operator.id** | integer | Identificador del operador. |
| **operator.names** | string | Nombre del operador. |
| **operator.email** | string | Correo electrónico del operador. |
| **operator.companyId** | integer | Identificador de la empresa a la que pertenece el operador. |

> [!TIP]
>
> Usa `attended` y `notAttended` junto con `avgOperatorResponseTime` para evaluar la carga y la eficiencia de cada operador dentro del rango consultado.


## OpenAPI

````yaml GET /v1/metrics/conversations/external/stats
openapi: 3.1.0
info:
  title: Jelou API
  description: >-
    API for the Jelou platform. Send messages, manage campaigns, handle
    conversations, users, databases, and widgets.
  version: 1.0.0
servers:
  - url: https://api.jelou.ai
    description: Production server
security:
  - basicAuth: []
tags:
  - name: Messages
    description: Send messages to users
  - name: Campaigns
    description: HSM campaigns and templates
  - name: Conversations
    description: Chat history and metrics
  - name: Users
    description: User state and cache management
  - name: Clients
    description: WhatsApp clients of the company
  - name: Resources
    description: Media resource management
  - name: Datum
    description: Database CRUD operations
  - name: Widget
    description: Widget and room management
  - name: PMA Custom
    description: External support panel integration
  - name: Memory
    description: Per-user session memory management (Memory API v2)
paths:
  /v1/metrics/conversations/external/stats:
    get:
      tags:
        - Conversations
      summary: Get Operator Statistics
      description: >-
        Retrieve an operator's (or all operators') attention statistics within a
        date range.
      operationId: getOperatorStats
      parameters:
        - name: startAt
          in: query
          required: true
          description: Search start date
          schema:
            type: string
            format: date
        - name: endAt
          in: query
          required: true
          description: Search end date
          schema:
            type: string
            format: date
        - name: operatorId
          in: query
          required: false
          description: Operator ID to filter statistics for a specific operator
          schema:
            type: integer
      responses:
        '200':
          description: Statistics retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OperatorStatsResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    OperatorStatsResponse:
      type: object
      properties:
        _id:
          type: integer
          description: Identifier of the queried operator or aggregation
        total:
          type: integer
          description: Total cases within the date range
        actual:
          type: integer
          description: Cases currently in the queue
        attended:
          type: integer
          description: Attended cases
        expired:
          type: integer
          description: Cases that expired without attention
        lastMessageOperator:
          type: integer
          description: Conversations whose last message was sent by the operator
        lastMessageUser:
          type: integer
          description: Conversations whose last message was sent by the user
        lastMessageBot:
          type: integer
          description: Conversations whose last message was sent by the bot
        notAttended:
          type: integer
          description: Unattended cases
        avgReplyTime:
          type: number
          description: Average reply time, in seconds
        avgOperatorResponseTime:
          type: number
          description: Average operator response time, in seconds
        transfered:
          type: integer
          description: Cases transferred to another operator or team
        avgConversationTime:
          type: number
          description: Average conversation duration, in seconds
        operator:
          $ref: '#/components/schemas/OperatorStatsOperator'
    OperatorStatsOperator:
      type: object
      properties:
        id:
          type: integer
        names:
          type: string
        email:
          type: string
        companyId:
          type: integer
    Error:
      type: object
      properties:
        message:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        statusMessage:
          type: string
        status:
          type: integer
        error:
          type: object
          properties:
            code:
              type: string
            key:
              type: string
            description:
              type: string
            developerMessages:
              type: object
            clientMessages:
              type: object
        validationError:
          type: object
  responses:
    Unauthorized:
      description: Unauthorized - Invalid authentication credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnprocessableEntity:
      description: Unprocessable entity - Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Basic authentication using Base64 encoded clientId:clientSecret

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.