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

> Cancela automaticamente suas ordens se o seu cliente se desconectar

Um mecanismo de segurança: envie um heartbeat com um `timeout` (em segundos). Se o próximo heartbeat não for recebido em `timeout` segundos, **todas as suas ordens abertas são canceladas**.

Use este endpoint em qualquer cliente que envie ordens em aberto: se o seu processo cair ou perder conectividade, o heartbeat garante que as ordens obsoletas sejam retiradas em vez de ficarem no livro.

## Requisição

`POST /user/ordersHeartbeat`

**timeout** `integer` *required*

Timeout de cancelamento, em segundos. Deve ser maior que `5`.

```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 Corpo JSON theme={null}
{ "timeout": 30 }
```

## Resposta

A resposta é repassada a partir do serviço de ordens:

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

## Erros

| Status | Significado |
| - | - |
| `400` | `timeout` falta, não é um número ou é `<= 5`. |
| `503` | O serviço de ordens não está disponível. |


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