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

# User status

> Query and update the status of a user

## Description

Manage the operational status of a user within your bot. You can check whether a contact is in manual or automatic mode and update this setting to control who responds to conversations.

## Get User Status

### Endpoint

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

### Path Parameters

<ParamField path="userId" type="string" required>
  User's phone number (without the `+` sign).
</ParamField>

### Response Example

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

## Change User Status

### Endpoint

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

### Request Body

<ParamField body="ttl" type="number">
  Time in seconds that the manual state will remain before automatically expiring.
</ParamField>

<ParamField body="botId" type="string" required>
  Identifier of the bot associated with the user.
</ParamField>

<ParamField body="userId" type="string" required>
  User's phone number (without the `+` sign).
</ParamField>

<ParamField body="state" type="string" required>
  Target state. Allowed values: `"manual"` or `"auto"`.
</ParamField>

### Request Example

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

### Response Example

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

<Warning>
  When a user is in `manual` state, the bot stops responding automatically and manual messages must be sent using the send endpoints. Make sure to coordinate the state change with your support team.
</Warning>

## Common Errors

* `400` - Could not get or update the user's status.
* `401` - Invalid or missing credentials.
* `404` - User or bot not found.


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

````