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

# Orders heartbeat

> Auto-cancel your orders if your client disconnects

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 endpoint in any client that places resting orders — if your process crashes or loses connectivity, the heartbeat ensures stale orders get pulled instead of staying on the book.

## Request

`POST /user/ordersHeartbeat`

<ParamField body="timeout" type="integer" required>
  Cancel-after timeout, in seconds. Must be greater than `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>

## Response

The response is forwarded from the orders service:

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

## Errors

| Status | Meaning                                     |
| ------ | ------------------------------------------- |
| `400`  | `timeout` missing, not a number, or `<= 5`. |
| `503`  | Orders service unreachable.                 |


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

````