# Ask the pages of a user

`POST https://rest.wordplus.cloud/wordplus/realtime/users/{id}/ask`

Sends an event to the open pages of a user and waits for their replies. A page answers the events it chose with the
browser `rt.answer( event, handler )`, which returns the reply. The answer comes with the first reply, or with
`all` once `timeout` is over, with every reply by then. No page answering is no reply.

Seal `data` with the key of the user to keep it from WordPlus Cloud ([sealing](/api/sealing/)): the pages seal their
replies with the same key. The packages do both by default.

In the packages: `realtime.user( id ).ask( event, data, { timeout, all } )`.

## Parameters

| Name | In | |
|---|---|---|
| `id` (required) | path | The user id, percent-encoded. |

## Request

```json
{
  "event": "cart",
  "data": {
    "why": "checkout"
  },
  "timeout": 5000
}
```

## Answer

The replies, in the order they came: one at most without `all`.

```json
{
  "ok": true,
  "replies": [
    {
      "data": {
        "items": 3
      },
      "at": 1791638400000
    }
  ]
}
```

## Refusals

- **400**: `bad_event`: a name kept for the rooms. `bad_request`: a timeout out of range.
- **401**: `missing_signature`, `stale_signature` (a clock off by more than 5 minutes), `unknown_site`, `bad_signature` (a wrong secret, or a body or path other than the one signed).
- **403**: `not_included`: your plan does not include it.
- **413**: `too_large`: data over 1 MB. `too_many`: over 1,000 rooms or users in an event, or 100 events in a batch.

## Examples

`wordplus()` (in Go `app.Request()`) signs and sends the request: https://docs.wordplus.cloud/api/signing/ has it in each language.

**curl**

```bash
wordplus POST '/wordplus/realtime/users/42/ask' '{"event":"cart","data":{"why":"checkout"},"timeout":5000}'
```

**Node**

```js
const { replies } = await wordplus('POST', '/wordplus/realtime/users/42/ask', { event: 'cart', data: { why: 'checkout' }, timeout: 5000 });
```

**Python**

```python
replies = wordplus("POST", "/wordplus/realtime/users/42/ask", {"event": "cart", "data": {"why": "checkout"}, "timeout": 5000})["replies"]
```

**PHP**

```php
$replies = wordplus('POST', '/wordplus/realtime/users/42/ask', ['event' => 'cart', 'data' => ['why' => 'checkout'], 'timeout' => 5000])['replies'];
```

**Go**

```go
answer, err := app.Request("POST", "/wordplus/realtime/users/42/ask", map[string]any{"event": "cart", "data": map[string]any{"why": "checkout"}, "timeout": 5000})
```

