> ## 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.

# Estado de usuario

> Consulta y actualiza el estado de un usuario

## Descripción

Gestiona el estado operativo de un usuario dentro de tu bot. Puedes consultar si un contacto está en modo manual o automático y actualizar esta configuración para controlar quién responde las conversaciones.

## Obtener el Estado de un Usuario

### Endpoint

```
GET https://api.jelou.ai/v1/users/{userId}/state
```

### Parámetros de Ruta

<ParamField path="userId" type="string" required>
  Número de teléfono del usuario (sin el signo `+`).
</ParamField>

### Ejemplo de Respuesta

```json theme={null}
{
  "id": "573001234567",
  "names": "John Doe",
  "botId": "bot-12345",
  "groupId": "grp-67890",
  "state": "auto"
}
```

## Cambiar el Estado de un Usuario

### Endpoint

```
POST https://api.jelou.ai/v1/users/state
```

### Cuerpo de la Solicitud

<ParamField body="ttl" type="number">
  Tiempo en segundos que permanecerá el estado manual antes de expirar automáticamente.
</ParamField>

<ParamField body="botId" type="string" required>
  Identificador del bot asociado al usuario.
</ParamField>

<ParamField body="userId" type="string" required>
  Número de teléfono del usuario (sin el signo `+`).
</ParamField>

<ParamField body="state" type="string" required>
  Estado objetivo. Valores permitidos: `"manual"` o `"auto"`.
</ParamField>

### Ejemplo de Solicitud

```bash cURL theme={null}
curl --request POST \
  --url https://api.jelou.ai/v1/users/state \
  --header 'Authorization: Basic <Base64Encoded clientId:clientSecret>' \
  --header 'Content-Type: application/json' \
  --data '{
    "ttl": 3600,
    "botId": "bot-12345",
    "userId": "573001234567",
    "state": "manual"
  }'
```

### Ejemplo de Respuesta

```json theme={null}
{
  "id": "573001234567",
  "names": "John Doe",
  "botId": "bot-12345",
  "groupId": "grp-67890",
  "state": "manual"
}
```

<Warning>
  Cuando un usuario está en estado `manual`, el bot deja de responder automáticamente y es necesario enviar mensajes manuales usando los endpoints de envío. Asegúrate de coordinar el cambio de estado con tu equipo de soporte.
</Warning>

## Errores Comunes

* `400` - No se pudo obtener o actualizar el estado del usuario.
* `401` - Credenciales inválidas o faltantes.
* `404` - Usuario o bot no encontrados.


## OpenAPI

````yaml GET /v1/users/{userId}/state
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: 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
paths:
  /v1/users/{userId}/state:
    get:
      tags:
        - Users
      summary: Get User State
      description: Get the current state (auto/manual) of a user.
      operationId: getUserState
      parameters:
        - name: userId
          in: path
          required: true
          description: Phone number without + sign
          schema:
            type: string
      responses:
        '200':
          description: User state retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserStateResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    UserStateResponse:
      type: object
      properties:
        id:
          type: string
        names:
          type: string
        botId:
          type: string
        groupId:
          type: string
        state:
          type: string
          enum:
            - auto
            - manual
    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:
    BadRequest:
      description: Bad request - Invalid format or missing required fields
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized - Invalid authentication credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not found - Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Basic authentication using Base64 encoded clientId:clientSecret

````