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

# Heartbeat de órdenes

> Autocancela tus órdenes si tu cliente se desconecta

Un mecanismo de seguridad: envía un heartbeat con un `timeout` (en segundos). Si el siguiente heartbeat no se recibe en `timeout` segundos, **se cancelan todas tus órdenes abiertas**.

Usa este endpoint en cualquier cliente que coloque órdenes en espera: si tu proceso se cae o pierde conectividad, el heartbeat asegura que las órdenes obsoletas se retiren en lugar de quedarse en el libro.

<h2 id="request">
  Solicitud
</h2>

`POST /user/ordersHeartbeat`

<ParamField body="timeout" type="integer" required>
  Timeout de cancelación, en segundos. Debe ser mayor que `5`.
</ParamField>

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.4casters.io/user/ordersHeartbeat \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{"timeout": 30}'
  ```

  ```json JSON body theme={null}
  { "timeout": 30 }
  ```
</CodeGroup>

<h2 id="response">
  Respuesta
</h2>

La respuesta se reenvía desde el servicio de órdenes:

```json theme={null}
{ "data": { /* heartbeat ack payload */ } }
```

<h2 id="errors">
  Errores
</h2>

| Estado | Significado |
| - | - |
| `400` | `timeout` falta, no es un número o es `<= 5`. |
| `503` | El servicio de órdenes no está disponible. |


## OpenAPI

````yaml POST /user/ordersHeartbeat
openapi: 3.1.0
info:
  title: 4casters REST API
  version: 1.0.0
  description: >-
    Public REST API for the 4casters peer-to-peer betting exchange. Use this API
    to manage your account, query the orderbook and games, and place / edit /
    cancel orders.


    All responses (unless noted otherwise) are JSON envelopes of the form `{
    "data": ... }`.
  contact:
    name: 4casters
    url: https://4casters.io
servers:
  - url: https://api.4casters.io
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Authentication
    description: Login and account session management
  - name: User
    description: Read account info, bets, and orders
  - name: Orders
    description: Place, edit, look up, and cancel orders
  - name: Markets
    description: Browse leagues, games, participants, and orderbooks
  - name: Affiliate
    description: Affiliate / referral commission
paths:
  /user/ordersHeartbeat:
    post:
      tags:
        - User
      summary: Send orders heartbeat
      description: >-
        A safety mechanism: send a heartbeat with a `timeout` (in seconds). If
        the next heartbeat is not received within `timeout` seconds, **all of
        your open orders are cancelled**. Use this to ensure that orders are
        pulled if your client loses connectivity.


        `timeout` must be greater than 5 seconds.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - timeout
              properties:
                timeout:
                  type: integer
                  minimum: 6
                  description: Cancel-after timeout, in seconds.
            example:
              timeout: 30
      responses:
        '200':
          description: >-
            Heartbeat acknowledged. The response shape is forwarded from the
            orders service.
        '400':
          description: Invalid timeout (must be > 5)
        '401':
          $ref: '#/components/responses/Unauthorized'
        '503':
          description: Orders service unreachable
components:
  responses:
    Unauthorized:
      description: Missing or invalid auth token
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Pass your auth token in the `Authorization` header. The `Bearer` prefix
        is optional; the server also accepts a signed `auth` cookie or a `token`
        field in the request body.

````

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