Send orders heartbeat
curl --request POST \
--url https://api.4casters.io/user/ordersHeartbeat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"timeout": 30
}'import requests
url = "https://api.4casters.io/user/ordersHeartbeat"
payload = { "timeout": 30 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({timeout: 30})
};
fetch('https://api.4casters.io/user/ordersHeartbeat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.4casters.io/user/ordersHeartbeat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'timeout' => 30
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.4casters.io/user/ordersHeartbeat"
payload := strings.NewReader("{\n \"timeout\": 30\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.4casters.io/user/ordersHeartbeat")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"timeout\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.4casters.io/user/ordersHeartbeat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"timeout\": 30\n}"
response = http.request(request)
puts response.read_bodyUser
Orders heartbeat
Auto-cancel your orders if your client disconnects
POST
/
user
/
ordersHeartbeat
Send orders heartbeat
curl --request POST \
--url https://api.4casters.io/user/ordersHeartbeat \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"timeout": 30
}'import requests
url = "https://api.4casters.io/user/ordersHeartbeat"
payload = { "timeout": 30 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({timeout: 30})
};
fetch('https://api.4casters.io/user/ordersHeartbeat', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.4casters.io/user/ordersHeartbeat",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'timeout' => 30
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.4casters.io/user/ordersHeartbeat"
payload := strings.NewReader("{\n \"timeout\": 30\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.4casters.io/user/ordersHeartbeat")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"timeout\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.4casters.io/user/ordersHeartbeat")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"timeout\": 30\n}"
response = http.request(request)
puts response.read_bodyA 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
integer
required
Cancel-after timeout, in seconds. Must be greater than
5.curl -X POST https://api.4casters.io/user/ordersHeartbeat \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"timeout": 30}'
{ "timeout": 30 }
Response
The response is forwarded from the orders service:{ "data": { /* heartbeat ack payload */ } }
Errors
| Status | Meaning |
|---|---|
400 | timeout missing, not a number, or <= 5. |
503 | Orders service unreachable. |
Authorizations
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.
Body
application/json
Cancel-after timeout, in seconds.
Required range:
x >= 6Response
Heartbeat acknowledged. The response shape is forwarded from the orders service.
Was this page helpful?