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

# Status do usuário

> Consulte e atualize o status de um usuário

## Descrição

Gerencie o status operacional de um usuário dentro do seu bot. Você pode verificar se um contato está no modo manual ou automático e atualizar essa configuração para controlar quem responde às conversas.

## Obter Status do Usuário

### Endpoint

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

### Parâmetros de Path

<ParamField path="userId" type="string" required>
  Número de telefone do usuário (sem o sinal `+`).
</ParamField>

### Exemplo de Resposta

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

## Alterar Status do Usuário

### Endpoint

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

### Corpo da Requisição

<ParamField body="ttl" type="number">
  Tempo em segundos que o estado manual permanecerá antes de expirar automaticamente.
</ParamField>

<ParamField body="botId" type="string" required>
  Identificador do bot associado ao usuário.
</ParamField>

<ParamField body="userId" type="string" required>
  Número de telefone do usuário (sem o sinal `+`).
</ParamField>

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

### Exemplo de Requisição

```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"
  }'
```

### Exemplo de Resposta

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

<Warning>
  Quando um usuário está no estado `manual`, o bot para de responder automaticamente e mensagens manuais devem ser enviadas usando os endpoints de envio. Certifique-se de coordenar a mudança de estado com sua equipe de suporte.
</Warning>

## Erros Comuns

* `400` - Não foi possível obter ou atualizar o status do usuário.
* `401` - Credenciais inválidas ou ausentes.
* `404` - Usuário ou bot não encontrado.


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

````